|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.mit.jmwe.index.InMemoryMWEIndex
public abstract class InMemoryMWEIndex
The default abstract implementation of IMWEIndex
. Loads the entire index into
memory. Subclasses must implement the createData()
method to actually create
the index data object.
Field Summary | |
---|---|
protected Lock |
lifecycleLock
|
Fields inherited from interface edu.mit.jmwe.index.IMWEIndex |
---|
commentDoubleSemicolon, commentDoubleSlash |
Constructor Summary | |
---|---|
InMemoryMWEIndex()
|
Method Summary | |
---|---|
protected void |
checkOpen()
Throws an IllegalStateException if the index is closed. |
void |
close()
Closes the index if open. |
protected abstract Map<IMWEDescID,? extends IRootMWEDesc> |
createData()
|
static Map<IMWEDescID,IRootMWEDesc> |
createData(Iterable<String> descStrs)
Utility method that assembles a MWE index data map from a list of multi-word expression string descriptions. |
static Map<IMWEDescID,IRootMWEDesc> |
createData(Reader r)
Utility method that assembles a MWE index data map from a stream of characters that contains a whitespace-delimited list of multi-word expressions. |
protected Map<String,? extends IMWEDescSet> |
createIndex(Map<IMWEDescID,? extends IRootMWEDesc> data)
Uses the given map of description IDs to root descriptions in order to create the index. |
IMWEDesc |
get(IMWEDescID id)
Returns the MWE description for the specified ID, or null if
this index does not contain said description. |
Set<? extends IRootMWEDesc> |
get(String part)
Returns a set of IRootMWEDesc objects whose MWEs contain the
specified part. |
IMWEDescSet |
getAll(String part)
Returns a set containing both IRootMWEDesc and IInfMWEDesc
objects that the given string is a part of. |
Iterator<String> |
getIndexIterator()
Returns an iterator that will iterate over all MWE parts in the index, in order. |
IInfMWEDesc |
getInflectedMWEDesc(String lemma,
MWEPOS pos,
String inflected)
Returns the inflected MWE description for the specified root lemma, part of speech, and inflected form, or null if this index does
not contain said description. |
Iterator<IRootMWEDesc> |
getRootIterator()
Returns an iterator that will iterate over all root MWE descriptions in the index, in order. |
IRootMWEDesc |
getRootMWEDesc(String lemma,
MWEPOS pos)
Returns the root MWE description for the specified lemma and part of speech, or null if this index does not contain said
description. |
protected void |
insert(String key,
IMWEDesc object,
Map<String,IMWEDescSet> map)
Adds the specified object to the set indexed under the specified key in the given map. |
static boolean |
isComment(String descStr)
Returns true if the given string is a comment; that is, if it starts with '//' or ';;'. |
boolean |
isOpen()
Returns whether the index is open. |
boolean |
open()
Prepares the index for use. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Lock lifecycleLock
Constructor Detail |
---|
public InMemoryMWEIndex()
Method Detail |
---|
public boolean open() throws IOException
IMWEIndex
IllegalStateException
.
Once open, an index can be closed by calling the IMWEIndex.close()
method.
open
in interface IMWEIndex
true
if the call succeeded, and the index is ready
to service calls; false
otherwise.
IOException
- if an IO exception is thrown while opening the indexprotected abstract Map<IMWEDescID,? extends IRootMWEDesc> createData() throws IOException
IOException
protected Map<String,? extends IMWEDescSet> createIndex(Map<IMWEDescID,? extends IRootMWEDesc> data)
data
- the map of IMWEDescID objects to IRootMWEDesc objects used to
create the index
protected final void insert(String key, IMWEDesc object, Map<String,IMWEDescSet> map)
key
- the key under which the object is to be filed; may be
null
object
- the object to be filed; may be null
map
- the map into which the object should be filed; may not be
null
NullPointerException
- if the specified map is null
public boolean isOpen()
IMWEIndex
isOpen
in interface IMWEIndex
true
if the index is open and ready to accept
calls; false
otherwise.public void close()
IMWEIndex
close
in interface IMWEIndex
public IMWEDesc get(IMWEDescID id)
IMWEIndex
null
if
this index does not contain said description.
get
in interface IMWEIndex
id
- the id for the MWE description desired; may not be
null
null
if
nonepublic IRootMWEDesc getRootMWEDesc(String lemma, MWEPOS pos)
IMWEIndex
null
if this index does not contain said
description.
getRootMWEDesc
in interface IMWEIndex
lemma
- the lemma for the MWE description desired; may not be
null
pos
- the part of speech for the MWE description desired; may not be
null
null
if nonepublic IInfMWEDesc getInflectedMWEDesc(String lemma, MWEPOS pos, String inflected)
IMWEIndex
null
if this index does
not contain said description.
getInflectedMWEDesc
in interface IMWEIndex
lemma
- the lemma for the MWE description desired; may not be
null
pos
- the part of speech for the MWE description desired; may not be
null
inflected
- the inflected form of the MWE description desired; may not be
null
null
if nonepublic Set<? extends IRootMWEDesc> get(String part)
IMWEIndex
IRootMWEDesc
objects whose MWEs contain the
specified part. Retrieval is insensitive to case. If no entries are
found, this method returns an empty set. The order of the returned set is
implementation dependent.
get
in interface IMWEIndex
part
- a string representing the part for which entries should be
retrieved
public IMWEDescSet getAll(String part)
IMWEIndex
IInfMWEDesc
objects that the given string is a part of. Retrieval is insensitive to
case. If no entries are found, this method returns an empty set. The
order of the returned set is implementation dependent.
getAll
in interface IMWEIndex
part
- a string representing the part for which entries should be
retrieved
public Iterator<IRootMWEDesc> getRootIterator()
IMWEIndex
getRootIterator
in interface IMWEIndex
public Iterator<String> getIndexIterator()
IMWEIndex
getIndexIterator
in interface IMWEIndex
protected void checkOpen()
IllegalStateException
if the index is closed.
public static boolean isComment(String descStr)
descStr
- the string to be checked
public static Map<IMWEDescID,IRootMWEDesc> createData(Iterable<String> descStrs)
tok1_tok2_..._tokN_POS
, where each tok#
is one
part of the multiword expression, and POS
is the MWE part of
speech, represented as the identifier character.
descStrs
- the collection of mwe description strings to be processed into
the index data object
NullPointerException
- if the specified iterable is null
public static Map<IMWEDescID,IRootMWEDesc> createData(Reader r) throws IOException
tok1_tok2_..._tokN_POS
, where each tok#
is one
part of the multiword expression, and POS
is the MWE part of
speech, represented as the identifier character.
IOException
- if there is an IOException thrown while reading from the
reader
NullPointerException
- if the reader is null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |