Search in sources :

Example 6 with TaggedWord

use of org.languagetool.tagging.TaggedWord in project languagetool by languagetool-org.

the class ManualTaggerAdapter method tag.

@Override
public List<AnalyzedTokenReadings> tag(List<String> sentenceTokens) throws IOException {
    List<AnalyzedTokenReadings> tokenReadings = new ArrayList<>();
    int pos = 0;
    for (String word : sentenceTokens) {
        List<AnalyzedToken> l = new ArrayList<>();
        List<TaggedWord> manualTags = manualTagger.tag(word.toLowerCase());
        for (TaggedWord manualTag : manualTags) {
            l.add(new AnalyzedToken(word, manualTag.getPosTag(), manualTag.getLemma()));
        }
        if (l.isEmpty()) {
            l.add(new AnalyzedToken(word, null, null));
        }
        tokenReadings.add(new AnalyzedTokenReadings(l, pos));
        pos += word.length();
    }
    return tokenReadings;
}
Also used : AnalyzedToken(org.languagetool.AnalyzedToken) TaggedWord(org.languagetool.tagging.TaggedWord) ArrayList(java.util.ArrayList) AnalyzedTokenReadings(org.languagetool.AnalyzedTokenReadings)

Aggregations

ArrayList (java.util.ArrayList)6 AnalyzedToken (org.languagetool.AnalyzedToken)6 TaggedWord (org.languagetool.tagging.TaggedWord)6 AnalyzedTokenReadings (org.languagetool.AnalyzedTokenReadings)3 Nullable (org.jetbrains.annotations.Nullable)2 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1