public class OpenSchemaPlanner extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
OpenSchemaPlanner.Cache
Values cache.
|
protected static class |
OpenSchemaPlanner.DecoratedNode
A decorated node inner class.
|
protected class |
OpenSchemaPlanner.Node
Node inner class.
|
protected class |
OpenSchemaPlanner.Predicate
Predicate inner class
|
Modifier and Type | Field and Description |
---|---|
protected static int |
AGGRBOUNDARY_NODE
Aggregation boundary node.
|
protected LocalChooser |
chooser
LocalChooser, decides which node to continue the instantiation of the schema.
|
protected static Frame |
EMPTY_FOCUS |
protected static int |
EMPTY_NODE
Empty node, only used for structural purposes.
|
protected static int |
PARBOUNDARY_NODE
Paragraph boundary node.
|
protected static int |
PREDICATE_NODE
Predicate node, contains a predicate reference plus global-to-local mapping.
|
protected Map<String,OpenSchemaPlanner.Predicate> |
predicates
Definition of the rhetorical predicates.
|
protected OpenSchemaPlanner.Node |
top
Top-level node of the schema, here is where the instantiation starts.
|
static boolean |
verbose
Verbosity flag, defaults to off.
|
Constructor and Description |
---|
OpenSchemaPlanner(InputSource source,
LocalChooser chooser)
Constructor from an SAX InputSource.
|
Modifier and Type | Method and Description |
---|---|
protected Map<String,Object> |
assembleFD(List<AttributeValuePair> vs,
Set<String> vars)
Create a functional description from the JAXB code.
|
protected void |
assembleSchema(OpenSchema schema)
Construct the nodes network from a JAXB generated schema class.
|
protected void |
build(OpenSchemaPlanner.Node inNode,
OpenSchemaPlanner.Node outNode,
List<SchemaNode.Node> schemaNodes,
boolean isChoice)
Construct the network for a given construction in the schema language.
|
protected boolean |
canBeInstantiated(OpenSchemaPlanner.Node node,
Map<String,Frame> varMapping,
OpenSchemaPlanner.Cache cache,
Ontology ontology,
FrameSet frames)
Check whether there is valid data to instantiate a node or not, given an initial variable mapping.
|
protected List<OpenSchemaPlanner.DecoratedNode> |
computeConfusionSet(OpenSchemaPlanner.Node node,
Map<String,Frame> varMapping,
OpenSchemaPlanner.Cache cache,
Ontology ontology,
FrameSet frames)
Compute all the nodes that are reachable from current node without passing through another Predicate node.
|
String |
dump()
Show the network (for debugging purposes)
|
String |
dump(boolean asDot)
Show the network (for debugging purposes)
|
protected void |
dump(StringBuilder dump,
OpenSchemaPlanner.Node current,
Set<OpenSchemaPlanner.Node> seen,
boolean asDot)
Recursive method for dump.
|
protected static List<Frame> |
framesUnderType(Object type,
Ontology ontology,
FrameSet frames)
Retrieve all the frames in a FrameSet which type is a subtype of a given type.
|
DocumentPlan |
instantiate(FrameSet frames,
Map<String,Frame> initialMapping,
Ontology ontology)
Main method, takes data to instantiate the schema, an initial variable mapping and an ontology and returns a
DocumentPlan.
|
protected Map<String,Object> |
instantiateClause(Map<String,Object> fd,
Map<Object,Frame> valueMapping)
Instantiate a given FD by changing all the variable references via a provided variable mapping.
|
protected Map<String,Object> |
instantiatePredicate(OpenSchemaPlanner.Node node,
Map<String,Frame> varMapping,
OpenSchemaPlanner.Cache cache,
boolean commit)
Instantiate a predicate by fetching the values from the cache and resolving variables in the output FD of the
predicate.
|
protected List<Map<Object,Frame>> |
searchValues(OpenSchemaPlanner.Node node,
Map<String,Frame> varMapping,
Ontology ontology,
FrameSet frames)
Search for values that satisfy the node properties and the given mapping of variables.
|
public static boolean verbose
protected OpenSchemaPlanner.Node top
protected Map<String,OpenSchemaPlanner.Predicate> predicates
protected LocalChooser chooser
protected static Frame EMPTY_FOCUS
protected static final int EMPTY_NODE
protected static final int PREDICATE_NODE
protected static final int AGGRBOUNDARY_NODE
protected static final int PARBOUNDARY_NODE
public OpenSchemaPlanner(InputSource source, LocalChooser chooser) throws JAXBException
source
- A SAX InputSource, can read from a Reader or an InputStream.chooser
- An instance of the abstract class LocalChooser, it should select among the different
continuation nodes during instantiation.JAXBException
public DocumentPlan instantiate(FrameSet frames, Map<String,Frame> initialMapping, Ontology ontology)
frames
- a class implementing the FrameSet interface, for example RDFFrameSet containing the
data to fill the schema.initialMapping
- a mapping from variable names to values (Frames).ontology
- a class implementing the Ontology interface, for example RDFOntology.protected List<OpenSchemaPlanner.DecoratedNode> computeConfusionSet(OpenSchemaPlanner.Node node, Map<String,Frame> varMapping, OpenSchemaPlanner.Cache cache, Ontology ontology, FrameSet frames)
node
- the current node to start the spanning tree.varMapping
- the current variable-values mapping.cache
- the current values cache.ontology
- used to update the cache.frames
- used to update the cache.protected boolean canBeInstantiated(OpenSchemaPlanner.Node node, Map<String,Frame> varMapping, OpenSchemaPlanner.Cache cache, Ontology ontology, FrameSet frames)
node
- the current node, to analyze the predicate and global-to-local variable mapping.varMapping
- the global variables.cache
- the cache to be queried/populated.ontology
- used to populate the cache.frames
- used to populate the cache.protected List<Map<Object,Frame>> searchValues(OpenSchemaPlanner.Node node, Map<String,Frame> varMapping, Ontology ontology, FrameSet frames)
node
- the schema node, containing the properties that the values should satisfy and the mapping between
local and global variables.varMapping
- global variables, mapping from name to value.ontology
- the ontology, employed to restrict the search over values of a certain type.frames
- the set of frames over where to perform the search.{edu.columbia.openschema.OpenSchema.Node.Property}
protected static List<Frame> framesUnderType(Object type, Ontology ontology, FrameSet frames)
type
- the parent type.ontology
- the ontology where to check for the relations.frames
- the frameset to look for the data.protected Map<String,Object> instantiatePredicate(OpenSchemaPlanner.Node node, Map<String,Frame> varMapping, OpenSchemaPlanner.Cache cache, boolean commit)
node
- the node being instantiated.varMapping
- the global variables.commit
- whether or not to remove the values from the cache.protected Map<String,Object> instantiateClause(Map<String,Object> fd, Map<Object,Frame> valueMapping)
fd
- the functional description to operate on.valueMapping
- variable-to-value mapping.protected void assembleSchema(OpenSchema schema)
schema
- the JAXB class, used to deal with the XML.protected Map<String,Object> assembleFD(List<AttributeValuePair> vs, Set<String> vars)
vs
- the JAXB instances being processed.vars
- predicate variables, to replace the variable references.protected void build(OpenSchemaPlanner.Node inNode, OpenSchemaPlanner.Node outNode, List<SchemaNode.Node> schemaNodes, boolean isChoice)
inNode
- the input to this subnetwork.outNode
- the output of the subnetwork.schemaNodes
- the JAXB instances for this construction.isChoice
- whether to link each node one after the other or all from inNode to outNode.public String dump()
public String dump(boolean asDot)
protected void dump(StringBuilder dump, OpenSchemaPlanner.Node current, Set<OpenSchemaPlanner.Node> seen, boolean asDot)
Copyright © 2015 Pablo Duboue. All rights reserved.