|
|
@ -60,8 +60,8 @@ def words(s: str):
|
|
|
|
yield word
|
|
|
|
yield word
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@multimethod
|
|
|
|
@words.register
|
|
|
|
def words(s: ExtractedText):
|
|
|
|
def _(s: ExtractedText):
|
|
|
|
return words(s.text)
|
|
|
|
return words(s.text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -70,8 +70,8 @@ def words_normalized(s: str):
|
|
|
|
return words(unicodedata.normalize("NFC", s))
|
|
|
|
return words(unicodedata.normalize("NFC", s))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@multimethod
|
|
|
|
@words_normalized.register
|
|
|
|
def words_normalized(s: ExtractedText):
|
|
|
|
def _(s: ExtractedText):
|
|
|
|
return words_normalized(s.text)
|
|
|
|
return words_normalized(s.text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -82,15 +82,13 @@ def word_error_rate_n(reference: str, compared: str) -> Tuple[float, int]:
|
|
|
|
return word_error_rate_n(reference_seq, compared_seq)
|
|
|
|
return word_error_rate_n(reference_seq, compared_seq)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@multimethod
|
|
|
|
@word_error_rate_n.register
|
|
|
|
def word_error_rate_n(
|
|
|
|
def _(reference: ExtractedText, compared: ExtractedText) -> Tuple[float, int]:
|
|
|
|
reference: ExtractedText, compared: ExtractedText
|
|
|
|
|
|
|
|
) -> Tuple[float, int]:
|
|
|
|
|
|
|
|
return word_error_rate_n(reference.text, compared.text)
|
|
|
|
return word_error_rate_n(reference.text, compared.text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@multimethod
|
|
|
|
@word_error_rate_n.register
|
|
|
|
def word_error_rate_n(reference: Iterable, compared: Iterable) -> Tuple[float, int]:
|
|
|
|
def _(reference: Iterable, compared: Iterable) -> Tuple[float, int]:
|
|
|
|
reference_seq = list(reference)
|
|
|
|
reference_seq = list(reference)
|
|
|
|
compared_seq = list(compared)
|
|
|
|
compared_seq = list(compared)
|
|
|
|
|
|
|
|
|
|
|
|