-
Notifications
You must be signed in to change notification settings - Fork 273
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
ZeroDivisionError when training with zero-length data #49
Comments
This is the reason for the error. return float(len(text)) / len(fdata) - (1e-6 * fragment.start) If the float that is being returned is inversely proportional to length of fdata, can we just write this.? fdata = page.fragment_data(fragment).strip()
if text in fdata:
if not len(fdata):
return float("inf")
return float(len(text)) / len(fdata) - (1e-6 * fragment.start)
else:
return 0.0
return func |
This isn't a wacky edge-case at all. I got the same error using actual data and had to patch it. |
Same here, I reproduced this error using regular, non-empty data. |
marekyggdrasil
added a commit
to marekyggdrasil/scrapely
that referenced
this issue
Nov 27, 2019
ruairif
added a commit
that referenced
this issue
Nov 28, 2019
patch for issue #49 and fixed Travis tests
the patch has been merged, I believe this issue can be closed? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(Minor bug.)
I installed scrapely from pip this morning.
This is a wacky edge case, but I think you could raise a more constructive error.
(Who wants to extract a zero-length string from a document? It's a bit like a magician pulling some atmosphere out of a hat: it's always going to be there...)
Check it out:
The text was updated successfully, but these errors were encountered: