Ejemplo n.º 1
0
 public boolean add(List<String> tokens, Collection<EntityType> types) {
   if (tokens.size() == 0)
     throw new IllegalArgumentException("Number of tokens must be greater than zero");
   // Verify that the sequence to be added is not listed as not included
   Boolean value = notInclude.getValue(tokens);
   if (value != null) return false;
   // If configured, drop parenthetical phrases at the end of the sequence
   if (dropEndParentheticals && tokens.get(tokens.size() - 1).equals(")")) {
     int openParen = tokens.size() - 1;
     while (openParen > 0 && !tokens.get(openParen).equals("(")) openParen--;
     if (openParen <= 0) return false;
     tokens = tokens.subList(0, openParen);
   }
   Set<EntityType> currentTypes = entities.getValue(tokens);
   if (currentTypes == null) {
     currentTypes = new HashSet<EntityType>(1);
     entities.add(tokens, currentTypes);
   }
   return currentTypes.addAll(types);
 }
Ejemplo n.º 2
0
 public void suppress(String text) {
   notInclude.add(process(text), Boolean.TRUE);
 }