Class SegGraph
- java.lang.Object
-
- org.apache.lucene.analysis.cn.smart.hhmm.SegGraph
-
class SegGraph extends java.lang.Object
Graph representing possible tokens at each start offset in the sentence.For each start offset, a list of possible tokens is stored.
-
-
Field Summary
Fields Modifier and Type Field Description private int
maxStart
private java.util.Map<java.lang.Integer,java.util.ArrayList<SegToken>>
tokenListTable
Map of start offsets to ArrayList of tokens at that position
-
Constructor Summary
Constructors Constructor Description SegGraph()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addToken(SegToken token)
Add aSegToken
to the mapping, creating a new mapping at the token's startOffset if one does not exist.int
getMaxStart()
Get the highest start offset in the mapjava.util.List<SegToken>
getStartList(int s)
Get the list of tokens at the specified start offsetboolean
isStartExist(int s)
Returns true if a mapping for the specified start offset existsjava.util.List<SegToken>
makeIndex()
Set theSegToken.index
for each token, based upon its order by startOffset.java.lang.String
toString()
java.util.List<SegToken>
toTokenList()
Return aList
of all tokens in the map, ordered by startOffset.
-
-
-
Field Detail
-
tokenListTable
private java.util.Map<java.lang.Integer,java.util.ArrayList<SegToken>> tokenListTable
Map of start offsets to ArrayList of tokens at that position
-
maxStart
private int maxStart
-
-
Method Detail
-
isStartExist
public boolean isStartExist(int s)
Returns true if a mapping for the specified start offset exists- Parameters:
s
- startOffset- Returns:
- true if there are tokens for the startOffset
-
getStartList
public java.util.List<SegToken> getStartList(int s)
Get the list of tokens at the specified start offset- Parameters:
s
- startOffset- Returns:
- List of tokens at the specified start offset.
-
getMaxStart
public int getMaxStart()
Get the highest start offset in the map- Returns:
- maximum start offset, or -1 if the map is empty.
-
makeIndex
public java.util.List<SegToken> makeIndex()
Set theSegToken.index
for each token, based upon its order by startOffset.- Returns:
- a
List
of these ordered tokens.
-
addToken
public void addToken(SegToken token)
Add aSegToken
to the mapping, creating a new mapping at the token's startOffset if one does not exist.- Parameters:
token
-SegToken
-
toTokenList
public java.util.List<SegToken> toTokenList()
Return aList
of all tokens in the map, ordered by startOffset.- Returns:
List
of all tokens in the map.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-