Skip to content

Commit

Permalink
simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnaber committed Sep 29, 2015
1 parent d30de33 commit 67be29a
Showing 1 changed file with 3 additions and 18 deletions.
Expand Up @@ -20,7 +20,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
* Tags a word using two taggers, combining their results.
Expand Down Expand Up @@ -60,24 +59,10 @@ public List<TaggedWord> tag(String word) {
result.addAll(tagger1.tag(word));
}
if (removalTagger != null) {
removeReadings(word, result);
List<TaggedWord> removalTags = removalTagger.tag(word);
result.removeAll(removalTags);
}
return result;
}

private void removeReadings(String word, List<TaggedWord> result) {
List<TaggedWord> removalTags = removalTagger.tag(word);
List<TaggedWord> toRemove = new ArrayList<>();
for (TaggedWord taggedWord : result) {
for (TaggedWord removalTag : removalTags) {
if (Objects.equals(taggedWord.getLemma(), removalTag.getLemma()) && Objects.equals(taggedWord.getPosTag(), removalTag.getPosTag())) {
toRemove.add(removalTag);
}
}
}
for (TaggedWord taggedWord : toRemove) {
result.remove(taggedWord);
}
}


}

0 comments on commit 67be29a

Please sign in to comment.