edu.stanford.nlp.sequences.FactoredSequenceListener Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stanford-corenlp Show documentation
Show all versions of stanford-corenlp Show documentation
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.
package edu.stanford.nlp.sequences;
/**
* @author grenager
* Date: Apr 18, 2005
*/
public class FactoredSequenceListener implements SequenceListener {
SequenceListener model1;
SequenceListener model2;
SequenceListener[] models = null;
/**
* Informs this sequence model that the value of the element at position pos has changed.
* This allows this sequence model to update its internal model if desired.
*
*/
public void updateSequenceElement(int[] sequence, int pos, int oldVal) {
if(models != null){
for (SequenceListener model : models) model.updateSequenceElement(sequence, pos, oldVal);
return;
}
model1.updateSequenceElement(sequence, pos, oldVal);
model2.updateSequenceElement(sequence, pos, oldVal);
}
/**
* Informs this sequence model that the value of the whole sequence is initialized to sequence
*
*/
public void setInitialSequence(int[] sequence) {
if(models != null){
for (SequenceListener model : models) model.setInitialSequence(sequence);
return;
}
model1.setInitialSequence(sequence);
model2.setInitialSequence(sequence);
}
public FactoredSequenceListener(SequenceListener model1, SequenceListener model2) {
this.model1 = model1;
this.model2 = model2;
}
public FactoredSequenceListener(SequenceListener[] models){
this.models = models;
}
}