Search in sources :

Example 16 with PosTag

use of com.joliciel.talismane.posTagger.PosTag in project talismane by joliciel-informatique.

the class LexiconPosTagsFeature 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;
    Token token = innerWrapper.getToken();
    FeatureResult<List<WeightedOutcome<String>>> result = null;
    List<WeightedOutcome<String>> resultList = new ArrayList<WeightedOutcome<String>>();
    for (PosTag posTag : token.getPossiblePosTags()) {
        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) ArrayList(java.util.ArrayList) WeightedOutcome(com.joliciel.talismane.utils.WeightedOutcome) Token(com.joliciel.talismane.tokeniser.Token) List(java.util.List) ArrayList(java.util.ArrayList)

Example 17 with PosTag

use of com.joliciel.talismane.posTagger.PosTag 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

PosTag (com.joliciel.talismane.posTagger.PosTag)17 ArrayList (java.util.ArrayList)6 Token (com.joliciel.talismane.tokeniser.Token)5 PosTagSequence (com.joliciel.talismane.posTagger.PosTagSequence)3 PosTagSet (com.joliciel.talismane.posTagger.PosTagSet)3 WeightedOutcome (com.joliciel.talismane.utils.WeightedOutcome)3 List (java.util.List)3 LexicalEntry (com.joliciel.talismane.lexicon.LexicalEntry)2 PosTaggerLexicon (com.joliciel.talismane.lexicon.PosTaggerLexicon)2 TalismaneException (com.joliciel.talismane.TalismaneException)1 TalismaneTest (com.joliciel.talismane.TalismaneTest)1 BooleanFeature (com.joliciel.talismane.machineLearning.features.BooleanFeature)1 FunctionDescriptor (com.joliciel.talismane.machineLearning.features.FunctionDescriptor)1 FunctionDescriptorParser (com.joliciel.talismane.machineLearning.features.FunctionDescriptorParser)1 PosTaggerContext (com.joliciel.talismane.posTagger.PosTaggerContext)1 UnknownPosTagException (com.joliciel.talismane.posTagger.UnknownPosTagException)1 Config (com.typesafe.config.Config)1 FileOutputStream (java.io.FileOutputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 ZipEntry (java.util.zip.ZipEntry)1