1
0
Fork 0
mirror of https://github.com/qurator-spk/dinglehopper.git synced 2025-06-08 11:20:26 +02:00

Remove support for ExtractedText for bag metrics.

This commit is contained in:
Benjamin Rosemann 2021-06-11 10:23:26 +02:00
parent 381fe7cb6b
commit 9f5112f8f6
2 changed files with 1 additions and 10 deletions

View file

@ -1,20 +1,12 @@
from collections import Counter
from typing import Union
from .utils import bag_accuracy, MetricResult, Weights
from .. import ExtractedText
from ..normalize import words_normalized
def bag_of_words_accuracy(
reference: Union[str, ExtractedText],
compared: Union[str, ExtractedText],
weights: Weights,
reference: str, compared: str, weights: Weights
) -> MetricResult:
if isinstance(reference, ExtractedText):
reference = reference.text
if isinstance(compared, ExtractedText):
compared = compared.text
reference_words = Counter(words_normalized(reference))
compared_words = Counter(words_normalized(compared))
result = bag_accuracy(reference_words, compared_words, weights)

View file

@ -1,4 +1,3 @@
import math
import unicodedata
from collections import Counter