pattern_clustering.pattern_automaton.PatternAutomaton
- class PatternAutomaton(word: str, map_name_dfa: dict, make_mg: Optional[callable] = None, filtered_patterns: Optional[set] = None)[source]
Bases:
AutomatonA
PatternAutomatonmodels a string at the pattern level using a automaton-like structure where each vertex corresponds to a string index; each arc corresponds to an infix and its corresponding pattern.Constructs the
PatternAutomatonrelated to an input word according to a collection of patterns and according to amulti_grepstrategy.- Parameters
word (str) – The input string.
map_name_dfa (dict) – The pattern collection mapping each pattern name (
str) with its correspondingAutomatoninstance. The"any"pattern is always ignored.filtered_patterns (set) – A subset (possibly empty) of
map_name_dfa.keys()keying the types that must be caught mymulti_grep, but not appearing in the arcs involved in thePatternAutomaton. It may be used for instance to drop spaces and get a smallerPatternAutomaton, but the position of spaces in the original lines will be lost.
Methods
acceptsadd_edgeadd_vertexalphabetdeltadelta_wordRetrieve the edge from a vertex u to vertex v.
edgesfinalsRetrieves the infix (substring) related to an edge.
Retrieves the slice (pair of uint indices delimiting a substring) related to an edge.
has_edgehas_vertexin_edgesinitialis_completeis_deterministicis_finalis_finiteis_initiallabelnum_edgesnum_verticesout_edgesremove_edgeremove_vertexset_finalset_initialsigmasourcetargetto_dotverticesAttributes
adjacenciesdirected- edge(q: int, r: int, a: chr) tuple
Retrieve the edge from a vertex u to vertex v. :param u: The source of the edge. :param v: The target of the edge.
- Returns
(e, True) if it exists a single edge from u to v, (None, False) otherwise.