MoseleyBioinformaticsLab / academic_tracker

Academic Tracker is a package that can search PubMed, Crossref, ORCID, and Google Scholar for publications given a list of authors or publication citations.
https://moseleybioinformaticslab.github.io/academic_tracker/
Other
14 stars 5 forks source link

Divide by zero error #5

Closed ianzur closed 4 months ago

ianzur commented 4 months ago

https://github.com/MoseleyBioinformaticsLab/academic_tracker/blob/aeec3103185f1dd5385a2c762b8d8589b036f06b/src/academic_tracker/helper_functions.py#L688

prev_citation = 'Chmielewski M, Abken H, Can. Immunol. Immunother 2012, 61, 1269–1277.'
new_citation = '\xa0' 

The citation string inputs to this function may contain only whitespace \xa0 characters. I do not know how this happens and this may be a configuration issue. The .strip() call removes the whitespace resulting in divide by zero.

I think the citation string should be sanitized/normalized before adding to dictionary. Otherwise, I can remove the print statements from the check I added and merge.

https://github.com/MoseleyBioinformaticsLab/academic_tracker/compare/main...ianzur:academic_tracker:citation-common-phrase-div-by-zero?expand=1

Thank you, Ian

ptth222 commented 4 months ago

Thanks for posting this issue and a solution! This looks like an acceptable improvement to me. Yes, remove the print statements and extra blank lines. Can I get you to modify the doc string as well?

Change "If either citation is None, then return None." to "If either citation is None or empty after character removal and stripping, then return None."

As for sanitation, we just try to return what the source gives us.