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;
}
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;
}
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;
}
Aggregations