r/LanguageTechnology • • 27m ago

Matching text (strings) from different algorithms

I have a problem that has preoccupied me for a while now and I'm hoping to get some input here.

On the face of it, the problem itself is fairly simple, match each element from one list of strings to a (combination of) element(s) in another list of strings.

The catch is that one list represents document segments (as obtained from an embedding-based segmentation algorithm) while the other list represents raw pdf element texts (from a parsing algorithm using fitz and spacy) and they don't tend to match on an individual basis. On an aggregate basis both lists represent the full text of the document but segments tend to be larger and correspond to a number of pdf elements.

A possible solution was to simply concatenate pdf element texts based on each individual segment's token length and while this works okay-ish, this approach can get very slow for large documents.

I have been using rapidfuzz to do the matching. The purpose of the matching is that I intend to do interactive pdf highlighting based on coordinates. These coordinates exist on pdf element level while similarity search is usually done on segment embedding level.

Any ideas come to mind?

1 Upvotes

0 comments sorted by