Search in sources :

Example 1 with PosTaggedTokenWrapper

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

the class AddressFunctionBuffer method check.

@Override
public FeatureResult<PosTaggedTokenWrapper> check(ParseConfigurationWrapper wrapper, RuntimeEnvironment env) throws TalismaneException {
    ParseConfiguration configuration = wrapper.getParseConfiguration();
    PosTaggedToken resultToken = null;
    FeatureResult<Integer> indexResult = indexFeature.check(configuration, env);
    if (indexResult != null) {
        int index = indexResult.getOutcome();
        Iterator<PosTaggedToken> bufferIterator = configuration.getBuffer().iterator();
        for (int i = 0; i <= index; i++) {
            if (!bufferIterator.hasNext()) {
                resultToken = null;
                break;
            }
            resultToken = bufferIterator.next();
        }
    }
    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 2 with PosTaggedTokenWrapper

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

the class AddressFunctionHead 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();
        resultToken = configuration.getHead(referenceToken);
    }
    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 3 with PosTaggedTokenWrapper

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

the class AddressFunctionLDep 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> leftDependents = configuration.getLeftDependents(referenceToken);
        if (leftDependents.size() > 0)
            resultToken = leftDependents.get(0);
    }
    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 4 with PosTaggedTokenWrapper

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

the class AddressFunctionOffset 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> offsetResult = offsetFeature.check(configuration, env);
    if (addressResult != null && offsetResult != null) {
        int offset = offsetResult.getOutcome();
        PosTaggedToken referenceToken = addressResult.getOutcome().getPosTaggedToken();
        int refIndex = referenceToken.getToken().getIndex();
        int index = refIndex + offset;
        if (index >= 0 && index < configuration.getPosTagSequence().size()) {
            resultToken = configuration.getPosTagSequence().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 5 with PosTaggedTokenWrapper

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

the class AddressFunctionSequence method check.

@Override
public FeatureResult<PosTaggedTokenWrapper> check(ParseConfigurationWrapper wrapper, RuntimeEnvironment env) throws TalismaneException {
    ParseConfiguration configuration = wrapper.getParseConfiguration();
    PosTaggedToken resultToken = null;
    FeatureResult<Integer> indexResult = indexFeature.check(configuration, env);
    if (indexResult != null) {
        int index = indexResult.getOutcome();
        if (index >= 0 && index < configuration.getPosTagSequence().size())
            resultToken = configuration.getPosTagSequence().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)

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