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

Assert that locations are not empty #5

Merged

Conversation

konstin
Copy link
Contributor

@konstin konstin commented Apr 16, 2018

Before that an empty locations list would raise some weird pyahocorasick error about a value not being an automaton

Before that an empty locations list would raise some weird pyahocorasick error about a value not being an automaton
@coveralls
Copy link

coveralls commented Apr 16, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling 435b85f on meine-stadt-transparent:non_empty_locations into 38b7526 on stadt-karlsruhe:master.

Copy link
Contributor

@torfsen torfsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! There's a small change that I'd like to see. In addition, please add a corresponding test case to the TestNameExtractor class.


if not list(self._automaton.items()):
raise ValueError("You must provide locations for extraction")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with adding this check, but it should be done at the end of NameExtractor.setup instead. At that point, no further words will be added to the automaton.

@torfsen torfsen merged commit 18916c1 into stadt-karlsruhe:master Apr 17, 2018
@torfsen
Copy link
Contributor

torfsen commented Apr 17, 2018

Thanks for your contribution, @konstin!

@torfsen
Copy link
Contributor

torfsen commented Apr 17, 2018

In hindsight, I think the better approach is to simply return no matches from NameExtractor.extract in case the locations list was empty. This is consistent with the expected behavior, doesn't raise any exceptions and doesn't require special code in tests, etc. to avoid an empty locations list.

I've made this change in 0d184e2.

@konstin konstin deleted the non_empty_locations branch April 17, 2018 13:07
@konstin
Copy link
Contributor Author

konstin commented Apr 17, 2018

Ah great, that makes it even easier to use!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants