Record Class Bigram

Record Components:
w1 - the first word of bigram.
w2 - the second word of bigram.
count - the total number of occurrences of bigram in the corpus.
score - the chi-square statistical score of the collocation in the corpus.
All Implemented Interfaces:
Comparable<Bigram>

public record Bigram(String w1, String w2, int count, double score) extends Record implements Comparable<Bigram>
Bigrams or digrams are groups of two words, and are very commonly used as the basis for simple statistical analysis of text. They are a special case of N-gram.
  • Constructor Details

    • Bigram

      public Bigram(String w1, String w2)
      Constructor.
      Parameters:
      w1 - the first word of bigram.
      w2 - the second word of bigram.
    • Bigram

      public Bigram(String w1, String w2, int count, double score)
      Creates an instance of a Bigram record class.
      Parameters:
      w1 - the value for the w1 record component
      w2 - the value for the w2 record component
      count - the value for the count record component
      score - the value for the score record component
  • Method Details

    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public boolean equals(Object obj)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      obj - the object with which to compare
      Returns:
      true if this object is the same as the obj argument; false otherwise.
    • compareTo

      public int compareTo(Bigram o)
      Specified by:
      compareTo in interface Comparable<Bigram>
    • w1

      public String w1()
      Returns the value of the w1 record component.
      Returns:
      the value of the w1 record component
    • w2

      public String w2()
      Returns the value of the w2 record component.
      Returns:
      the value of the w2 record component
    • count

      public int count()
      Returns the value of the count record component.
      Returns:
      the value of the count record component
    • score

      public double score()
      Returns the value of the score record component.
      Returns:
      the value of the score record component