mirror of
https://github.com/qurator-spk/dinglehopper.git
synced 2025-06-11 04:39:59 +02:00
🐛 Use typing.List instead of list, for Python <3.9
This commit is contained in:
parent
071766efc2
commit
c752793be6
3 changed files with 6 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
|||
import unicodedata
|
||||
from typing import Tuple
|
||||
from typing import Tuple, List
|
||||
|
||||
from multimethod import multimethod
|
||||
from uniseg.graphemecluster import grapheme_clusters
|
||||
|
@ -10,7 +10,7 @@ from .extracted_text import ExtractedText
|
|||
|
||||
@multimethod
|
||||
def character_error_rate_n(
|
||||
reference: list[str], compared: list[str]
|
||||
reference: List[str], compared: List[str]
|
||||
) -> Tuple[float, int]:
|
||||
"""
|
||||
Compute character error rate.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import unicodedata
|
||||
from typing import List
|
||||
|
||||
from multimethod import multimethod
|
||||
from rapidfuzz.distance import Levenshtein
|
||||
|
@ -8,7 +9,7 @@ from .extracted_text import ExtractedText
|
|||
|
||||
|
||||
@multimethod
|
||||
def distance(seq1: list[str], seq2: list[str]):
|
||||
def distance(seq1: List[str], seq2: List[str]):
|
||||
"""Compute the Levenshtein edit distance between two lists of grapheme clusters.
|
||||
|
||||
This assumes that the grapheme clusters are already normalized.
|
||||
|
|
|
@ -4,7 +4,7 @@ import re
|
|||
import unicodedata
|
||||
from contextlib import suppress
|
||||
from itertools import repeat
|
||||
from typing import Optional
|
||||
from typing import List, Optional
|
||||
|
||||
import attr
|
||||
import numpy as np
|
||||
|
@ -135,7 +135,7 @@ class ExtractedText:
|
|||
segments = attr.ib(type=Optional[list], converter=attr.converters.optional(list))
|
||||
joiner = attr.ib(type=Optional[str])
|
||||
_text = attr.ib(type=Optional[str])
|
||||
_grapheme_clusters = attr.ib(type=Optional[list[str]])
|
||||
_grapheme_clusters = attr.ib(type=Optional[List[str]])
|
||||
|
||||
@segments.validator
|
||||
def check(self, _, value):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue