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

Version Path
abstractor-4.4.7 lib/lingscope/src/lingscope/algorithms/Annotator.java
abstractor-4.4.6 lib/lingscope/src/lingscope/algorithms/Annotator.java
abstractor-4.4.5 lib/lingscope/src/lingscope/algorithms/Annotator.java
abstractor-4.4.4 lib/lingscope/src/lingscope/algorithms/Annotator.java
abstractor-4.4.3 lib/lingscope/src/lingscope/algorithms/Annotator.java
abstractor-4.4.2 lib/lingscope/src/lingscope/algorithms/Annotator.java
abstractor-4.4.1 lib/lingscope/src/lingscope/algorithms/Annotator.java
abstractor-4.4.0 lib/lingscope/src/lingscope/algorithms/Annotator.java
abstractor-4.3.3 lib/lingscope/src/lingscope/algorithms/Annotator.java
abstractor-4.3.2 lib/lingscope/src/lingscope/algorithms/Annotator.java
abstractor-4.3.1 lib/lingscope/src/lingscope/algorithms/Annotator.java
abstractor-4.3.0 lib/lingscope/src/lingscope/algorithms/Annotator.java
abstractor-4.2.3 lib/lingscope/src/lingscope/algorithms/Annotator.java
abstractor-4.2.2 lib/lingscope/src/lingscope/algorithms/Annotator.java
abstractor-4.2.1 lib/lingscope/src/lingscope/algorithms/Annotator.java
abstractor-4.2.0 lib/lingscope/src/lingscope/algorithms/Annotator.java
abstractor-4.1.5 lib/lingscope/src/lingscope/algorithms/Annotator.java
abstractor-4.1.4 lib/lingscope/src/lingscope/algorithms/Annotator.java
abstractor-4.1.3 lib/lingscope/src/lingscope/algorithms/Annotator.java
abstractor-4.1.2 lib/lingscope/src/lingscope/algorithms/Annotator.java