Is there any way to get a list of the patterns in a PhraseMatcher? For example, if I added the patterns abc, def, efg to a matcher, is there a way I can list out those patterns? Or even just check if abc is a pattern in the matcher?
Is there any way to get a list of the patterns in a PhraseMatcher? For example, if I added the patterns abc, def, efg to a matcher, is there a way I can list out those patterns? Or even just check if abc is a pattern in the matcher?
For PhraseMatcher specifically the internal list of rules is not exposed, but __contains__ is implemented so you can do this:
matcher.add("abc", ...)
"abc" in matcher # => True
Out of curiosity what are you checking for? In my experience with the matchers usually they're just set up and used without being passed around much, I kind of have trouble imagining a situation where you'd use this feautre.