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

more robust table extraction #767

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

unsleepy22
Copy link
Contributor

Refine table extraction and add more test cases.

@unsleepy22 unsleepy22 force-pushed the refine-table-extraction branch from a42df23 to c510ac5 Compare December 13, 2024 16:08
Copy link

codecov bot commented Dec 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.27%. Comparing base (b010779) to head (02be8b2).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #767   +/-   ##
=======================================
  Coverage   99.27%   99.27%           
=======================================
  Files          21       21           
  Lines        3576     3587   +11     
=======================================
+ Hits         3550     3561   +11     
  Misses         26       26           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

trafilatura/utils.py Outdated Show resolved Hide resolved
@adbar
Copy link
Owner

adbar commented Dec 18, 2024

@unsleepy22 Thanks for the PR, everything looks OK to me but the code could be improved using the suggestions above.

@unsleepy22
Copy link
Contributor Author

@unsleepy22 Thanks for the PR, everything looks OK to me but the code could be improved using the suggestions above.

Thanks for your comments, updated accordingly, would you take a look again?


def is_in_table_cell(elem: _Element) -> bool:
'''Check whether an element is in a table cell'''
return elem.xpath('//ancestor::cell')
Copy link
Owner

Choose a reason for hiding this comment

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

@unsleepy22 The .xpath method returns a list of elements or [], the type annotation is not correct and since we don't need the list it's useless to return it, I suggest using return bool(elem.xpath(...)).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you're right, type check didn't find this one.

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.

2 participants