mirror of
https://github.com/qurator-spk/dinglehopper.git
synced 2025-07-01 14:40:00 +02:00
Remove support for ExtractedText for bag metrics.
This commit is contained in:
parent
381fe7cb6b
commit
9f5112f8f6
2 changed files with 1 additions and 10 deletions
|
@ -1,20 +1,12 @@
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
from typing import Union
|
|
||||||
|
|
||||||
from .utils import bag_accuracy, MetricResult, Weights
|
from .utils import bag_accuracy, MetricResult, Weights
|
||||||
from .. import ExtractedText
|
|
||||||
from ..normalize import words_normalized
|
from ..normalize import words_normalized
|
||||||
|
|
||||||
|
|
||||||
def bag_of_words_accuracy(
|
def bag_of_words_accuracy(
|
||||||
reference: Union[str, ExtractedText],
|
reference: str, compared: str, weights: Weights
|
||||||
compared: Union[str, ExtractedText],
|
|
||||||
weights: Weights,
|
|
||||||
) -> MetricResult:
|
) -> MetricResult:
|
||||||
if isinstance(reference, ExtractedText):
|
|
||||||
reference = reference.text
|
|
||||||
if isinstance(compared, ExtractedText):
|
|
||||||
compared = compared.text
|
|
||||||
reference_words = Counter(words_normalized(reference))
|
reference_words = Counter(words_normalized(reference))
|
||||||
compared_words = Counter(words_normalized(compared))
|
compared_words = Counter(words_normalized(compared))
|
||||||
result = bag_accuracy(reference_words, compared_words, weights)
|
result = bag_accuracy(reference_words, compared_words, weights)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import math
|
|
||||||
import unicodedata
|
import unicodedata
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue