public abstract class FeatureFunction<State,V> extends Object
evaluate(de.up.ling.irtg.automata.Rule, de.up.ling.irtg.automata.TreeAutomaton, de.up.ling.irtg.maxent.MaximumEntropyIrtg, java.util.Map)
method on each rule of a TreeAutomaton
with state set
State. The evaluate method can additionally see the Rule
itself, the MaximumEntropyIrtg
from which the rule
originally came, and the inputs that are being parsed.
For instance, in a log-linear model for a context-free grammar,
you will have a MaximumEntropyIrtg with a single interpretation
into the StringAlgebra
. Therefore the states of the chart
will be pairs of String (= nonterminal from the grammar) and
StringAlgebra.Span
(indicating a span in the input string).
A feature function will be passed the rule in the chart; the chart
itself; the IRTG grammar; and a map that maps the interpretation name
to the string that is currently being parsed. A feature that responds
to the first and last words in the span can look these up in the string.
Concrete implementations of FeatureFunction must implement
the evaluate(de.up.ling.irtg.automata.Rule, de.up.ling.irtg.automata.TreeAutomaton, de.up.ling.irtg.maxent.MaximumEntropyIrtg, java.util.Map)
method. Note that feature values can come from any class V,
but the standard methods for training and parsing in
MaximumEntropyIrtg
only support V = Double
.
Constructor and Description |
---|
FeatureFunction() |
Modifier and Type | Method and Description |
---|---|
abstract V |
evaluate(Rule rule,
TreeAutomaton<State> automaton,
MaximumEntropyIrtg irtg,
Map<String,Object> inputs)
Computes the value of the feature function for a given rule.
|
String |
toString() |
public abstract V evaluate(Rule rule, TreeAutomaton<State> automaton, MaximumEntropyIrtg irtg, Map<String,Object> inputs)
rule
- a rule in "automaton"automaton
- the tree automaton to which "rule" belongs, typically a parse chartirtg
- the maxent IRTG which defined the grammar rule on which "rule" is basedinputs
- the inputs that are currently being parsedCopyright © 2017. All rights reserved.