Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unsupported argument minimize from additional parameters in Python binding #469

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading