How to get DependencyMatcher results as Span? #10406
-
Greetings all, I am trying work with multiple patterns on DependencyMatcher applied on a single doc. I would like to know if it is possible to get matcher returns as Span? For instance;
So the question is how to get to span from here? More specifically how to get each sentence matched with each pattern? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
The DependencyMatcher doesn't return spans because there's no guarantee that it will match a contiguous string of tokens. For example, your third match there has tokens 19, 20, 21, and 24 - there's a gap. A simple thing you can do is take the highest and lowest token index in the returned match and use that to create a span. To get the sentence a match is in, you can use the |
Beta Was this translation helpful? Give feedback.
-
I gave up the idea of using DependencyMatcher to TokenMatcher. TokenMatcher is much easier :) |
Beta Was this translation helpful? Give feedback.
I gave up the idea of using DependencyMatcher to TokenMatcher. TokenMatcher is much easier :)