class_docstr: Calculates the similarity of two statements based on the Jaccard index.
  
  The Jaccard index is composed of a numerator and denominator.
  In the numerator, we count the number of items that are shared between the sets.
  In the denominator, we count the total number of items across both sets.
  Let's say we define sentences to be equivalent if 50% or more of their tokens are equivalent.
  Here are two sample sentences:
  
      The young cat is hungry.
      The cat is very hungry.
  
  When we parse these sentences to remove stopwords, we end up with the following two sets:
  
      {young, cat, hungry}
      {cat, very, hungry}
  
  In our example above, our intersection is {cat, hungry}, which has count of two.
  The union of the sets is {young, cat, very, hungry}, which has a count of four.
  Therefore, our `Jaccard similarity index`_ is two divided by four, or 50%.
  Given our similarity threshold above, we would consider this to be a match.
  
  .. _`Jaccard similarity index`: https://en.wikipedia.org/wiki/Jaccard_index
class_docstr_tok: ["Calculates","the","similarity","of","two","statements","based","on","the","Jaccard","index",".","The","Jaccard","index","is","composed","of","a","numerator","and","denominator",".","In","the","numerator",",","we","count","the","number","of","items","that","are","shared","between","the","sets",".","In","the","denominator",",","we","count","the","total","number","of","items","across","both","sets",".","Let","'s","say","we","define","sentences","to","be","equivalent","if","50","%","or","more","of","their","tokens","are","equivalent",".","Here","are","two","sample","sentences",":","The","young","cat","is","hungry",".","The","cat","is","very","hungry",".","When","we","parse","these","sentences","to","remove","stopwords",",","we","end","up","with","the","following","two","sets",":","{","young",",","cat",",","hungry","}","{","cat",",","very",",","hungry","}","In","our","example","above",",","our","intersection","is","{","cat",",","hungry","}",",","which","has","count","of","two",".","The","union","of","the","sets","is","{","young",",","cat",",","very",",","hungry","}",",","which","has","a","count","of","four",".","Therefore",",","our","`","Jaccard","similarity","index","`","_","is","two","divided","by","four",",","or","50","%",".","Given","our","similarity","threshold","above",",","we","would","consider","this","to","be","a","match",".","..","_","`","Jaccard","similarity","index","`",":","https",":","\/\/en.wikipedia.org\/wiki\/Jaccard_index"]
docstr: Return the calculated similarity of two
  statements based on the Jaccard index.
docstr_tok: ["Return","the","calculated","similarity","of","two","statements","based","on","the","Jaccard","index","."]
code: def compare(self, statement_a, statement_b):
      """
      Return the calculated similarity of two
      statements based on the Jaccard index.
      """
      # Make both strings lowercase
      document_a = self.nlp(statement_a.text.lower())
      document_b = self.nlp(statement_b.text.lower())
  
      statement_a_lemmas = set(
          [token.lemma_ for token in document_a if not token.is_stop]
      )
      statement_b_lemmas = set(
          [token.lemma_ for token in document_b if not token.is_stop]
      )
  
      # Calculate Jaccard similarity
      numerator = len(
          statement_a_lemmas.intersection(statement_b_lemmas)
      )
      denominator = float(
          len(statement_a_lemmas.union(statement_b_lemmas))
      )
      ratio = numerator / denominator
  
      return ratio
  
file_path: ChatterBot/chatterbot/comparisons.py
imports: from chatterbot.exceptions import OptionalDependencyImportError
  from difflib import SequenceMatcher
label_desc: Use image node_id 2 for calling the JaccardSimilarity obj's underlying member method code with example usage: obj.compare(statement_a, statement_b) and returns: ratio