org.apache.james.ai.classic
Class TokenCounter

java.lang.Object
  extended by org.apache.james.ai.classic.Tokenizer
      extended by org.apache.james.ai.classic.TokenCounter

public class TokenCounter
extends Tokenizer

Counts tokens occuring in stream. Totals are added to map.


Constructor Summary
TokenCounter(Map<String,Integer> countsByToken)
          Constructs a token counter to update values in given map.
 
Method Summary
 TokenCounter count(Reader stream)
          Tokenizes and adds token counts to map.
protected  void next(String token)
          Updates count for token in map.
 
Methods inherited from class org.apache.james.ai.classic.Tokenizer
doTokenize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TokenCounter

public TokenCounter(Map<String,Integer> countsByToken)
Constructs a token counter to update values in given map.

Parameters:
countsByToken - counts for token indexed by token, not null
Method Detail

count

public TokenCounter count(Reader stream)
                   throws IOException
Tokenizes and adds token counts to map.

Parameters:
stream - not null
Returns:
this, not null
Throws:
IOException

next

protected void next(String token)
Updates count for token in map.

Specified by:
next in class Tokenizer
Parameters:
token - not null


Copyright © 2008-2012 The Apache Software Foundation. All Rights Reserved.