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

Convert document context information when importing a table from Watson Discovery #121

Open
frreiss opened this issue Sep 15, 2020 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@frreiss
Copy link
Member

frreiss commented Sep 15, 2020

The output of Watson Discovery's Table Understanding contains information about the area of the document where the table resides. Specifically, the following keys are present in the JSON returned:

  • "location" --> Span of the table in the converted HTML version of the document
  • "section_title" --> Span of the title of the section containing the table in the converted HTM
  • "contexts" --> Spans of key phrases appearing near the table

Currently, the we make limited use of these spans. We use the text "section_title" for identifying a single table when the user passes the select_table argument to io.watson.tables.parse_response(). And parse_response() returns the character offsets from the "location" span as a Python tuple of integers. The contents of "contexts" are not processed.

io.watson.tables.parse_response() should convert all of this context information into Text Extensions for Pandas data structures. I recommend returning a single DataFrame "context" containing two columns: "context_type" (string that can be "location", "section_title" or "contexts"), and "span" (SpanArray of spans into the HTML representation of the document).

Note: We have seen some issues with character offsets not lining up between the spans returned by Table Understanding and the converted HTML returned by Table Understanding. We should fix those issues if possible. If it's not possible to get accurate character offsets, then I recommend replacing the "span" column in the above design with a Pandas Interval plus a string. Make sure to document why the spans are returned this way if you use this workaround.

@frreiss frreiss added enhancement New feature or request good first issue Good for newcomers labels Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant