jInfer

cz.cuni.mff.ksi.jinfer.iss.objects
Class AMModel

java.lang.Object
  extended by cz.cuni.mff.ksi.jinfer.iss.objects.AMModel

public class AMModel
extends Object

Class representing a model for attribute mappings operations. It is constructed from a specified grammar and provides various views of the mappings in that grammar, notably:

Most of these methods cache their results (the input grammar cannot change later anyway) and return them lazily. Be aware though that the lazy implementations are not thread-safe!


Constructor Summary
AMModel(List<Element> grammar)
          Full constructor.
 
Method Summary
 double coverage(AttributeMappingId targetMapping)
          Please see the "Finding ID Attributes in XML Documents" article for the definition of this function.
 Map<AttributeMappingId,AttributeMapping> getAMs()
          Returns all attribute mappings in the underlying grammar as a map indexed by their IDs (AttributeMappingId) containing the full mappings (AttributeMapping).
 List<Triplet> getFlat()
          Extracts the attribute mapping from the underlying grammar as a flat list of Triplets (element name, attribute name, attribute content).
 TreeNode getTree()
          Extracts the attribute mapping from the underlying grammar as a tree ready to be used in a JTree.
 Set<String> getTypes()
          Returns all the element types represented in this model.
 int size()
          Returns the total size of all attribute mappings represented in this model.
 double support(AttributeMappingId targetMapping)
          Please see the "Finding ID Attributes in XML Documents" article for the definition of this function.
 double weight(AttributeMappingId mapping, double alpha, double beta)
          Returns the weight of the provided AM in the context of this AM model as a weighted sum of its support and coverage.
 double weight(Collection<AttributeMappingId> mappings, double alpha, double beta)
          Returns the sum of weights of all the mappings provided in the context this AM model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AMModel

public AMModel(List<Element> grammar)
Full constructor.

Parameters:
grammar - Grammar from which the model should be created.
Method Detail

getFlat

public List<Triplet> getFlat()
Extracts the attribute mapping from the underlying grammar as a flat list of Triplets (element name, attribute name, attribute content).

Note that the original content of the attribute is split into tokens on spaces. For example an element e with attribute a that contains the string "1 p p" in the original document will produce 3 Triplets, containing the attribute content 1, p and p respectively.

Returns:
Flat representation of the attribute mapping contained in the underlying grammar. Resulting list of Triplets is sorted (see Triplet.compareTo(Triplet)).

getTree

public TreeNode getTree()
Extracts the attribute mapping from the underlying grammar as a tree ready to be used in a JTree.

Please note that the attribute content is split into tokens on spaces, see MappingUtils#extractFlat for details.

Returns:
Tree representation of the attribute mapping contained in the underlying grammar. Under the root node there are nodes representing each Element in the grammar. The element nodes then contain nodes for each of the Attributes they contain.

getAMs

public Map<AttributeMappingId,AttributeMapping> getAMs()
Returns all attribute mappings in the underlying grammar as a map indexed by their IDs (AttributeMappingId) containing the full mappings (AttributeMapping).

Returns:
Map of all the attribute mappings.

size

public int size()
Returns the total size of all attribute mappings represented in this model.

Returns:
Size of all the attribute mappings in this model. It is the sum of sizes of all the mappings represented.

getTypes

public Set<String> getTypes()
Returns all the element types represented in this model.

Returns:
Set of all element types (names) in this model.

weight

public double weight(AttributeMappingId mapping,
                     double alpha,
                     double beta)
Returns the weight of the provided AM in the context of this AM model as a weighted sum of its support and coverage.

Parameters:
mapping - Mapping to compute weight for.
alpha - Weight of the mapping support.
beta - Weight of the mapping coverage.
Returns:
Weight of the provided mapping in the context this model.
See Also:
MappingUtils#support(AttributeMappingId, AMModel), MappingUtils#coverage(AttributeMappingId, AMModel)

weight

public double weight(Collection<AttributeMappingId> mappings,
                     double alpha,
                     double beta)
Returns the sum of weights of all the mappings provided in the context this AM model.

Parameters:
mappings - List of the mappings to calculate the weight for.
alpha - Weight of the mapping support.
beta - Weight of the mapping coverage.
Returns:
Sum of all the weights of all the provided mappings.
See Also:
MappingUtils#weight(AttributeMappingId, AMModel)

support

public double support(AttributeMappingId targetMapping)
Please see the "Finding ID Attributes in XML Documents" article for the definition of this function.

Parameters:
targetMapping - Mapping for which support should be calculated.
Returns:
Support of the specified mapping.

coverage

public double coverage(AttributeMappingId targetMapping)
Please see the "Finding ID Attributes in XML Documents" article for the definition of this function.

Parameters:
targetMapping - Mapping for which coverage should be calculated.
Returns:
Coverage of the specified mapping.

jInfer

Generated on Fri Dec 9 00:01:25 CET 2011