Skip to content

Commit

Permalink
Remove duplicate productions in CNF for CFGs (nltk#2435)
Browse files Browse the repository at this point in the history
Co-authored-by: Steven Bird <[email protected]>
  • Loading branch information
Daksh and stevenbird authored Dec 23, 2020
1 parent b4e6868 commit 4881fff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@
- Nicolas Darr <https://github.com/ndarr>
- Hervé Nicol <https://github.com/hervenicol>
- Alexandre H. T. Dias <https://github.com/alexandredias3d>
- Daksh Shah <https://github.com/Daksh>
- Jacob Weightman <https://github.com/jacobdweightman>
- Bonifacio de Oliveira <https://github.com/Bonifacio2>
- Armins Bagrats Stepanjans <https://github.com/ab-10>
Expand Down
3 changes: 2 additions & 1 deletion nltk/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,8 @@ def chomsky_normal_form(self, new_token_padding="@$@", flexible=False):
if flexible:
return step2
step3 = CFG.remove_unitary_rules(step2)
return step3
step4 = CFG(step3.start(),list(set(step3.productions())))
return step4

@classmethod
def remove_unitary_rules(cls, grammar):
Expand Down

0 comments on commit 4881fff

Please sign in to comment.