Skip to content

Commit

Permalink
fix(bindings/python): Remove unsupported argument minimize from add…
Browse files Browse the repository at this point in the history
…itional params
  • Loading branch information
Adda0 authored and hiraethese committed Dec 19, 2024
1 parent d44f1df commit f63531c
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions bindings/python/libmata/nfa/nfa.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -923,21 +923,24 @@ def concatenate_with_result_state_maps(Nfa lhs, Nfa rhs, use_epsilon: bool = Fal
return result, lhs_map, rhs_map


def complement(Nfa lhs, alph.Alphabet alphabet, params = None):
"""Performs complement of lhs
:param Nfa lhs: complemented automaton
:param OnTheFlyAlphabet alphabet: alphabet of the lhs
:param dict params: additional params
- "algorithm": "classical" (classical algorithm determinizes the automaton, makes it complete and swaps final and non-final states);
- "minimize": "true"/"false" (whether to compute minimal deterministic automaton for classical algorithm);
:return: complemented automaton
def complement(Nfa nfa, alph.Alphabet alphabet, params = None):
"""Computes the complement of the nfa.
:param Nfa nfa: The automaton to complement.
:param OnTheFlyAlphabet alphabet: The alphabet of the nfa.
:param dict params: Additional parameters.
- "algorithm":
- "classical": The classical algorithm determinizes the automaton, makes it complete and swaps final and
non-final states.
- "brzozowski": The Brzozowski algorithm determinizes the automaton using Brzozowski minimization, makes it
complete, and swaps final and non-final states.
:return: The complemented automaton.
"""
result = Nfa()
params = params or {'algorithm': 'classical', 'minimize': 'false'}
params = params or {'algorithm': 'classical'}
mata_nfa.c_complement(
result.thisptr.get(),
dereference(lhs.thisptr.get()),
dereference(nfa.thisptr.get()),
<CAlphabet&>dereference(alphabet.as_base()),
{
k.encode('utf-8'): v.encode('utf-8') if isinstance(v, str) else v
Expand Down

0 comments on commit f63531c

Please sign in to comment.