private static TokenNameFinderModel organizationModel;
private static TokenNameFinderModel personModel;
private static TokenNameFinderModel locationModel;
- private static TokenNameFinderModel timeModel;
private static TokenizerModel tokenModel;
public static List<String> classify(String str, List<String> entities, Config config) throws IOException {
classify(str, getOrganizationModel(), entities, config);
-
classify(str, getPersonModel(), entities, config);
classify(str, getLocationModel(), entities, config);
- classify(str, getTimeModel(), entities, config);
-
return entities;
}
return locationModel;
}
-
- private static TokenNameFinderModel getTimeModel() throws IOException {
- synchronized (OpenNLP.class) {
- if (timeModel == null) {
- InputStream inputStream = OpenNLP.class.getResourceAsStream("/en-ner-time.bin");
- timeModel = new TokenNameFinderModel(inputStream);
- }
- }
-
- return timeModel;
- }
private static List<String> classify(String str, TokenNameFinderModel model, List<String> entities, Config config) throws IOException {
String entity;
LOG.finest(entity + " " + s.getProb() + " " + s.toString());
if (!config.isBlacklistedEntity(entity) && !entities.contains(entity))
- entities.add(entity);
+ entities.add(config.getEntityAlias(entity));
}
return entities;