Search in sources :

Example 16 with PosTaggedTokenWrapper

use of com.joliciel.talismane.posTagger.features.PosTaggedTokenWrapper 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 17 with PosTaggedTokenWrapper

use of com.joliciel.talismane.posTagger.features.PosTaggedTokenWrapper 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 18 with PosTaggedTokenWrapper

use of com.joliciel.talismane.posTagger.features.PosTaggedTokenWrapper 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)

Example 19 with PosTaggedTokenWrapper

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

the class AddressFunctionDep method check.

@Override
public FeatureResult<PosTaggedTokenWrapper> check(ParseConfigurationWrapper wrapper, RuntimeEnvironment env) throws TalismaneException {
    ParseConfiguration configuration = wrapper.getParseConfiguration();
    PosTaggedToken resultToken = null;
    FeatureResult<PosTaggedTokenWrapper> addressResult = addressFunction.check(wrapper, env);
    FeatureResult<Integer> indexResult = indexFeature.check(configuration, env);
    if (addressResult != null && indexResult != null) {
        int index = indexResult.getOutcome();
        PosTaggedToken referenceToken = addressResult.getOutcome().getPosTaggedToken();
        if (referenceToken != null) {
            List<PosTaggedToken> dependents = configuration.getDependents(referenceToken);
            if (index < dependents.size()) {
                resultToken = dependents.get(index);
            }
        }
    }
    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 20 with PosTaggedTokenWrapper

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

the class AddressFunctionRDep method check.

@Override
public FeatureResult<PosTaggedTokenWrapper> check(ParseConfigurationWrapper wrapper, RuntimeEnvironment env) throws TalismaneException {
    ParseConfiguration configuration = wrapper.getParseConfiguration();
    PosTaggedToken resultToken = null;
    FeatureResult<PosTaggedTokenWrapper> addressResult = addressFunction.check(wrapper, env);
    if (addressResult != null) {
        PosTaggedToken referenceToken = addressResult.getOutcome().getPosTaggedToken();
        List<PosTaggedToken> rightDependents = configuration.getRightDependents(referenceToken);
        if (rightDependents.size() > 0)
            resultToken = rightDependents.get(rightDependents.size() - 1);
    }
    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)20 PosTaggedTokenWrapper (com.joliciel.talismane.posTagger.features.PosTaggedTokenWrapper)20 ParseConfiguration (com.joliciel.talismane.parser.ParseConfiguration)18 IntegerLiteralFeature (com.joliciel.talismane.machineLearning.features.IntegerLiteralFeature)1 DependencyArc (com.joliciel.talismane.parser.DependencyArc)1 PosTagSequence (com.joliciel.talismane.posTagger.PosTagSequence)1