Package com.cobber.fta.token
Class TokenStreams
- Object
-
- com.cobber.fta.token.TokenStreams
-
public class TokenStreams extends Object
This Singleton class captures the sum of all input observed as a set of instances of the TokenStream Class.
-
-
Constructor Summary
Constructors Constructor Description TokenStreams(int maxStreams)
Construct a TokenStreams object with a maximum number of TokenStream instances.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TokenStream
getBest()
Get the 'best' TokenStream - where 'best' is the one with the highest count.String
getRegExp(boolean fitted)
Get the 'best' Regular Expression we can based on the set of TokenStreams.long
getSamples()
Map<String,Long>
getShapes()
Get the Map of shapes.Map<String,TokenStream>
getStreams()
Get the Map of streams.boolean
isAnyShape()
boolean
isFull()
long
matches(String regExp, int confidence)
Check if the TokenStreams (i.e.int
size()
Get the size of the Map.void
track(String trimmed, long count)
Track the supplied input.
-
-
-
Method Detail
-
track
public void track(String trimmed, long count)
Track the supplied input.- Parameters:
trimmed
- The trimmed input.count
- The number of occurrences of this input.
-
isAnyShape
public boolean isAnyShape()
-
isFull
public boolean isFull()
-
getSamples
public long getSamples()
- Returns:
- The number of inputs this TokenStream has captured.
-
getRegExp
public String getRegExp(boolean fitted)
Get the 'best' Regular Expression we can based on the set of TokenStreams.- Parameters:
fitted
- If true the Regular Expression should be a 'more closely fitted' Regular Expression.- Returns:
- The 'best' Regular Expression we can based on the set of TokenStreams, or null if nothing clever can be discerned.
-
matches
public long matches(String regExp, int confidence)
Check if the TokenStreams (i.e. if all member TokenStream's) match the supplied Regular Expression at the supplied confidence level.- Parameters:
regExp
- The Regular Expression to match.confidence
- The confidence we require to determine if this is a match.- Returns:
- The number of matches if the TokenStreams matches the supplied Regular Expression at the supplied confidence level or 0 otherwise.
-
getBest
public TokenStream getBest()
Get the 'best' TokenStream - where 'best' is the one with the highest count.- Returns:
- The 'best' TokenStream entry.
-
getShapes
public Map<String,Long> getShapes()
Get the Map of shapes.- Returns:
- The ordered (by shape) Map of all shapes.
-
getStreams
public Map<String,TokenStream> getStreams()
Get the Map of streams.- Returns:
- The Map of all streams.
-
size
public int size()
Get the size of the Map.- Returns:
- The Map size.
-
-