Search in sources :

Example 1 with PosTaggerLexicon

use of com.joliciel.talismane.lexicon.PosTaggerLexicon in project talismane by joliciel-informatique.

the class LexiconPosTagForStringFeature method checkInternal.

@Override
public FeatureResult<Boolean> checkInternal(TokenWrapper tokenWrapper, RuntimeEnvironment env) throws TalismaneException {
    TokenWrapper innerWrapper = this.getToken(tokenWrapper, env);
    if (innerWrapper == null)
        return null;
    FeatureResult<Boolean> result = null;
    FeatureResult<String> wordToCheckResult = wordToCheckFeature.check(innerWrapper, env);
    if (wordToCheckResult != null) {
        FeatureResult<String> posTagResult = posTagFeature.check(innerWrapper, env);
        if (posTagResult != null) {
            PosTag posTag = TalismaneSession.get(sessionId).getPosTagSet().getPosTag(posTagResult.getOutcome());
            String wordToCheck = wordToCheckResult.getOutcome();
            PosTaggerLexicon lexicon = TalismaneSession.get(sessionId).getMergedLexicon();
            Set<PosTag> posTags = lexicon.findPossiblePosTags(wordToCheck);
            boolean hasPosTag = (posTags.contains(posTag));
            result = this.generateResult(hasPosTag);
        }
    }
    return result;
}
Also used : PosTag(com.joliciel.talismane.posTagger.PosTag) PosTaggerLexicon(com.joliciel.talismane.lexicon.PosTaggerLexicon)

Example 2 with PosTaggerLexicon

use of com.joliciel.talismane.lexicon.PosTaggerLexicon in project talismane by joliciel-informatique.

the class LexiconPosTagsForStringFeature method checkInternal.

@Override
public FeatureResult<List<WeightedOutcome<String>>> checkInternal(TokenWrapper tokenWrapper, RuntimeEnvironment env) throws TalismaneException {
    TokenWrapper innerWrapper = this.getToken(tokenWrapper, env);
    if (innerWrapper == null)
        return null;
    FeatureResult<List<WeightedOutcome<String>>> result = null;
    FeatureResult<String> wordToCheckResult = wordToCheckFeature.check(innerWrapper, env);
    if (wordToCheckResult != null) {
        String wordToCheck = wordToCheckResult.getOutcome();
        List<WeightedOutcome<String>> resultList = new ArrayList<WeightedOutcome<String>>();
        PosTaggerLexicon lexicon = TalismaneSession.get(sessionId).getMergedLexicon();
        Set<PosTag> posTags = lexicon.findPossiblePosTags(wordToCheck);
        for (PosTag posTag : posTags) {
            resultList.add(new WeightedOutcome<String>(posTag.getCode(), 1.0));
        }
        if (resultList.size() > 0)
            result = this.generateResult(resultList);
    }
    return result;
}
Also used : PosTag(com.joliciel.talismane.posTagger.PosTag) PosTaggerLexicon(com.joliciel.talismane.lexicon.PosTaggerLexicon) ArrayList(java.util.ArrayList) WeightedOutcome(com.joliciel.talismane.utils.WeightedOutcome) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

PosTaggerLexicon (com.joliciel.talismane.lexicon.PosTaggerLexicon)2 PosTag (com.joliciel.talismane.posTagger.PosTag)2 WeightedOutcome (com.joliciel.talismane.utils.WeightedOutcome)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1