com.sun.labs.minion.lextax
Class ConceptEntry

java.lang.Object
  extended by com.sun.labs.minion.lextax.ConceptEntry
All Implemented Interfaces:
Entry, IndexEntry, QueryEntry, java.lang.Comparable

public class ConceptEntry
extends java.lang.Object
implements IndexEntry, QueryEntry

A dictionary entry that holds a concept in a taxonomy. This kind of entry does not have any associated postings. Rather, the information about the taxonomic structure is encoded directly into the entries in the dictionary.


Field Summary
protected  Dictionary dict
          The dictionary containing this concept.
protected  int id
          The ID of the concept.
protected  java.util.Set[] links
          Links from this concept to other concepts.
protected  java.lang.String name
          The name of the concept.
 
Constructor Summary
ConceptEntry()
          Creates a new instance of ConceptEntry
ConceptEntry(java.lang.Object name)
           
 
Method Summary
 int add(int linkType, ConceptEntry c)
          Adds a link to this concept.
 void add(Occurrence o)
          Adds an occurrence to this index entry.
 void append(QueryEntry qe, int start, int[] idMap)
          Appends the postings from another entry onto this one.
 int compareTo(java.lang.Object o)
           
 void decodePostingsInfo(ReadableBuffer b, int pos)
          Decode a ConceptEntry from the buffer.
 void encodePostingsInfo(WriteableBuffer b)
          Encodes any information associated with the postings onto the given buffer.
 boolean equals(java.lang.Object conceptEntry)
           
 java.util.Set getAbbrevChildren()
           
 java.util.Set getAbbrevParents()
           
 java.util.Set getChildren()
          Gets morph and instanceof and kindof children.
 java.util.Set[][] getChildrenLinkSet()
          Gets links in Children direction
 java.util.Set getEntailsChildren()
          Gets entailment children.
 java.util.Set getEntailsParents()
          Gets Entails parents.
 Entry getEntry()
          Gets a new entry that contains a copy of the data in this entry.
 Entry getEntry(java.lang.Object name)
          Gets a new entry with the given name.
 int getID()
          Gets the ID associated with this entry.
 java.util.Set getIkoChildren()
          Gets kind-of children.
 java.util.Set getIkoParents()
          Gets all varieties of kind-of(iko) parents.
 java.util.Set getInstanceOfChildren()
          instance-of children.
 java.util.Set getInstanceOfParents()
          Gets instance-of parents.
protected  java.util.Set getLinks(int linkType)
          Gets links of a given type.
protected  java.util.Set[][] getLinkSet(int linkSet)
          Gets the set of links of a given type.
 int getMaxFDT()
          Gets the maximum document term frequency from this entry.
 java.util.Set getMisspellingChildren()
           
 java.util.Set getMisspellingParents()
           
 java.util.Set getMorphChildren()
          Gets morphological children.
 java.util.Set getMorphParents()
          Gets morphological parents.
 int getN()
          Gets the number of postings associated with this entry.
 java.lang.Object getName()
          Gets the name of this entry, which can be any object.
 java.util.Set getNicknameChildren()
           
 java.util.Set getNicknameParents()
           
 int getNumChannels()
          Returns the number of channels needed to store or retrieve the postings for this entry type.
 java.util.Set[][] getParentLinkSet()
          Gets links in Parent direction
 java.util.Set getParents()
          Gets morph, kindof, senseof, and instanceof parents.
 Partition getPartition()
          Gets the partition that this entry was drawn from.
 java.util.Set getSenseChildren()
          Gets subsenses of this concept (sense children).
 java.util.Set getSenseParents()
          Gets sense-of parents.
 long getTotalOccurrences()
          Gets the total number of occurrences associated with this entry.
 java.util.Set getVariantOfChildren()
          variant-of children.
 java.util.Set getVariantOfParents()
          Gets variant-of parents.
 boolean hasFieldInformation()
          Indicates whether the postings associated with this entry have field information.
 int hashCode()
           
 boolean hasPositionInformation()
          Indicates whether the postings associated with this entry have position information.
 PostingsIterator iterator(PostingsIteratorFeatures features)
          Gets an iterator that will iterate through the postings associated with this entry.
 void readPostings()
          We don't have any postings!
 void setDictionary(Dictionary dict)
          Sets the dictionary that this entry was drawn from.
 void setID(int id)
          Sets the ID associated with this entry.
 void setName(java.lang.Object name)
          Sets the name of this entry.
 void setPostingsInput(PostingsInput[] postIn)
          Sets the inputs that will be used to read postings for this entry.
 java.lang.String toString()
           
 boolean writePostings(PostingsOutput[] out, int[] idMap)
          Writes the postings associated with this entry to some or all of the given channels.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
The name of the concept.


id

protected int id
The ID of the concept.


dict

protected Dictionary dict
The dictionary containing this concept.


links

protected java.util.Set[] links
Links from this concept to other concepts.

Constructor Detail

ConceptEntry

public ConceptEntry()
Creates a new instance of ConceptEntry


ConceptEntry

public ConceptEntry(java.lang.Object name)
Method Detail

setName

public void setName(java.lang.Object name)
Description copied from interface: IndexEntry
Sets the name of this entry.

Specified by:
setName in interface Entry
Specified by:
setName in interface IndexEntry
Parameters:
name - The name that we wish the entry to have.

setID

public void setID(int id)
Description copied from interface: IndexEntry
Sets the ID associated with this entry.

Specified by:
setID in interface Entry
Specified by:
setID in interface IndexEntry
Parameters:
id - The id to use for this entry.

add

public void add(Occurrence o)
Description copied from interface: IndexEntry
Adds an occurrence to this index entry.

Specified by:
add in interface IndexEntry
Parameters:
o - The occurrence to add.

writePostings

public boolean writePostings(PostingsOutput[] out,
                             int[] idMap)
                      throws java.io.IOException
Description copied from interface: IndexEntry
Writes the postings associated with this entry to some or all of the given channels.

Specified by:
writePostings in interface IndexEntry
Parameters:
out - The outputs to which we will write the postings.
idMap - A map from the IDs currently used in the postings to the IDs that should be used when the postings are written to disk. This may be null, in which case no remapping will occur.
Returns:
true if postings were written, false otherwise
Throws:
java.io.IOException - if there is any error writing the postings.

append

public void append(QueryEntry qe,
                   int start,
                   int[] idMap)
Description copied from interface: IndexEntry
Appends the postings from another entry onto this one. This is used when merging dictionaries.

Specified by:
append in interface IndexEntry
Parameters:
qe - The entry that we want to append onto this one.
start - The new starting ID for the partition that the entry was drawn from.
idMap - A map from old IDs in the given postings to new IDs with gaps removed for deleted data. If this is null, then there are no deleted documents.

encodePostingsInfo

public void encodePostingsInfo(WriteableBuffer b)
Description copied from interface: IndexEntry
Encodes any information associated with the postings onto the given buffer.

Specified by:
encodePostingsInfo in interface IndexEntry
Parameters:
b - The buffer onto which the postings information should be encoded. The buffer will be positioned to the correct spot for the encoding.

getEntry

public Entry getEntry(java.lang.Object name)
Description copied from interface: Entry
Gets a new entry with the given name.

Specified by:
getEntry in interface Entry
Parameters:
name - the name that we want to give the entry.
Returns:
a new entry.

getEntry

public Entry getEntry()
Description copied from interface: Entry
Gets a new entry that contains a copy of the data in this entry.

Specified by:
getEntry in interface Entry
Returns:
a new entry.

getName

public java.lang.Object getName()
Description copied from interface: Entry
Gets the name of this entry, which can be any object.

Specified by:
getName in interface Entry

getID

public int getID()
Description copied from interface: Entry
Gets the ID associated with this entry.

Specified by:
getID in interface Entry

getN

public int getN()
Description copied from interface: Entry
Gets the number of postings associated with this entry. This can be used to sort entries by their frequency during query operations.

Specified by:
getN in interface Entry
Returns:
The number of postings associated with this entry.

getTotalOccurrences

public long getTotalOccurrences()
Description copied from interface: Entry
Gets the total number of occurrences associated with this entry. This is useful when a single postings entry may comprise multiple occurrences.

At the moment, this is only really useful for entries from the main dictionary for a partition.

Specified by:
getTotalOccurrences in interface Entry
Returns:
The total number of occurrences associated with this entry.

getMaxFDT

public int getMaxFDT()
Description copied from interface: Entry
Gets the maximum document term frequency from this entry. For all IDs asssociated with this entry, this is the maximum frequency across all the IDs.

Specified by:
getMaxFDT in interface Entry

setDictionary

public void setDictionary(Dictionary dict)
Description copied from interface: Entry
Sets the dictionary that this entry was drawn from.

Specified by:
setDictionary in interface Entry

getPartition

public Partition getPartition()
Description copied from interface: Entry
Gets the partition that this entry was drawn from.

Specified by:
getPartition in interface Entry

getNumChannels

public int getNumChannels()
Description copied from interface: Entry
Returns the number of channels needed to store or retrieve the postings for this entry type.

Specified by:
getNumChannels in interface Entry

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

setPostingsInput

public void setPostingsInput(PostingsInput[] postIn)
Description copied from interface: QueryEntry
Sets the inputs that will be used to read postings for this entry. This allows us to use different input implementation strategies at different times.

Specified by:
setPostingsInput in interface QueryEntry
Parameters:
postIn - The channels from which the postings data can be read.

decodePostingsInfo

public void decodePostingsInfo(ReadableBuffer b,
                               int pos)
Decode a ConceptEntry from the buffer. The links of the concept entry do not point to other concepts but rather to their IDs (represented as Integers). The links are fixed up by DiskTaxonomy

Specified by:
decodePostingsInfo in interface QueryEntry
Parameters:
b - The buffer containing the encoded postings information.
pos - The position in b where the postings information can be found.
See Also:
QueryEntry.decodePostingsInfo(com.sun.labs.minion.util.buffer.ReadableBuffer, int), DiskTaxonomy.merge(DiskTaxonomy[], String, File)

readPostings

public void readPostings()
                  throws java.io.IOException
We don't have any postings!

Specified by:
readPostings in interface QueryEntry
Throws:
java.io.IOException - if there is any error reading the postings.

hasPositionInformation

public boolean hasPositionInformation()
Description copied from interface: QueryEntry
Indicates whether the postings associated with this entry have position information.

Specified by:
hasPositionInformation in interface QueryEntry

hasFieldInformation

public boolean hasFieldInformation()
Description copied from interface: QueryEntry
Indicates whether the postings associated with this entry have field information.

Specified by:
hasFieldInformation in interface QueryEntry

iterator

public PostingsIterator iterator(PostingsIteratorFeatures features)
Description copied from interface: QueryEntry
Gets an iterator that will iterate through the postings associated with this entry.

Specified by:
iterator in interface QueryEntry
Parameters:
features - A set of features that the iterator must support.
Returns:
An iterator for the postings.

add

public int add(int linkType,
               ConceptEntry c)
Adds a link to this concept.

Parameters:
linkType - The type of link to add.
c - The concept that the link is to.
Returns:
the number of bits added to the representation

getVariantOfParents

public java.util.Set getVariantOfParents()
Gets variant-of parents.


getVariantOfChildren

public java.util.Set getVariantOfChildren()
variant-of children.


getSenseParents

public java.util.Set getSenseParents()
Gets sense-of parents.


getSenseChildren

public java.util.Set getSenseChildren()
Gets subsenses of this concept (sense children).


getParents

public java.util.Set getParents()
Gets morph, kindof, senseof, and instanceof parents.


getNicknameParents

public java.util.Set getNicknameParents()

getNicknameChildren

public java.util.Set getNicknameChildren()

getMorphParents

public java.util.Set getMorphParents()
Gets morphological parents.


getMorphChildren

public java.util.Set getMorphChildren()
Gets morphological children.


getMisspellingParents

public java.util.Set getMisspellingParents()

getMisspellingChildren

public java.util.Set getMisspellingChildren()

getLinks

protected java.util.Set getLinks(int linkType)
Gets links of a given type.


getInstanceOfParents

public java.util.Set getInstanceOfParents()
Gets instance-of parents.


getInstanceOfChildren

public java.util.Set getInstanceOfChildren()
instance-of children.


getIkoParents

public java.util.Set getIkoParents()
Gets all varieties of kind-of(iko) parents.


getIkoChildren

public java.util.Set getIkoChildren()
Gets kind-of children.


getEntailsParents

public java.util.Set getEntailsParents()
Gets Entails parents.


getEntailsChildren

public java.util.Set getEntailsChildren()
Gets entailment children.


getChildren

public java.util.Set getChildren()
Gets morph and instanceof and kindof children.


getAbbrevParents

public java.util.Set getAbbrevParents()

getAbbrevChildren

public java.util.Set getAbbrevChildren()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getParentLinkSet

public java.util.Set[][] getParentLinkSet()
Gets links in Parent direction


getLinkSet

protected java.util.Set[][] getLinkSet(int linkSet)
Gets the set of links of a given type. linkSet is 0 or 1. Some of the extra tests are to deal with link sets of varying size


getChildrenLinkSet

public java.util.Set[][] getChildrenLinkSet()
Gets links in Children direction


hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object conceptEntry)
Overrides:
equals in class java.lang.Object