Skip to content

Commit bace3bc

Browse files
committed
fix comment
1 parent a866d9c commit bace3bc

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

mmeval/metrics/char_recall_precision.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ class CharRecallPrecision(BaseMetric):
1414
1515
- unchanged: Do not change prediction texts and labels.
1616
- upper: Convert prediction texts and labels into uppercase
17-
characters.
17+
characters.
1818
- lower: Convert prediction texts and labels into lowercase
19-
characters.
19+
characters.
2020
2121
Usually, it only works for English characters. Defaults to
2222
'unchanged'.
2323
invalid_symbol (str): A regular expression to filter out invalid or
24-
not cared characters. Defaults to '[^A-Z^a-z^0-9^\u4e00-\u9fa5]'.
24+
not cared characters. Defaults to '[^A-Za-z0-9\u4e00-\u9fa5]'.
2525
**kwargs: Keyword parameters passed to :class:`BaseMetric`.
2626
2727
Examples:
@@ -36,21 +36,21 @@ class CharRecallPrecision(BaseMetric):
3636

3737
def __init__(self,
3838
letter_case: str = 'unchanged',
39-
invalid_symbol: str = '[^A-Z^a-z^0-9^\u4e00-\u9fa5]',
39+
invalid_symbol: str = '[^A-Za-z0-9\u4e00-\u9fa5]',
4040
**kwargs):
4141
super().__init__(**kwargs)
4242
assert letter_case in ['unchanged', 'upper', 'lower']
4343
self.letter_case = letter_case
4444
self.invalid_symbol = re.compile(invalid_symbol)
4545

46-
def add(self, predictions: Sequence[str], labels: Sequence[str]) -> None: # type: ignore # yapf: disable # noqa: E501
46+
def add(self, predictions: Sequence[str], groundtruths: Sequence[str]) -> None: # type: ignore # yapf: disable # noqa: E501
4747
"""Process one batch of data and predictions.
4848
4949
Args:
5050
predictions (list[str]): The prediction texts.
51-
labels (list[str]): The ground truth texts.
51+
groundtruths (list[str]): The ground truth texts.
5252
"""
53-
for pred, label in zip(predictions, labels):
53+
for pred, label in zip(predictions, groundtruths):
5454
if self.letter_case in ['upper', 'lower']:
5555
pred = getattr(pred, self.letter_case)()
5656
label = getattr(label, self.letter_case)()
@@ -79,10 +79,10 @@ def compute_metric(self, results: Sequence[Tuple[int, int, int]]) -> Dict:
7979
true_positive_sum += true_positive
8080
char_recall = true_positive_sum / max(gt_sum, 1.0)
8181
char_precision = true_positive_sum / max(pred_sum, 1.0)
82-
eval_res = {}
83-
eval_res['recall'] = char_recall
84-
eval_res['precision'] = char_precision
85-
return eval_res
82+
metric_results = {}
83+
metric_results['recall'] = char_recall
84+
metric_results['precision'] = char_precision
85+
return metric_results
8686

8787
def _cal_true_positive_char(self, pred: str, gt: str) -> int:
8888
"""Calculate correct character number in prediction.

0 commit comments

Comments
 (0)