liebeck / spacy-sentiws Goto Github PK
View Code? Open in Web Editor NEWGerman sentiment scores with SentiWS as extension for spaCy
License: MIT License
German sentiment scores with SentiWS as extension for spaCy
License: MIT License
pip install spacy-sentiws installs an older version where it is not compatible with the spacy 3. How can I get this git repo in pip installation?
Hey @Liebeck,
Thanks for this extension, I'm currently digging into using spaCy for a university project working on a sentiment analysis. I just made my first steps and have a working spaCy installation using 'de_core_news_lg' as model and 'spacy_sentiws' as an extension.
See this sample:
"Ich bin stark. Die Digitalisierung begegnet uns überall – und hat die Art, wie wir arbeiten und leben, stark verändert."
Ich, None, PRON
bin, None, AUX
stark, None, ADV
., None, PUNCT
Die, None, DET
Digitalisierung, None, NOUN
begegnet, None, VERB
uns, None, PRON
überall, None, ADV
–, None, PUNCT
und, None, CCONJ
hat, None, VERB
die, None, DET
Art, None, NOUN
,, None, PUNCT
wie, None, SCONJ
wir, None, PRON
arbeiten, None, VERB
und, None, CCONJ
leben, None, VERB
,, None, PUNCT
stark, None, ADV
verändert, None, VERB
., None, PUNCT
Why is "stark" always recognized as an adverb and why doesn't it get a SentiWS value at all? If I look into it should get a value of 0.0040 (stark|ADJX 0.0040).
Thanks,
Dia
Hi,
I've followed your instruction, but got an error msg: set_extension() got an unexpected keyword argument 'force'
Can you pls help me with that?
import spacy
from spacy_sentiws import spaCySentiWS
nlp = spacy.load('de_core_news_sm')
nlp.add_pipe('sentiws', config={'sentiws_path': 'data/sentiws/'})
ValueError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_9632\291549605.py in
3
4 nlp = spacy.load('de_core_news_sm')
----> 5 nlp.add_pipe('sentiws', config={'sentiws_path': 'data/sentiws/'})
~\PythonProgramming\Anaconda\lib\site-packages\spacy\language.py in add_pipe(self, factory_name, name, before, after, first, last, source, config, raw_config, validate)
799 lang_code=self.lang,
800 )
--> 801 pipe_component = self.create_pipe(
802 factory_name,
803 name=name,
~\PythonProgramming\Anaconda\lib\site-packages\spacy\language.py in create_pipe(self, factory_name, name, config, raw_config, validate)
659 lang_code=self.lang,
660 )
--> 661 raise ValueError(err)
662 pipe_meta = self.get_factory_meta(factory_name)
663 # This is unideal, but the alternative would mean you always need to
ValueError: [E002] Can't find factory for 'sentiws' for language German (de). This usually happens when spaCy calls nlp.create_pipe
with a custom component name that's not registered on the current language class. If you're using a Transformer, make sure to install 'spacy-transformers'. If you're using a custom component, make sure you've added the decorator @Language.component
(for function components) or @Language.factory
(for class components).
Available factories: attribute_ruler, tok2vec, merge_noun_chunks, merge_entities, merge_subtokens, token_splitter, doc_cleaner, parser, beam_parser, lemmatizer, trainable_lemmatizer, entity_linker, ner, beam_ner, entity_ruler, tagger, morphologizer, senter, sentencizer, textcat, spancat, future_entity_ruler, span_ruler, textcat_multilabel
Spacy 3 is not supported: https://spacy.io/usage/v3#migrating-add-pipe
When trying to execute i get this exception:
>>> nlp = spacy.load("de_core_news_md")
>>> sentiws = spaCySentiWS(sentiws_path="...")
>>> nlp.add_pipe(sentiws)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\...\.conda\envs\jw\lib\site-packages\spacy\language.py", line 754, in add_pipe
raise ValueError(err)
ValueError: [E966] `nlp.add_pipe` now takes the string name of the registered component factory, not a callable component. Expected string, but got <spacy_sentiws.spaCySentiWS object at 0x000001DD854C0B20> (name: 'None').
- If you created your component with `nlp.create_pipe('name')`: remove nlp.create_pipe and call `nlp.add_pipe('name')` instead.
- If you passed in a component like `TextCategorizer()`: call `nlp.add_pipe` with the string name instead, e.g. `nlp.add_pipe('textcat')`.
- If you're using a custom component: Add the decorator `@Language.component` (for function components) or `@Language.factory` (for class components / factories) to your custom component and assign it a name, e.g. `@Language.component('your_name')`. You can then run `nlp.add_pipe('your_name')` to add it to the pipeline.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.