List of usage examples for edu.stanford.nlp.trees CollinsHeadFinder CollinsHeadFinder
public CollinsHeadFinder()
From source file:coreferenceresolver.util.Util.java
public static void assignNounPhrases(List<NounPhrase> nounPhrases, List<Review> reviews) { CollinsHeadFinder headFinder = new CollinsHeadFinder(); for (NounPhrase np : nounPhrases) { Review review = reviews.get(np.getReviewId()); Sentence sentence = review.getSentences().get(np.getSentenceId()); String npContent = ""; for (CRFToken token : np.getCRFTokens()) { npContent += token.getWord() + " "; }/*from w w w . jav a 2 s .c o m*/ //Initiate a NP Tree Tree npNode = initNPTree(); for (CRFToken cRFToken : np.getCRFTokens()) { Tree cRFTokenTree = sentence.getTokens().get(cRFToken.getIdInSentence()).getTokenTree(); npNode.addChild(cRFTokenTree); } np.setNpNode(npNode); np.setHeadNode(npNode.headTerminal(headFinder)); int npOffsetBegin = sentence.getTokens().get(np.getCRFTokens().get(0).getIdInSentence()) .getOffsetBegin(); np.setOffsetBegin(npOffsetBegin); int npOffsetEnd = sentence.getTokens() .get(np.getCRFTokens().get(np.getCRFTokens().size() - 1).getIdInSentence()).getOffsetEnd(); np.setOffsetEnd(npOffsetEnd); review.addNounPhrase(np); sentence.addNounPhrase(np); sentence.setSentimentForNPs(); } }
From source file:edu.albany.cubism.util.StanfordChineseParser.java
public void printTree(Tree t) { tp.printTree(t);/*from w ww . j av a 2s. c o m*/ tp.printTree(t.headTerminal(new CollinsHeadFinder()));//SemanticHeadFinder())); //System.out.println("tree label: " + t.label()); List trees = t.subTreeList(); for (int i = 0; i < trees.size(); i++) { Tree sbt = (Tree) trees.get(i); /* * if (!sbt.isLeaf()) { trees.addAll(sbt.subTreeList()); } */ //System.out.println("sbt lable: " + sbt.label()); } //System.out.println("done"); List<Tree> leaves = t.getLeaves(); for (int i = 0; i < leaves.size(); i++) { Tree leaf = leaves.get(i); //if (leaf.parent() != null) { System.out.println(leaf.pennString() + " " + leaf.value()); //} } /* * Set dependencies = t.dependencies(); Iterator it = * dependencies.iterator(); while (it.hasNext()) { Dependency dependency * = (Dependency)it.next(); System.out.println(dependency.toString()); * System.out.println(dependency.name()); } */ }
From source file:edu.cmu.ark.AnalysisUtilities.java
License:Open Source License
private AnalysisUtilities() { parser = null;//from w w w . j ava 2 s .com conjugator = new VerbConjugator(); conjugator.load(GlobalProperties.getProperties().getProperty("verbConjugationsFile", "config" + File.separator + "verbConjugations.txt")); headfinder = new CollinsHeadFinder(); tree_factory = new LabeledScoredTreeFactory(); tlp = new PennTreebankLanguagePack(); }
From source file:edu.cmu.ark.nlp.question.Question.java
License:Open Source License
public Question(Properties props) { this.tree = null; this.hf = new CollinsHeadFinder(); this.setIntermediateTreeSupersenses(null); this.featureMap = new HashMap<String, Double>(); this.sourceDocument = null; this.sourceArticleName = ""; this.props = props; this.populateFeatureNames(props); }
From source file:edu.cmu.ark.nlp.question.Question.java
License:Open Source License
public Question(Properties props, Tree tree) { this.hf = new CollinsHeadFinder(); this.setIntermediateTreeSupersenses(null); this.featureMap = new HashMap<String, Double>(); this.sourceDocument = null; this.sourceArticleName = ""; this.tree = tree; this.props = props; this.populateFeatureNames(props); }
From source file:edu.cmu.ark.nlp.question.Question.java
License:Open Source License
public Question(Properties props, Map<String, Double> features) { this.tree = null; this.hf = new CollinsHeadFinder(); this.setIntermediateTreeSupersenses(null); this.featureMap = new HashMap<String, Double>(); this.featureMap.putAll(features); this.sourceDocument = null; this.sourceArticleName = ""; this.props = props; this.populateFeatureNames(props); }
From source file:edu.cmu.ark.nlp.question.Question.java
License:Open Source License
public Question(Properties props, Tree tree, Map<String, Double> features) { this.tree = tree; this.hf = new CollinsHeadFinder(); this.setIntermediateTreeSupersenses(null); this.featureMap = new HashMap<String, Double>(); this.featureMap.putAll(features); this.sourceDocument = null; this.sourceArticleName = ""; this.props = props; this.populateFeatureNames(props); }
From source file:edu.cmu.ark.nlp.question.Question.java
License:Open Source License
public Question(Properties props, Tree tree, Tree intermediateTree, Tree sourceTree, Map<String, Double> features) { this.intermediateTree = intermediateTree; this.sourceTree = sourceTree; this.tree = tree; this.hf = new CollinsHeadFinder(); this.setIntermediateTreeSupersenses(null); this.featureMap = new HashMap<String, Double>(); this.featureMap.putAll(features); this.sourceDocument = null; this.sourceArticleName = ""; this.populateFeatureNames(props); }
From source file:edu.cmu.ark.nlp.sent.SentenceSimplifier.java
License:Open Source License
public SentenceSimplifier(Properties props) { factory = new LabeledScoredTreeFactory(); this.hf = new CollinsHeadFinder(); String computefeatures = props.getProperty("getComputeFeatures", "true"); if (computefeatures.equals("true")) this.getComputeFeatures = true; else//from w w w . java 2 s .c om this.getComputeFeatures = false; this.props = props; conjugator = new VerbConjugator(props); }
From source file:elkfed.mmax.pipeline.SemTagger.java
License:Apache License
/** Creates a new instance of SemTagger */ public SemTagger() { super();/*from ww w. java 2s .c o m*/ this.semroles = new ArrayList<Markable>(); this.markables = new ArrayList<Markable>(); this.headFinder = new CollinsHeadFinder(); this.parseTrees = new ArrayList<Tree>(); this.parseStart = new ArrayList<Integer>(); this.parseEnd = new ArrayList<Integer>(); }