All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.stanford.nlp.trees.tregex.tsurgeon.TsurgeonMatcher Maven / Gradle / Ivy

Go to download

Stanford CoreNLP provides a set of natural language analysis tools which can take raw English language text input and give the base forms of words, their parts of speech, whether they are names of companies, people, etc., normalize dates, times, and numeric quantities, mark up the structure of sentences in terms of phrases and word dependencies, and indicate which noun phrases refer to the same entities. It provides the foundational building blocks for higher level text understanding applications.

There is a newer version: 4.5.7
Show newest version
package edu.stanford.nlp.trees.tregex.tsurgeon;

import java.util.Map;

import edu.stanford.nlp.trees.Tree;
import edu.stanford.nlp.trees.tregex.TregexMatcher;

/**
 * An object factored out to keep the state of a Tsurgeon
 * operation separate from the TsurgeonPattern objects.
 * This makes it easier to reset state between invocations and makes
 * it easier to use in a threadsafe manner.
 * 
* TODO: it would be nice to go through all the patterns and make sure * they update newNodeNames or look for appropriate nodes * in newNodeNames when possible. *
* It would also be nicer if the call to matcher() took * the tree & tregex instead of evaluate(), but that * is a little more complicated because of the way the * TsurgeonMatcher is used in Tsurgeon. * Basically, you would need to move that code from * Tsurgeon to TsurgeonMatcher. * * @author John Bauer */ public abstract class TsurgeonMatcher { Map newNodeNames; CoindexationGenerator coindexer; TsurgeonMatcher[] childMatcher; // TODO: ideally we should have the tree and the tregex matcher be // part of this as well. That would involve putting some of the // functionality in Tsurgeon.java in this object public TsurgeonMatcher(TsurgeonPattern pattern, Map newNodeNames, CoindexationGenerator coindexer) { this.newNodeNames = newNodeNames; this.coindexer = coindexer; this.childMatcher = new TsurgeonMatcher[pattern.children.length]; for (int i = 0; i < pattern.children.length; ++i) { this.childMatcher[i] = pattern.children[i].matcher(newNodeNames, coindexer); } } /** * Evaluates the surgery pattern against a {@link Tree} and a {@link TregexMatcher} * that has been successfully matched against the tree. * * @param tree The {@link Tree} that has been matched upon; typically this tree will be destructively modified. * @param tregex The successfully matched {@link TregexMatcher}. * @return Some node in the tree; depends on implementation and use of the specific subclass. */ public abstract Tree evaluate(Tree tree, TregexMatcher tregex); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy