Search in sources :

Example 56 with PosTaggedToken

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

the class DependencyCountIf method check.

@Override
public FeatureResult<Integer> check(ParseConfigurationWrapper wrapper, RuntimeEnvironment env) throws TalismaneException {
    ParseConfiguration configuration = wrapper.getParseConfiguration();
    FeatureResult<PosTaggedTokenWrapper> tokenResult = addressFunction.check(wrapper, env);
    FeatureResult<Integer> featureResult = null;
    if (tokenResult != null) {
        PosTaggedToken posTaggedToken = tokenResult.getOutcome().getPosTaggedToken();
        int countMatching = 0;
        for (PosTaggedToken dependent : configuration.getDependents(posTaggedToken)) {
            ParseConfigurationAddress parseConfigurationAddress = new ParseConfigurationAddress(env);
            parseConfigurationAddress.setParseConfiguration(configuration);
            parseConfigurationAddress.setPosTaggedToken(dependent);
            FeatureResult<Boolean> criterionResult = criterion.check(parseConfigurationAddress, env);
            if (criterionResult != null && criterionResult.getOutcome())
                countMatching++;
        }
        featureResult = this.generateResult(countMatching);
    }
    return featureResult;
}
Also used : PosTaggedToken(com.joliciel.talismane.posTagger.PosTaggedToken) PosTaggedTokenWrapper(com.joliciel.talismane.posTagger.features.PosTaggedTokenWrapper) ParseConfiguration(com.joliciel.talismane.parser.ParseConfiguration)

Example 57 with PosTaggedToken

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

the class DependencyLabelFeature method check.

@Override
public FeatureResult<String> check(ParseConfigurationWrapper wrapper, RuntimeEnvironment env) throws TalismaneException {
    PosTaggedTokenWrapper innerWrapper = this.getToken(wrapper, env);
    if (innerWrapper == null)
        return null;
    PosTaggedToken posTaggedToken = innerWrapper.getPosTaggedToken();
    if (posTaggedToken == null)
        return null;
    FeatureResult<String> featureResult = null;
    ParseConfiguration configuration = wrapper.getParseConfiguration();
    DependencyArc arc = configuration.getGoverningDependency(posTaggedToken);
    if (arc != null) {
        String label = arc.getLabel();
        if (label == null)
            label = "null";
        featureResult = this.generateResult(label);
    }
    return featureResult;
}
Also used : PosTaggedToken(com.joliciel.talismane.posTagger.PosTaggedToken) PosTaggedTokenWrapper(com.joliciel.talismane.posTagger.features.PosTaggedTokenWrapper) DependencyArc(com.joliciel.talismane.parser.DependencyArc) ParseConfiguration(com.joliciel.talismane.parser.ParseConfiguration)

Example 58 with PosTaggedToken

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

the class DependencySearchFeature method check.

@Override
public FeatureResult<PosTaggedTokenWrapper> check(ParseConfigurationWrapper wrapper, RuntimeEnvironment env) throws TalismaneException {
    ParseConfiguration configuration = wrapper.getParseConfiguration();
    PosTaggedToken resultToken = null;
    FeatureResult<PosTaggedTokenWrapper> referenceTokenResult = referenceTokenFeature.check(configuration, env);
    if (referenceTokenResult != null) {
        PosTaggedToken referenceToken = referenceTokenResult.getOutcome().getPosTaggedToken();
        ParseConfigurationAddress parseConfigurationAddress = new ParseConfigurationAddress(env);
        parseConfigurationAddress.setParseConfiguration(configuration);
        for (PosTaggedToken dependent : configuration.getDependents(referenceToken)) {
            parseConfigurationAddress.setPosTaggedToken(dependent);
            FeatureResult<Boolean> criterionResult = criterionFeature.check(parseConfigurationAddress, env);
            if (criterionResult != null) {
                boolean criterion = criterionResult.getOutcome();
                if (criterion) {
                    resultToken = dependent;
                    break;
                }
            }
        }
    }
    FeatureResult<PosTaggedTokenWrapper> featureResult = null;
    if (resultToken != null)
        featureResult = this.generateResult(resultToken);
    return featureResult;
}
Also used : PosTaggedToken(com.joliciel.talismane.posTagger.PosTaggedToken) PosTaggedTokenWrapper(com.joliciel.talismane.posTagger.features.PosTaggedTokenWrapper) ParseConfiguration(com.joliciel.talismane.parser.ParseConfiguration)

Example 59 with PosTaggedToken

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

the class DistanceFeature method check.

@Override
public FeatureResult<Integer> check(ParseConfigurationWrapper wrapper, RuntimeEnvironment env) throws TalismaneException {
    FeatureResult<PosTaggedTokenWrapper> tokenResult1 = addressFunction1.check(wrapper, env);
    FeatureResult<PosTaggedTokenWrapper> tokenResult2 = addressFunction2.check(wrapper, env);
    FeatureResult<Integer> featureResult = null;
    if (tokenResult1 != null && tokenResult2 != null) {
        PosTaggedToken posTaggedToken1 = tokenResult1.getOutcome().getPosTaggedToken();
        PosTaggedToken posTaggedToken2 = tokenResult2.getOutcome().getPosTaggedToken();
        int distance = posTaggedToken2.getToken().getIndex() - posTaggedToken1.getToken().getIndex();
        if (distance < 0)
            distance = 0 - distance;
        featureResult = this.generateResult(distance);
    }
    return featureResult;
}
Also used : PosTaggedToken(com.joliciel.talismane.posTagger.PosTaggedToken) PosTaggedTokenWrapper(com.joliciel.talismane.posTagger.features.PosTaggedTokenWrapper)

Example 60 with PosTaggedToken

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

the class ForwardSearchFeature method check.

@Override
public FeatureResult<PosTaggedTokenWrapper> check(ParseConfigurationWrapper wrapper, RuntimeEnvironment env) throws TalismaneException {
    ParseConfiguration configuration = wrapper.getParseConfiguration();
    PosTaggedToken resultToken = null;
    FeatureResult<PosTaggedTokenWrapper> referenceTokenResult = referenceTokenFeature.check(wrapper, env);
    if (referenceTokenResult != null) {
        PosTaggedToken referenceToken = referenceTokenResult.getOutcome().getPosTaggedToken();
        ParseConfigurationAddress parseConfigurationAddress = new ParseConfigurationAddress(env);
        parseConfigurationAddress.setParseConfiguration(configuration);
        for (int i = referenceToken.getToken().getIndex() + 1; i < configuration.getPosTagSequence().size(); i++) {
            PosTaggedToken nextToken = configuration.getPosTagSequence().get(i);
            parseConfigurationAddress.setPosTaggedToken(nextToken);
            FeatureResult<Boolean> criterionResult = criterionFeature.check(parseConfigurationAddress, env);
            if (criterionResult != null) {
                boolean criterion = criterionResult.getOutcome();
                if (criterion) {
                    resultToken = nextToken;
                    break;
                }
            }
        }
    }
    FeatureResult<PosTaggedTokenWrapper> featureResult = null;
    if (resultToken != null)
        featureResult = this.generateResult(resultToken);
    return featureResult;
}
Also used : PosTaggedToken(com.joliciel.talismane.posTagger.PosTaggedToken) PosTaggedTokenWrapper(com.joliciel.talismane.posTagger.features.PosTaggedTokenWrapper) ParseConfiguration(com.joliciel.talismane.parser.ParseConfiguration)

Aggregations

PosTaggedToken (com.joliciel.talismane.posTagger.PosTaggedToken)77 ParseConfiguration (com.joliciel.talismane.parser.ParseConfiguration)24 PosTaggedTokenWrapper (com.joliciel.talismane.posTagger.features.PosTaggedTokenWrapper)20 PosTagSequence (com.joliciel.talismane.posTagger.PosTagSequence)14 Token (com.joliciel.talismane.tokeniser.Token)11 DependencyArc (com.joliciel.talismane.parser.DependencyArc)9 TalismaneException (com.joliciel.talismane.TalismaneException)8 Decision (com.joliciel.talismane.machineLearning.Decision)8 RuntimeEnvironment (com.joliciel.talismane.machineLearning.features.RuntimeEnvironment)8 Sentence (com.joliciel.talismane.rawText.Sentence)8 TokenSequence (com.joliciel.talismane.tokeniser.TokenSequence)8 HashMap (java.util.HashMap)7 List (java.util.List)7 TalismaneTest (com.joliciel.talismane.TalismaneTest)6 PosTaggerContext (com.joliciel.talismane.posTagger.PosTaggerContext)6 PosTaggerContextImpl (com.joliciel.talismane.posTagger.PosTaggerContextImpl)6 Config (com.typesafe.config.Config)6 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 StringLiteralFeature (com.joliciel.talismane.machineLearning.features.StringLiteralFeature)5