Extending the SpanRuler to support more than just label and id #13554
NixBiks
started this conversation in
Help: Best practices
Replies: 1 comment
-
A helpful extension would be the ability to set extension attributes to the span when proving a pattern ruler.add_patterns([
{
"label": "GPE",
"pattern": "Apple",
"_": {
"custom_attribute": {"name": "John Doe"},
},
}
]) Then I could access that via |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I wonder if there is an easy way to extend the SpanRuler to allow for more fields than just label and id.
I have a use case where I want to extract amounts into structured data. E.g. a phrase like
5,123 mEUR
can be matched using a pattern but then I'd like to apply some function to it as well where I provide a regex showing where the number is, where the multiplier is and where the currency is.I solved this in the past with a solution with my own
SecondOpinonRuler
where I extendSpanRuler
component and overrideadd_patterns
andmatch
methods, basically to add an additional key inself._match_label_id_map
dict values. But I feel like there might be a smarter way with less to maintain. Any thoughts?Beta Was this translation helpful? Give feedback.
All reactions