Sha256: a5a299084adf35f0310d6bcd6f49be06bbe396b2419714901a8db9a9d78e5c0d
Contents?: true
Size: 1.57 KB
Versions: 45
Compression:
Stored size: 1.57 KB
Contents
package lingscope.algorithms; import java.util.List; import lingscope.structures.AnnotatedSentence; /** * * @author shashank */ public abstract class Annotator { protected String beginTag; protected String interTag; protected String otherTag; public Annotator(String beginTag, String interTag, String otherTag) { this.beginTag = beginTag; this.interTag = interTag; this.otherTag = otherTag; } public abstract void serializeAnnotator(String trainingFile, String modelFile); public abstract AnnotatedSentence annotateSentence(String sentence, boolean isTokenized); public abstract void loadAnnotator(String modelFile); /** * Checks if the given target phrase is negated in the given sentence. Only * the first word of the target phrase is used * @param sentence * @param isTokenized * @param targetPhrase * @return */ public boolean isTargetNegated(String sentence, boolean isTokenized, String targetPhrase) { AnnotatedSentence annotatedSentence = annotateSentence(sentence, isTokenized); String[] targetPhraseWords = targetPhrase.split("\\s+"); List<String> words = annotatedSentence.getWords(); List<Boolean> areNegated = annotatedSentence.getIsAnnotatedTags(); int index = 0; for (String word : words) { if (targetPhraseWords[0].equalsIgnoreCase(word)) { return areNegated.get(index); } ++index; } System.err.println("Phrase not found: " + targetPhrase); return false; } }
Version data entries
45 entries across 45 versions & 1 rubygems