Similarity Functions

Available functions:

  • edit_distance_score(text1, text2): Calculate the edit distance score between two texts.

  • bleu_score(reference, candidate): Calculate the BLEU score between a reference sentence and a candidate sentence.

  • jaccard_similarity_score(text1, text2): Calculate Jaccard similarity between two texts.


Edit distance score

Calculate the edit distance score between two texts.

Parameters:
- `text1` (str): The first text.
- `text2` (str): The second text.

Returns:
- `int`: The edit distance score.

BLEU Score

Calculate the BLEU score between a reference sentence and a candidate sentence.

Parameters:
- `reference` (str): The reference sentence.
- `candidate` (str): The candidate sentence.

Returns:
- `float`: The BLEU score.

Jaccard Similarity Score

Jaccard similarity is a measure of similarity between two sets. In the context of text comparison, it calculates the similarity between the sets of words in two texts.

Parameters:
- `text1` (str): The first text for comparison.
- `text2` (str): The second text for comparison.

Returns:
- `float`: Jaccard similarity score between the two texts. The score ranges
from 0 (no similarity) to 1 (complete similarity).

Last updated