Closed sam-writer closed 3 years ago
hmmm, sorter in confidence is throwing exceptions when the match occurs at the beginning of the string.
seems like some spaCy change (or replaCy change?) has introduced a lot of bugs
>>> from service_confidence.matcher import Confidence
>>> import en_core_web_sm
>>> nlp = en_core_web_sm.load()
>>> c = Confidence(nlp)
>>> c("The way I see it, this is bad")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/sh/q/repos/service.confidence/service_confidence/matcher.py", line 62, in __call__
return self.replace_matcher(doc)
File "/Users/sh/Library/Caches/pypoetry/virtualenvs/service.confidence-HAQAov7T-py3.8/lib/python3.8/site-packages/replacy/__init__.py", line 318, in __call__
self.spans = component(self.spans)
File "/Users/sh/Library/Caches/pypoetry/virtualenvs/service.confidence-HAQAov7T-py3.8/lib/python3.8/site-packages/replacy/scorer.py", line 102, in sort_suggestions
span._.suggestions = sorted(
File "/Users/sh/Library/Caches/pypoetry/virtualenvs/service.confidence-HAQAov7T-py3.8/lib/python3.8/site-packages/replacy/scorer.py", line 104, in <lambda>
key=lambda x: self.score_suggestion(
File "/Users/sh/Library/Caches/pypoetry/virtualenvs/service.confidence-HAQAov7T-py3.8/lib/python3.8/site-packages/replacy/scorer.py", line 96, in score_suggestion
text = " ".join([doc[: span.start].text] + suggestion + [doc[span.end :].text])
File "span.pyx", line 503, in spacy.tokens.span.Span.text.__get__
File "span.pyx", line 190, in spacy.tokens.span.Span.__getitem__
IndexError: [E201] Span index out of range.
relevant match
{
"the_way_i_see_it": {
"patterns": [
{
"ORTH": ",",
"OP": "?"
},
{
"LOWER": "the"
},
{
"LOWER": "way",
"DEP": {
"NOT_IN": [
"dobj"
]
}
},
{
"LOWER": {
"IN": [
"i",
"we"
]
}
},
{
"LOWER": "see"
},
{
"LOWER": {
"IN": [
"it",
"things"
]
}
},
{
"ORTH": ",",
"OP": "?"
},
{
"ORTH": "is",
"OP": "?"
},
{
"ORTH": "that",
"OP": "?"
}
],
"suggestions": [
[
{
"TEXT": {
"IN": [
"",
","
]
},
"MAX_COUNT": 2
}
]
],
"test": {
"positive": [
"Some may say that chipboard should not be used in a 'wet' boat, but the way I see it, if the inside gets wet, there are bigger problems than exploded chipboard veneer on the kitchen units!!!!!.",
"Well Gordon, the way I see it is that there are millions of people in the world and we can't be friends with them all.",
"Yes, the way I see it, if I didn't take it, you know.",
"Best thing that could happen, the way I see it.",
"I'm telling it the way I see it, from an outsider's perspective.",
"Kryten, the way I see it, the only difference between a friend and a girlfriend is that you have sex with one and not the other.",
"It speaks on so many levels, the way I see it: not just as one lover to another, but as self to self and the Divine to the human/vice versa.",
"That's the way I see it, \" was Karen's doggedly repeated bottom line, \" and nothing you say is going to make me change.",
"OK, the way I see it.",
"So the way I see it, this is a case where a particular piece of regulation is not evil, but simply ineffective in and of itself.",
"They must, the way I see it, explain why they have been quiet all those years when the Iraqi regime was killing millions in Iraq.",
"Oh, that's the way I see it,\" he says.",
"That removes it a bit from the McCarthy era, the way I see it.",
"We are going to write some matches in this file, the way I see things.",
"This is, very roughly, the way I see it.",
"At least that's the way I see it, Williams said.",
"So the way I see it, although being with a Christian partner can make it easier to serve God, all the same, God loves and accepts everyone, including non-Christians.",
"The way I see things, we are going to write some matches in this file.",
"From the way I see it, this matter is similar to the Muslims view of the Bible.",
"This is the way I see it, anyway from what I read.",
"I know someone has to worry about how this industry is going to make money, but the way I see it, thats up to the publishers.",
"So to conclude, the way I see it capping is a bad thing and the government must step in to ban it or Oftel should fine the ISPs for doing it.",
"But the way I see it, women are most definitely writing horror, and people are reading it.",
"Derek: I think, for me, the way I see it is that they are both related because theyre both part of overall user experience.",
"Basically, the way I see it, is that choice does not equal liberty if one cannot make a rational choice.",
"The first round, the way I see it, is a decontamination chamber for the truly playoff worthy, a week of working out the kinks.",
"Let's assume for a moment, that supernatural things can cause effects in the natural world (the way I see it, they can't by definition, but for the sake of argument, let's assume they can ).",
"We havent been given any infant milk powder but I will ask for it when we see the Dr next week and will also ask him for the Lactaid drops, the way I see it it has got to be worth a try.",
"Although it seems a million miles from being a miner, the way I see it is that when you worked pits as a fitter, the men's lives depended on you.",
"User Ok IT is fair to say that this game has got great visuals and is easy to pick up the controller and play, although the game is very repetitive, the way I see it, the ball just goes back and forth until someone hits a winner, it just goes on and on and on.",
"As regards the wiring well, the way I see it is you could just have an extension lead going through a hole in the wall from the main house.",
"Well, when it comes to pudding, the way I see it with cheesecake you've got a choice: Either EAT it or BE it.",
"Now the way I see it, you want more upmarket time than the plebs.",
"But the way I see it, that is not a bad thing when the obesity surveys show that Brits are the new Americans.",
"Well, I, I, the way I see it going is that the E C will expand to not only Lithuania about being but also other, other, er forms of Soviet Republics."
],
"negative": [
"This doesn't change the way I see things, but it might."
]
}
},
}
no matches work at start or end
>>> c("personally, I like this")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/sh/q/repos/service.confidence/service_confidence/matcher.py", line 62, in __call__
return self.replace_matcher(doc)
File "/Users/sh/Library/Caches/pypoetry/virtualenvs/service.confidence-HAQAov7T-py3.8/lib/python3.8/site-packages/replacy/__init__.py", line 318, in __call__
self.spans = component(self.spans)
File "/Users/sh/Library/Caches/pypoetry/virtualenvs/service.confidence-HAQAov7T-py3.8/lib/python3.8/site-packages/replacy/scorer.py", line 102, in sort_suggestions
span._.suggestions = sorted(
File "/Users/sh/Library/Caches/pypoetry/virtualenvs/service.confidence-HAQAov7T-py3.8/lib/python3.8/site-packages/replacy/scorer.py", line 104, in <lambda>
key=lambda x: self.score_suggestion(
File "/Users/sh/Library/Caches/pypoetry/virtualenvs/service.confidence-HAQAov7T-py3.8/lib/python3.8/site-packages/replacy/scorer.py", line 96, in score_suggestion
text = " ".join([doc[: span.start].text] + suggestion + [doc[span.end :].text])
File "span.pyx", line 503, in spacy.tokens.span.Span.text.__get__
File "span.pyx", line 190, in spacy.tokens.span.Span.__getitem__
IndexError: [E201] Span index out of range.
>>> c("this is offenseive personally,")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/sh/q/repos/service.confidence/service_confidence/matcher.py", line 62, in __call__
return self.replace_matcher(doc)
File "/Users/sh/Library/Caches/pypoetry/virtualenvs/service.confidence-HAQAov7T-py3.8/lib/python3.8/site-packages/replacy/__init__.py", line 318, in __call__
self.spans = component(self.spans)
File "/Users/sh/Library/Caches/pypoetry/virtualenvs/service.confidence-HAQAov7T-py3.8/lib/python3.8/site-packages/replacy/scorer.py", line 102, in sort_suggestions
span._.suggestions = sorted(
File "/Users/sh/Library/Caches/pypoetry/virtualenvs/service.confidence-HAQAov7T-py3.8/lib/python3.8/site-packages/replacy/scorer.py", line 104, in <lambda>
key=lambda x: self.score_suggestion(
File "/Users/sh/Library/Caches/pypoetry/virtualenvs/service.confidence-HAQAov7T-py3.8/lib/python3.8/site-packages/replacy/scorer.py", line 96, in score_suggestion
text = " ".join([doc[: span.start].text] + suggestion + [doc[span.end :].text])
File "span.pyx", line 503, in spacy.tokens.span.Span.text.__get__
File "span.pyx", line 190, in spacy.tokens.span.Span.__getitem__
IndexError: [E201] Span index out of range.
>>> c("this is offensive, personally")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/sh/q/repos/service.confidence/service_confidence/matcher.py", line 62, in __call__
return self.replace_matcher(doc)
File "/Users/sh/Library/Caches/pypoetry/virtualenvs/service.confidence-HAQAov7T-py3.8/lib/python3.8/site-packages/replacy/__init__.py", line 318, in __call__
self.spans = component(self.spans)
File "/Users/sh/Library/Caches/pypoetry/virtualenvs/service.confidence-HAQAov7T-py3.8/lib/python3.8/site-packages/replacy/scorer.py", line 102, in sort_suggestions
span._.suggestions = sorted(
File "/Users/sh/Library/Caches/pypoetry/virtualenvs/service.confidence-HAQAov7T-py3.8/lib/python3.8/site-packages/replacy/scorer.py", line 104, in <lambda>
key=lambda x: self.score_suggestion(
File "/Users/sh/Library/Caches/pypoetry/virtualenvs/service.confidence-HAQAov7T-py3.8/lib/python3.8/site-packages/replacy/scorer.py", line 96, in score_suggestion
text = " ".join([doc[: span.start].text] + suggestion + [doc[span.end :].text])
File "span.pyx", line 503, in spacy.tokens.span.Span.text.__get__
File "span.pyx", line 190, in spacy.tokens.span.Span.__getitem__
IndexError: [E201] Span index out of range.
>>> c("this is offensive, personally, you know")
[ personally,]
preceded_by_phrase
returns true if the match is at the beginning of the sentence (which cannot be correct)succeeded_by_phrase
returns true if the match is at the end of the sentence (which cannot be correct)using version
0.49.0
of replacy