info.aduna.language.identification.ngram
Class NGram

java.lang.Object
  extended by info.aduna.language.identification.ngram.NGram
All Implemented Interfaces:
Comparable<NGram>

public class NGram
extends Object
implements Comparable<NGram>

A simple, straightforward n-gram implementation. This NGram has an additional field for capturing the number of occurrences of an ngram. This field is optional and completely ignored by the equals and hashCode methods.


Constructor Summary
NGram(char[] chars, int start, int length, int count)
           
 
Method Summary
 int compareTo(NGram other)
           
 boolean equals(char[] chars, int start, int length)
           
 boolean equals(Object object)
           
 int getCount()
          Returns the number of occurrences of this NGram, or a negative value when the count is not used.
 int hashCode()
           
static int hashCode(char[] chars, int start, int length)
          Create a hash code for the specified char sequence.
 void increaseCount()
          Increase the count with one.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NGram

public NGram(char[] chars,
             int start,
             int length,
             int count)
Method Detail

getCount

public int getCount()
Returns the number of occurrences of this NGram, or a negative value when the count is not used.


increaseCount

public void increaseCount()
Increase the count with one.


compareTo

public int compareTo(NGram other)
Specified by:
compareTo in interface Comparable<NGram>

equals

public boolean equals(char[] chars,
                      int start,
                      int length)

equals

public boolean equals(Object object)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

hashCode

public static int hashCode(char[] chars,
                           int start,
                           int length)
Create a hash code for the specified char sequence.



Copyright © 1997-2008 Aduna. All Rights Reserved.