Ejemplo n.º 1
0
  /**
   * @return a list of forms of @param verb which match @param expectedVerbPOS (person:number)
   * @param toUppercase true when the suggestions should be capitalized
   */
  private List<String> getVerbSuggestions(
      final AnalyzedTokenReadings verb, final String expectedVerbPOS, final boolean toUppercase) {
    // find the first verb reading
    AnalyzedToken verbToken = new AnalyzedToken("", "", "");
    for (AnalyzedToken token : verb.getReadings()) {
      if (token.getPOSTag().startsWith("VER:")) {
        verbToken = token;
        break;
      }
    }

    try {
      String[] synthesized =
          german.getSynthesizer().synthesize(verbToken, "VER.*:" + expectedVerbPOS + ".*", true);
      // remove duplicates
      Set<String> suggestionSet = new HashSet<>();
      suggestionSet.addAll(Arrays.asList(synthesized));
      List<String> suggestions = new ArrayList<>();
      suggestions.addAll(suggestionSet);
      if (toUppercase) {
        for (int i = 0; i < suggestions.size(); ++i) {
          suggestions.set(i, StringTools.uppercaseFirstChar(suggestions.get(i)));
        }
      }
      Collections.sort(suggestions);
      return suggestions;
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
Ejemplo n.º 2
0
 @Nullable
 private String baseForThirdPersonSingularVerb(String word) throws IOException {
   List<AnalyzedTokenReadings> readings = tagger.tag(Collections.singletonList(word));
   for (AnalyzedTokenReadings reading : readings) {
     if (reading.hasPartialPosTag("VER:3:SIN:")) {
       return reading.getReadings().get(0).getLemma();
     }
   }
   return null;
 }
 @Override
 protected boolean isTagged(AnalyzedTokenReadings tokenReadings) {
   for (AnalyzedToken token : tokenReadings.getReadings()) {
     String posTag = token.getPOSTag();
     if (isGoodPosTag(posTag)) {
       return true;
     }
   }
   return false;
 }