Source code for jina.executors.evaluators.text.length

__copyright__ = "Copyright (c) 2020 Jina AI Limited. All rights reserved."
__license__ = "Apache-2.0"

from . import BaseTextEvaluator


[docs]class TextLengthEvaluator(BaseTextEvaluator): """A :class:`TextLengthEvaluator` evaluates the different lengths between actual and desired text""" metric = 'LengthDiff'
[docs] def evaluate(self, actual: str, desired: str, *args, **kwargs) -> float: """ " :param actual: the text of the document :param desired: the expected text of the document :return the evaluation metric value for the request document """ return abs(len(actual) - len(desired))