mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-24 17:06:29 +03:00
* Replace deprecated repvec reference in twitter-filter
This commit is contained in:
parent
f56209ef2e
commit
36517516ef
|
@ -80,10 +80,10 @@ include ./meta.jade
|
||||||
|
|
|
|
||||||
| def match_tweet(spacy, text, query):
|
| def match_tweet(spacy, text, query):
|
||||||
| def get_vector(word):
|
| def get_vector(word):
|
||||||
| return spacy.vocab[word].repvec
|
| return spacy.vocab[word].vector
|
||||||
|
|
|
|
||||||
| tweet = spacy(text)
|
| tweet = spacy(text)
|
||||||
| tweet = [w.repvec for w in tweet if w.is_alpha and w.lower_ != query]
|
| tweet = [w.vector for w in tweet if w.is_alpha and w.lower_ != query]
|
||||||
| if tweet:
|
| if tweet:
|
||||||
| accept = map(get_vector, 'Jeb Cheney Republican 9/11h'.split())
|
| accept = map(get_vector, 'Jeb Cheney Republican 9/11h'.split())
|
||||||
| reject = map(get_vector, 'garden Reggie hairy'.split())
|
| reject = map(get_vector, 'garden Reggie hairy'.split())
|
||||||
|
@ -147,11 +147,11 @@ include ./meta.jade
|
||||||
pre.language-python: code
|
pre.language-python: code
|
||||||
| def handle_tweet(spacy, resp, query):
|
| def handle_tweet(spacy, resp, query):
|
||||||
| def get_vector(word):
|
| def get_vector(word):
|
||||||
| return spacy.vocab[word].repvec
|
| return spacy.vocab[word].vector
|
||||||
|
|
|
|
||||||
| text = resp.get('text', '').decode('utf8')
|
| text = resp.get('text', '').decode('utf8')
|
||||||
| tweet = spacy(text)
|
| tweet = spacy(text)
|
||||||
| tweet = [w.repvec for w in tweet if w.is_alpha and w.lower_ != query]
|
| tweet = [w.vector for w in tweet if w.is_alpha and w.lower_ != query]
|
||||||
| if tweet:
|
| if tweet:
|
||||||
| accept = map(get_vector, 'Jeb Cheney Republican 9/11h'.split())
|
| accept = map(get_vector, 'Jeb Cheney Republican 9/11h'.split())
|
||||||
| reject = map(get_vector, 'garden Reggie hairy'.split())
|
| reject = map(get_vector, 'garden Reggie hairy'.split())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user