Best Usage of Document Object
Here is a quick question regarding how you would recommend leveraging the document object in this scenario:
We are receiving HTML email documents, and wish the original document to contain all html tags and metadata. However, we want spacy to iterate and perform linguistic analysis of spans that ignore these annotations.
I see two possible approaches:
- We maintain a set of offsets from a doc object to an original html document. Needing to create a bunch of infrastructure to maintain alignment etc.
- Somehow force SpaCy to perform linguistic analysis over an abstraction of the doc, treating the abstraction as a series of tokens.
I am coming at this from the perspective of a UIMA user in the past :) https://uima.apache.org
What would be the consensus? Thanks!
I think you want to extract the text and get the alignment into it of the original markup. Once you've done that, you can add the information as extension attributes, which might return Span objects for easy usability.
You probably want to customize the make_doc method, so that you can do your text extraction first, then you make your Doc object with the tokenizer, and then you can add the extension attributes.
It might seem painful to do the alignment, but it should only take an afternoon to write that code. It's a pure function, after all --- it doesn't touch or reference any system state. So it's pretty easy to test. Then once it's done you can forget about the markup and everything will work smoothly.
Thanks Matthew, that was my intuition as well. Will look into sharing the code back with you in case you want to add an html alignment option to doc at some point...
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.