public class TemplateInterpretedTreeAutomaton extends Object
foreach
keyword, like so:
foreach { x,y | left-of(x,y) and target(x) and distractor(y)}: NP_$x -> leftof_$x(N_$x, NP_$y) [sem] project_1(intersect_2(intersect_1(left-of, ?1), ?2)) [string] *(?1, *("left of", ?2))A template IRTG can be instantiated to an ordinary IRTG based on the contents of a
FirstOrderModel
using the
instantiate(de.up.ling.irtg.util.FirstOrderModel)
method.
This will enumerate all values (a,b) for the variables (x,y)
that satisfy all the conditions in the foreach clause,
and will replace the occurrences of $x and $y in the IRTG
rule by a and b respectively.
Template IRTGs are only rarely constructed programmatically.
The common use-case is to read a template IRTG from a file
using TemplateIrtgInputCodec
. Most methods in this
class are meant to be called from that input codec.
Modifier and Type | Class and Description |
---|---|
static class |
TemplateInterpretedTreeAutomaton.AtomicGuard |
static class |
TemplateInterpretedTreeAutomaton.ConjGuard |
static interface |
TemplateInterpretedTreeAutomaton.Guard |
static class |
TemplateInterpretedTreeAutomaton.TemplateRule
This class represents a template for a rule, from which multiple concrete
rules can be instantiated.
|
static class |
TemplateInterpretedTreeAutomaton.TopGuard |
Constructor and Description |
---|
TemplateInterpretedTreeAutomaton()
Constructs an empty template IRTG.
|
Modifier and Type | Method and Description |
---|---|
void |
addAlgebraClass(String interpretation,
String className)
Declares an interpretation.
|
void |
addConstructorFeatureDeclaration(String id,
String featureClass,
List<String> arguments)
Adds a declaration of a constructure feature to the
template IRTG.
|
void |
addRuleTemplate(TemplateInterpretedTreeAutomaton.TemplateRule trule)
Adds a rule template to the template IRTG.
|
void |
addStaticFeatureDeclaration(String id,
String featureClass,
String featureMethod,
List<String> arguments)
Adds a declaration of a static-method feature to
the template IRTG.
|
Map<String,String> |
getAlgebraClasses()
Returns a string to string map of algebra classes.
|
List<String> |
getFeatureIds()
Returns a list of ids of the feature declarations this IRTG contains.
|
double |
getFeatureWeight(int i)
Returns an specific entry for the feature weights.
|
double[] |
getFeatureWeights()
Returns a double array which contains the current settings of the feature
weights.
|
int |
getNumFeatures()
Returns the number of feature declarations this IRTG contains.
|
InterpretedTreeAutomaton |
instantiate(FirstOrderModel model)
Instantiates this template IRTG into a concrete IRTG.
|
void |
setFeatureWeight(int index,
double weight)
Allows for setting a single entry for the feature weights.
|
void |
setFeatureWeights(double[] featureWeights)
Allows for the feature weights to be set externally.
|
String |
toString() |
public TemplateInterpretedTreeAutomaton()
public void addRuleTemplate(TemplateInterpretedTreeAutomaton.TemplateRule trule)
trule
- public void addConstructorFeatureDeclaration(String id, String featureClass, List<String> arguments)
id
- featureClass
- arguments
- public void addStaticFeatureDeclaration(String id, String featureClass, String featureMethod, List<String> arguments)
id
- featureClass
- featureMethod
- arguments
- public void addAlgebraClass(String interpretation, String className)
interpretation
- className
- public InterpretedTreeAutomaton instantiate(FirstOrderModel model) throws ClassNotFoundException, InstantiationException, IllegalAccessException, CodecParseException
model
- ClassNotFoundException
InstantiationException
IllegalAccessException
CodecParseException
public int getNumFeatures()
public List<String> getFeatureIds()
public Map<String,String> getAlgebraClasses()
public double[] getFeatureWeights()
public void setFeatureWeights(double[] featureWeights)
featureWeights
- the featureWeights to setpublic double getFeatureWeight(int i)
i
- public void setFeatureWeight(int index, double weight)
index
- weight
- Copyright © 2017. All rights reserved.