|
Parsing Engine | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanbikel.parser.BrokenSubcatBag
public class BrokenSubcatBag
A “broken” version of SubcatBag that precisely reflects
the details specified in Collins’ thesis (used for
“clean-room” implementation). Catuion: Changes
made to the way SubcatBag operates may have rendered this class
even more “broken” than originally intended.
Training.argNonterminals() map.
As a special case, this class also supports gap requirements, that is,
requirements equal to Training.gapAugmentation(). This class also
provides a separate bin for miscellaneous subcat requirements, such as those
that can be matched via AbstractTraining.headSym.
All nonterminal requirements are stripped of any augmentations before being
counted in this subcat bag.
The comment for the toSexp method describes the way in which
this class represents miscellaneous requirements.
Bugs: Training.argNonterminals(), unless it
is modified, this class will simply put these elements in the miscellaneous
bin.
Subcats,
toSexp(),
Serialized Form| Constructor Summary | |
|---|---|
BrokenSubcatBag()
Constructs an empty subcat. |
|
BrokenSubcatBag(SexpList list)
Constructs a subcat bag containing the number of occurrences of the symbols of list. |
|
| Method Summary | |
|---|---|
MutableEvent |
add(int type,
Object obj)
Adds the specified object of the specified type to this event. |
MutableEvent |
add(Object obj)
Adds the specified object to this event. |
Subcat |
add(Symbol requirement)
Adds the specified requirement to this subcat bag. |
boolean |
addAll(SexpList list)
Adds each of the symbols of list to this subcat bag,
effectively calling add(Symbol) for each element of
list. |
void |
become(Subcat other)
Causes this subcat to be equal to the specified subcat by copying the specified subcat's data to this subcat. |
int |
canonicalize(Map canonical)
This method does nothing and returns -1, as no internal data to this class can be canonicalized. |
void |
clear()
This method sets all counts of this subcat bag to zero. |
boolean |
contains(Symbol requirement)
Returns true if this subcat frame contains the
specified requirement. |
Event |
copy()
Returns a deep copy of this subcat bag. |
boolean |
empty()
Returns true if and only if there are zero requirements
in this subcat bag. |
void |
ensureCapacity(int size)
This method does nothing and returns. |
void |
ensureCapacity(int type,
int size)
This method does nothing and returns. |
boolean |
equals(Object obj)
Returns true if and only if the specified object is of
type BrokenSubcatBag and has the same number of requirement
categories and has the same counts for each of those requirement
categories. |
Object |
get(int type,
int index)
Gets the indexth components of this subcat bag. |
Subcat |
getCanonical(boolean copyInto,
Map<Subcat,Subcat> map)
Returns a canonical instance of this object using the specified map (optional operation). |
Class |
getClass(int type)
This method returns the one class that Subcat objects
need to support: Symbol.class. |
int |
hashCode()
Computes the hash code for this subcat. |
Iterator |
iterator()
Returns an itrerator over the elements of this subcat bag, returning the canonical version of symbols for each the categories described in add(Symbol); for each occurrence of a miscellaneous item
present in this subcat bag, the return value of Training.stopSym()
is returned. |
int |
numComponents()
An alias for size(). |
int |
numComponents(int type)
An alias for size(). |
int |
numTypes()
Returns 1 ( Subcat objects only support Symbol
objects). |
void |
readExternal(ObjectInput stream)
|
boolean |
remove(Symbol requirement)
Removes the specified requirement from this subcat bag, if possible. |
static void |
setUpFastUidMap(CountsTable nonterminals)
|
int |
size()
Returns the number of requirements contained in this subcat bag. |
Sexp |
toSexp()
As per the contract of Subcat, this method returns a
Sexp such that an equivalent BrokenSubcatBag
object would result from the addAll(SexpList) method being
invoked with this Sexp as its argument. |
String |
toString()
Returns a human-readable string representation of the requirements contained in this bag. |
int |
typeIndex(Class cl)
Returns 0 if the specified class is equal to Symbol.class, -1 otherwise. |
protected boolean |
validRequirement(Symbol requirement)
A method to check if the specified requirement is valid. |
void |
writeExternal(ObjectOutput stream)
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public BrokenSubcatBag()
public BrokenSubcatBag(SexpList list)
list.
list - a list of Symbol objects to be added to this
subcat bag| Method Detail |
|---|
public static void setUpFastUidMap(CountsTable nonterminals)
protected boolean validRequirement(Symbol requirement)
Training.gapAugmentation() or a symbol for which
Training.isArgumentFast(Symbol) returns true.
A subclass may override this method to allow for new or different
valid requirements.
requirement - the requirement to test
public Subcat add(Symbol requirement)
Training.argNonterminals(), as
well as a bin for gap augmentations (that is, requirements that are
equal to Training.gapAugmentation()) and a miscellaneous bin
for all other requirements, such as those that can be matched via
AbstractTraining.headSym.
add in interface Subcatrequirement - the requirement to add to this subcat bag
Subcat objectTraining.defaultArgAugmentation(),
Training.gapAugmentation(),
Training.isArgumentFast(Symbol)public boolean addAll(SexpList list)
list to this subcat bag,
effectively calling add(Symbol) for each element of
list.
addAll in interface Subcatlist - a list of Symbol objects to be added to this
subcat bag
ClassCastException - if one or more elements of list
is not an instance of Symbolpublic boolean remove(Symbol requirement)
Language.training().isArgumentFast(requirement)
returns true, and if this subcat contained at least
one instance of that nonterminal.
remove in interface Subcatrequirement - the element that has been generated by the parser
and is thus a candidate for removal from this subcat
true if this subcat bag contained at least one
instance of the specified requirement and it was removed,
false otherwiseTraining.isArgumentFast(Symbol)public int size()
size in interface Subcatpublic boolean empty()
true if and only if there are zero requirements
in this subcat bag.
empty in interface Subcatpublic boolean contains(Symbol requirement)
Subcattrue if this subcat frame contains the
specified requirement.
contains in interface Subcatrequirement - the requirement for which membership in this
subcat is to be checked
true if this subcat contains requirement,
that is, returns true if and only if Subcat.remove(Symbol)
would remove the specified symbol from this subcatpublic Iterator iterator()
add(Symbol); for each occurrence of a miscellaneous item
present in this subcat bag, the return value of Training.stopSym()
is returned.
iterator in interface Subcatpublic Event copy()
copy in interface Eventpublic int hashCode()
hashCode in interface EventhashCode in interface SubcathashCode in class Objectpublic boolean equals(Object obj)
true if and only if the specified object is of
type BrokenSubcatBag and has the same number of requirement
categories and has the same counts for each of those requirement
categories.
equals in interface Eventequals in interface Subcatequals in class Objectpublic String toString()
toString in class Object
public Subcat getCanonical(boolean copyInto,
Map<Subcat,Subcat> map)
Subcat
getCanonical in interface SubcatcopyInto - specifies whether to copy this subcat before inserting
into the canonical mapmap - the reflexive map to use for canonicalization: the key-value
pair of (this, this) should be added to map
if this object is not already a key in map
public MutableEvent add(Object obj)
MutableEventthis.typeIndex(obj.getClass())must not return -1.
If an implementation of this interface collects components that
are primitive type values, then these values should be wrapped
in their corresponding wrapper classes. For example, if an
implementation of this interface accepts int values,
they should be passed as Integer objects to this method.
At present, an Event implementation cannot be
designed accept both a primitive type and its associated wrapper
class' type (this is, of course, not a serious limitation).
add in interface MutableEvent
public MutableEvent add(int type,
Object obj)
MutableEventthis.typeIndex(obj.getClass()) == typemust be true.
If an implementation of this interface collects components that
are primitive type values, then these values should be wrapped
in their corresponding wrapper classes. For example, if an
implementation of this interface accepts int values,
they should be passed as an Integer objects to this method.
At present, an Event implementation cannot be
designed accept both a primitive type and its associated wrapper
class' type (this is, of course, not a serious limitation).
add in interface MutableEventpublic void ensureCapacity(int size)
ensureCapacity in interface MutableEventsize - the size to pre-allocate for all abstract lists of this event
public void ensureCapacity(int type,
int size)
ensureCapacity in interface MutableEventtype - the type of underlying abstract list for which to pre-allocate
spacesize - the size to pre-allocate for the specified type of abstract
listpublic Class getClass(int type)
Subcat objects
need to support: Symbol.class.
getClass in interface EventClass) associated with the specified
type indexpublic int typeIndex(Class cl)
Symbol.class, -1 otherwise.
typeIndex in interface Eventpublic int numTypes()
Subcat objects only support Symbol
objects).
numTypes in interface Eventpublic int numComponents()
size().
numComponents in interface Eventpublic int numComponents(int type)
size().
numComponents in interface Eventpublic int canonicalize(Map canonical)
canonicalize in interface Eventcanonical - a reflexive map of objecs representing event
information: for each unique key-value pair, the value is a
reference to the key
canonical) or
-1 if this event was not even eligible for canonicalizationpublic void clear()
clear in interface MutableEvent
public Object get(int type,
int index)
indexth components of this subcat bag.
Efficiency note: The time complexity of this method is linear in the number of requirement types.
get in interface Eventtype - an unused type parameter (Subcat events only
support the type Symbol, so this argument is effectively
superfluous for this class)index - the index of the requirement to get
indexth Symbol of this
subcat bag, as would be returned by the indexth
invocation of next from the iterator returned by
iterator()public Sexp toSexp()
Subcat, this method returns a
Sexp such that an equivalent BrokenSubcatBag
object would result from the addAll(SexpList) method being
invoked with this Sexp as its argument.
N.B.: For each occurrence of a miscellaneous item present
in this subcat bag, the returned list will contain the symbol
Training.stopSym() augmented with the argument augmentation:
Symbol.get(Training.stopSym().toString() +Treebank.canonicalAugDelimiter()+Training.defaultArgAugmentation());
toSexp in interface SexpConvertibletoSexp in interface Subcat
public void writeExternal(ObjectOutput stream)
throws IOException
writeExternal in interface ExternalizableIOException
public void readExternal(ObjectInput stream)
throws IOException,
ClassNotFoundException
readExternal in interface ExternalizableIOException
ClassNotFoundExceptionpublic void become(Subcat other)
Subcat
become in interface Subcatother - the subcat that this subcat is to become
|
Parsing Engine | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||