edu.mit.jmwe.data
Class RootMWEDesc

java.lang.Object
  extended by edu.mit.jmwe.data.AbstractMWEDesc<IRootMWEDesc.IRootPart>
      extended by edu.mit.jmwe.data.RootMWEDesc
All Implemented Interfaces:
IHasForm, IHasMWEPOS, IMWEDesc, IRootMWEDesc, Comparable<IMWEDesc>
Direct Known Subclasses:
IndexBuilder.MutableRootMWEDesc

public class RootMWEDesc
extends AbstractMWEDesc<IRootMWEDesc.IRootPart>
implements IRootMWEDesc

Default implementation of the IRootMWEDesc interface.

Since:
jMWE 1.0.0
Version:
$Id: RootMWEDesc.java 620 2011-05-08 21:13:58Z markaf $
Author:
Nidhi Kulkarni, M.A. Finlayson

Nested Class Summary
protected  class RootMWEDesc.Part
          Default implementation of IRootMWEDesc.IRootPart.
 
Nested classes/interfaces inherited from class edu.mit.jmwe.data.AbstractMWEDesc
AbstractMWEDesc.AbstractPart
 
Nested classes/interfaces inherited from interface edu.mit.jmwe.data.IRootMWEDesc
IRootMWEDesc.IRootPart
 
Nested classes/interfaces inherited from interface edu.mit.jmwe.data.IMWEDesc
IMWEDesc.IPart
 
Field Summary
 
Fields inherited from class edu.mit.jmwe.data.AbstractMWEDesc
counts
 
Fields inherited from interface edu.mit.jmwe.data.IRootMWEDesc
EXPECTED_COUNT_LENGTH
 
Fields inherited from interface edu.mit.jmwe.data.IMWEDesc
boundaryUnderscores, comma, underscore, underscores
 
Constructor Summary
RootMWEDesc(List<String> parts, MWEPOS pos)
          Constructs a new MWE description object from the specified list of parts and part of speech, that has no inflected forms
RootMWEDesc(List<String> parts, MWEPOS pos, Collection<? extends InfMWEDesc.InfMWEDescBuilder> inflectedForms, int... counts)
          Constructs a new MWE description object from the specified list of parts, inflected forms, part of speech, and counts relating to the MWE's appearance in the reference concordance.
RootMWEDesc(String surfaceForm, MWEPOS pos)
          Constructs a new MWE description object from the specified surface form and part of speech, that has no inflected forms
RootMWEDesc(String surfaceForm, MWEPOS pos, Collection<? extends InfMWEDesc.InfMWEDescBuilder> inflectedForms, int... counts)
          Constructs a new MWE description object from the specified surface form, inflected forms, part of speech, and counts relating to the MWE's appearance in the reference concordance.
 
Method Summary
 boolean equals(Object obj)
           
protected  int getExpectedCountLength()
          Subclasses should implement this method to return the number of counts relating to the MWE's appearance in a reference concordance that are expected in the implementation.
 IMWEDescID getID()
          Returns the IMWEDescID associated with this description.
 Map<String,? extends IInfMWEDesc> getInflected()
          Returns an unmodifiable set of MWE descriptions corresponding to the inflected versions of this form.
 MWEPOS getPOS()
          Returns the part of speech of this object.
 int getUnmarkedInflected()
          Returns the number of times an inflected form of this MWE description occurs in the reference concordance without being marked as an occurrence of the MWE, and without being an exact match to a known inflected form of this root.
 int hashCode()
           
protected  IRootMWEDesc.IRootPart makePart(String form, int index)
          Subclasses should implement this method to construct an IMWEDesc.IPart given the form and index of a part of an MWE.
static IRootMWEDesc parse(String descStr)
          Parses the given description string into a root mwe description object.
static int[] parseCounts(String countStr)
          Parses a string of counts separated by commas into an array of integers.
static void toString(int[] counts, Appendable buf)
          Returns a string containing the given counts as
static String toString(IRootMWEDesc mweDesc)
          Returns the String representation of the given description.
static void toString(IRootMWEDesc root, Appendable buf)
          Returns the String representation of the given description as:
 
Methods inherited from class edu.mit.jmwe.data.AbstractMWEDesc
checkCount, compareTo, concatenate, equalsRoots, getCounts, getForm, getMarkedContinuous, getMarkedSplit, getParts, getRoot, getUnmarkedExact, getUnmarkedPattern, isFillerForSlot, isStopWord, splitOnUnderscores, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.mit.jmwe.data.IRootMWEDesc
getParts
 
Methods inherited from interface edu.mit.jmwe.data.IMWEDesc
getCounts, getMarkedContinuous, getMarkedSplit, getUnmarkedExact, getUnmarkedPattern
 
Methods inherited from interface edu.mit.jmwe.data.IHasForm
getForm
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

RootMWEDesc

public RootMWEDesc(String surfaceForm,
                   MWEPOS pos)
Constructs a new MWE description object from the specified surface form and part of speech, that has no inflected forms

Parameters:
surfaceForm - A string representing the MWE with its words separated by underscores
pos - The part of speech object representing the part of speech of the MWE
Throws:
NullPointerException - if either argument is null
IllegalArgumentException - if the surface form does not contain underscores
Since:
jMWE 1.0.0

RootMWEDesc

public RootMWEDesc(String surfaceForm,
                   MWEPOS pos,
                   Collection<? extends InfMWEDesc.InfMWEDescBuilder> inflectedForms,
                   int... counts)
Constructs a new MWE description object from the specified surface form, inflected forms, part of speech, and counts relating to the MWE's appearance in the reference concordance.

Parameters:
surfaceForm - A string representing the MWE with its words separated by underscores
pos - The part of speech object representing the part of speech of the MWE
inflectedForms - the collection of builders used to create the descriptions of the inflected forms of this MWE.
counts - the counts relating to the MWE's appearance in the reference concordance.
Throws:
NullPointerException - if the surface form or pos is null
IllegalArgumentException - if the surface form does not contain underscores
Since:
jMWE 1.0.0

RootMWEDesc

public RootMWEDesc(List<String> parts,
                   MWEPOS pos)
Constructs a new MWE description object from the specified list of parts and part of speech, that has no inflected forms

Parameters:
parts - A list of parts that comprise the MWE
pos - The part of speech object representing the part of speech of the MWE
Throws:
NullPointerException - if either argument is null
IllegalArgumentException - if the specified list has less than two elements, or any trimmed string in the list contains an underscore, is empty, or contains whitespace
Since:
jMWE 1.0.0

RootMWEDesc

public RootMWEDesc(List<String> parts,
                   MWEPOS pos,
                   Collection<? extends InfMWEDesc.InfMWEDescBuilder> inflectedForms,
                   int... counts)
Constructs a new MWE description object from the specified list of parts, inflected forms, part of speech, and counts relating to the MWE's appearance in the reference concordance.

Parameters:
parts - A list of parts that comprise the MWE
pos - The part of speech object representing the part of speech of the MWE
inflectedForms - the collection of builders used to create the descriptions of the inflected forms of this MWE.
counts - the counts relating to the MWE's appearance in the reference concordance.
Throws:
NullPointerException - if the list of parts or pos is null
IllegalArgumentException - if the specified list has less than two elements, or any trimmed string in the list contains an underscore, is empty, or contains whitespace
Since:
jMWE 1.0.0
Method Detail

getExpectedCountLength

protected int getExpectedCountLength()
Description copied from class: AbstractMWEDesc
Subclasses should implement this method to return the number of counts relating to the MWE's appearance in a reference concordance that are expected in the implementation.

Specified by:
getExpectedCountLength in class AbstractMWEDesc<IRootMWEDesc.IRootPart>
Returns:
the number of counts relating to the MWE's appearance in a reference concordance.

makePart

protected IRootMWEDesc.IRootPart makePart(String form,
                                          int index)
Description copied from class: AbstractMWEDesc
Subclasses should implement this method to construct an IMWEDesc.IPart given the form and index of a part of an MWE.

Specified by:
makePart in class AbstractMWEDesc<IRootMWEDesc.IRootPart>
Parameters:
form - the text of the part
index - the index of the part in the MWE

getID

public IMWEDescID getID()
Description copied from interface: IMWEDesc
Returns the IMWEDescID associated with this description.

Specified by:
getID in interface IMWEDesc
Returns:
the IMWEDescID associated with this description. Never null.

getPOS

public MWEPOS getPOS()
Description copied from interface: IHasMWEPOS
Returns the part of speech of this object. May not return null.

Specified by:
getPOS in interface IHasMWEPOS
Returns:
the non-null part of speech of the MWE.

getInflected

public Map<String,? extends IInfMWEDesc> getInflected()
Description copied from interface: IRootMWEDesc
Returns an unmodifiable set of MWE descriptions corresponding to the inflected versions of this form. If the method returns an empty set, this means that the expression cannot be inflected. If the method returns null, this means the no inflected forms have yet been assigned.

Specified by:
getInflected in interface IRootMWEDesc
Returns:
a possibly null, possibly empty set of inflected MWE descriptions.

getUnmarkedInflected

public int getUnmarkedInflected()
Description copied from interface: IRootMWEDesc
Returns the number of times an inflected form of this MWE description occurs in the reference concordance without being marked as an occurrence of the MWE, and without being an exact match to a known inflected form of this root. To be counted as an inflected unmarked occurrence, there must be a continuous run of tokens whose forms or stems match, in order, the forms of the parts (ignoring case) of this MWE description. Will always zero or a positive number.

Specified by:
getUnmarkedInflected in interface IRootMWEDesc
Returns:
the number of inflected unmarked occurrences of this MWE in the reference concordance.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public static String toString(IRootMWEDesc mweDesc)
Returns the String representation of the given description.

Parameters:
mweDesc - the description to be represented as a String.
Returns:
the String representation of the given description.
Since:
jMWE 1.0.0

toString

public static void toString(IRootMWEDesc root,
                            Appendable buf)
                     throws IOException
Returns the String representation of the given description as:

id count[0],count[1], ...,count[n] inf[1] inf[2] ... inf[m]

inf[i] is an inflected form of the MWE represented as:

infForm count[0],count[1], ...,count[n]

Parameters:
root - the description to be represented as a String.
buf - the appendable buffer used to build the String.
Throws:
IOException
Since:
jMWE 1.0.0

toString

public static void toString(int[] counts,
                            Appendable buf)
                     throws IOException
Returns a string containing the given counts as

count[0],count[1], ...,count[n]

Parameters:
counts - the counts to be represented as a String
buf - the appendable buffer used to build the String.
Throws:
IOException
Since:
jMWE 1.0.0

parse

public static IRootMWEDesc parse(String descStr)
Parses the given description string into a root mwe description object.

Parameters:
descStr - the string to be parsed
Returns:
an IRootMWEDesc containing the fields specified in the given string.
Since:
jMWE 1.0.0

parseCounts

public static int[] parseCounts(String countStr)
Parses a string of counts separated by commas into an array of integers.

Parameters:
countStr - the string to be parsed.
Returns:
an int array containing the counts in the given string
Since:
jMWE 1.0.0


Copyright © 2011 Massachusetts Institute of Technology. All Rights Reserved.