Pattern
Pattern(pattern)
Class for representing a pattern (a regular expression).
Initialize a Pattern.
Parameters:
-
pattern(str | Pattern) –Str or Pattern object representing a regular expressions. It must be compatible with re.compile method.
filter
filter(strings)
Return a boolean mask for strings matching the pattern.
Parameters:
-
strings(list[str]) –Strings to filter.
Returns:
-
matches–Numpy array of bool type.
match
match(string)
Verify if the pattern matches the string (at any place).
scores
scores(strings, labels, full_labels_list=None)
Calculate classification quality scores for pattern's matches and the labels.
Pattern's matches are considered as "predictions" when calculating quality metrics.
Parameters:
-
strings(list[str]) –A list of strings.
-
labels(list[int]) –A list of strings labels.
-
full_labels_list(list[int], default:None) –A full list of unique labels that can be present among labels.
Returns:
-
response(dict) –Contains keys: 'n_strings', 'total_positive', 'n_matches', 'precision', 'recall' and 'accuracy'. If there are more than 2 classes, each key is a list corresponding to each class.