我想对预编译和存储的正则表达式列表使用自动完成,但似乎我不能导入_sre.SRE_Pattern类,并且我无法以编程方式将获取的类型从type()提供给a注释格式#type:classname或用于返回 - > classname样式提示
有没有办法从_sre.c中显式导入一个类?
我打算尝试使用带有调整过的可接受分数参数的 Fuzzywuzzy 基本上它会检查单词是否按原样在词汇表中,如果不是,它会要求 Fuzzywuzzy 选择最佳模糊匹配,并接受列表令牌,如果它至少是一个特定的分数。
如果这不是处理大量拼写错误和拼写略有不同但相似的单词的最佳方法,我愿意接受建议。
问题是子类一直抱怨它有一个空词汇表,这没有任何意义,因为当我在代码的同一部分使用常规计数向量化器时,它工作正常。
它会吐出很多这样的错误: ValueError: empty words; 也许文档只包含停用词
我错过了什么?我还没有让它做任何特别的事情。它应该像往常一样工作:
class FuzzyCountVectorizer(CountVectorizer):
def __init__(self, input='content', encoding='utf-8', decode_error='strict',
strip_accents=None, lowercase=True, preprocessor=None, tokenizer=None, stop_words=None,
token_pattern="(?u)\b\w\w+\b", ngram_range=(1, 1), analyzer='word',
max_df=1.0, min_df=1, max_features=None, vocabulary=None, binary=False,
dtype=numpy.int64, min_fuzzy_score=80):
super().__init__(
input=input, encoding=encoding, decode_error=decode_error, strip_accents=strip_accents,
lowercase=lowercase, preprocessor=preprocessor, tokenizer=tokenizer, stop_words=stop_words,
token_pattern=token_pattern, ngram_range=ngram_range, analyzer=analyzer, max_df=max_df,
min_df=min_df, max_features=max_features, vocabulary=vocabulary, binary=binary, dtype=dtype)
# self._trained = False
self.min_fuzzy_score = min_fuzzy_score
@staticmethod
def remove_non_alphanumeric_chars(s: str) -> 'str':
pass
@staticmethod
def tokenize_text(s: str) -> 'List[str]':
pass
def fuzzy_repair(self, sl: 'List[str]') -> …Run Code Online (Sandbox Code Playgroud)