Search in sources :

Example 6 with HeadFinder

use of edu.stanford.nlp.trees.HeadFinder in project CoreNLP by stanfordnlp.

the class ShiftReduceParserTest method convertTree.

Tree convertTree(String treeText) {
    Options op = new Options();
    HeadFinder binaryHeadFinder = new BinaryHeadFinder(op.tlpParams.headFinder());
    Tree tree = Tree.valueOf(treeText);
    Trees.convertToCoreLabels(tree);
    tree.percolateHeadAnnotations(binaryHeadFinder);
    return tree;
}
Also used : BinaryHeadFinder(edu.stanford.nlp.parser.lexparser.BinaryHeadFinder) Options(edu.stanford.nlp.parser.lexparser.Options) BinaryHeadFinder(edu.stanford.nlp.parser.lexparser.BinaryHeadFinder) HeadFinder(edu.stanford.nlp.trees.HeadFinder) Tree(edu.stanford.nlp.trees.Tree)

Example 7 with HeadFinder

use of edu.stanford.nlp.trees.HeadFinder in project CoreNLP by stanfordnlp.

the class FrenchTreebankParserParams method setOptionFlag.

@Override
public int setOptionFlag(String[] args, int i) {
    if (annotations.containsKey(args[i])) {
        addFeature(args[i]);
        i++;
    } else if (args[i].equals("-collinizerRetainsPunctuation")) {
        optionsString.append("Collinizer retains punctuation.\n");
        collinizerRetainsPunctuation = true;
        i++;
    } else if (args[i].equalsIgnoreCase("-headFinder") && (i + 1 < args.length)) {
        try {
            HeadFinder hf = (HeadFinder) Class.forName(args[i + 1]).newInstance();
            setHeadFinder(hf);
            optionsString.append("HeadFinder: " + args[i + 1] + "\n");
        } catch (Exception e) {
            log.info(e);
            log.info(this.getClass().getName() + ": Could not load head finder " + args[i + 1]);
        }
        i += 2;
    } else if (args[i].equals("-xmlFormat")) {
        optionsString.append("Reading trees in XML format.\n");
        readPennFormat = false;
        setInputEncoding(tlp.getEncoding());
        i++;
    } else if (args[i].equals("-frenchFactored")) {
        for (String feature : factoredFeatures) addFeature(feature);
        i++;
    } else if (args[i].equals("-frenchMWMap")) {
        loadMWMap(args[i + 1]);
        i += 2;
    } else if (args[i].equals("-tsg")) {
        //wsg2011: These features should be removed for TSG extraction.
        //If they are retained, the resulting grammar seems to be too brittle....
        optionsString.append("Removing baseline features: -markVN, -coord1");
        removeFeature("-markVN");
        optionsString.append(" (removed -markVN)");
        removeFeature("-coord1");
        optionsString.append(" (removed -coord1)\n");
        i++;
    } else if (args[i].equals("-factlex") && (i + 1 < args.length)) {
        String activeFeats = setupMorphoFeatures(args[i + 1]);
        optionsString.append("Factored Lexicon: active features: ").append(activeFeats);
        // WSGDEBUG Maybe add -mweTag in place of -tagPAFr?
        removeFeature("-tagPAFr");
        optionsString.append(" (removed -tagPAFr)\n");
        // Add -mweTag
        String[] option = { "-mweTag" };
        setOptionFlag(option, 0);
        i += 2;
    } else if (args[i].equals("-noFeatures")) {
        for (String feature : annotations.keySet()) removeFeature(feature);
        optionsString.append("Removed all manual features.\n");
        i++;
    } else if (args[i].equals("-ccTagsetAnnotations")) {
        tagSpec = new FrenchMorphoFeatureSpecification();
        tagSpec.activate(MorphoFeatureType.OTHER);
        optionsString.append("Adding CC tagset as POS state splits.\n");
        ++i;
    }
    return i;
}
Also used : HeadFinder(edu.stanford.nlp.trees.HeadFinder) DybroFrenchHeadFinder(edu.stanford.nlp.trees.international.french.DybroFrenchHeadFinder) FrenchMorphoFeatureSpecification(edu.stanford.nlp.international.french.FrenchMorphoFeatureSpecification) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 8 with HeadFinder

use of edu.stanford.nlp.trees.HeadFinder in project CoreNLP by stanfordnlp.

the class SpanishTreebankParserParams method setOptionFlag.

/**
   * Set language-specific options according to flags. This routine should process the option starting in args[i] (which
   * might potentially be several arguments long if it takes arguments). It should return the index after the last index
   * it consumed in processing.  In particular, if it cannot process the current option, the return value should be i.
   * <p/>
   * Generic options are processed separately by {@link edu.stanford.nlp.parser.lexparser.Options#setOption(String[], int)}, and implementations of this
   * method do not have to worry about them. The Options class handles routing options. TreebankParserParams that extend
   * this class should call super when overriding this method.
   *
   * @param args
   * @param i
   */
@Override
public int setOptionFlag(String[] args, int i) {
    if (args[i].equalsIgnoreCase("-headFinder") && (i + 1 < args.length)) {
        try {
            HeadFinder hf = (HeadFinder) Class.forName(args[i + 1]).newInstance();
            setHeadFinder(hf);
            optionsString.append("HeadFinder: " + args[i + 1] + "\n");
        } catch (Exception e) {
            log.info(e);
            log.info(this.getClass().getName() + ": Could not load head finder " + args[i + 1]);
        }
        i += 2;
    }
    return i;
}
Also used : SpanishHeadFinder(edu.stanford.nlp.trees.international.spanish.SpanishHeadFinder) HeadFinder(edu.stanford.nlp.trees.HeadFinder)

Aggregations

HeadFinder (edu.stanford.nlp.trees.HeadFinder)8 ModCollinsHeadFinder (edu.stanford.nlp.trees.ModCollinsHeadFinder)3 Tree (edu.stanford.nlp.trees.Tree)3 BinaryHeadFinder (edu.stanford.nlp.parser.lexparser.BinaryHeadFinder)2 DybroFrenchHeadFinder (edu.stanford.nlp.trees.international.french.DybroFrenchHeadFinder)2 ChineseSemanticHeadFinder (edu.stanford.nlp.trees.international.pennchinese.ChineseSemanticHeadFinder)2 CorefCoreAnnotations (edu.stanford.nlp.coref.CorefCoreAnnotations)1 FrenchMorphoFeatureSpecification (edu.stanford.nlp.international.french.FrenchMorphoFeatureSpecification)1 CoreAnnotations (edu.stanford.nlp.ling.CoreAnnotations)1 CoreLabel (edu.stanford.nlp.ling.CoreLabel)1 Options (edu.stanford.nlp.parser.lexparser.Options)1 TreeBinarizer (edu.stanford.nlp.parser.lexparser.TreeBinarizer)1 SemanticGraphCoreAnnotations (edu.stanford.nlp.semgraph.SemanticGraphCoreAnnotations)1 BasicCategoryTreeTransformer (edu.stanford.nlp.trees.BasicCategoryTreeTransformer)1 CollinsHeadFinder (edu.stanford.nlp.trees.CollinsHeadFinder)1 CompositeTreeTransformer (edu.stanford.nlp.trees.CompositeTreeTransformer)1 DiskTreebank (edu.stanford.nlp.trees.DiskTreebank)1 LeftHeadFinder (edu.stanford.nlp.trees.LeftHeadFinder)1 SemanticHeadFinder (edu.stanford.nlp.trees.SemanticHeadFinder)1 TreeCoreAnnotations (edu.stanford.nlp.trees.TreeCoreAnnotations)1