You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+23-7Lines changed: 23 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,30 @@
1
-
# Contiributing
1
+
# Contributing
2
2
3
-
spaCyTextBlob is happy to accept contributions from the community. Please review the guidelines below.
3
+
*spacytextblob* is happy to accept contributions from the community. Please review the guidelines below.
4
+
5
+
## Development environment
6
+
7
+
### poetry
8
+
9
+
`poetry` is used to manage python dependencies. See the docs on how to install python [https://python-poetry.org/](https://python-poetry.org/). To activate the poetry virtual environment run the following commands:
10
+
11
+
```bash
12
+
poetry install
13
+
poetry shell
14
+
```
15
+
16
+
### just
17
+
18
+
`just` is used to run scripts. See the just docs for instructions on how to install: [https://github.com/casey/just](https://github.com/casey/just).
4
19
5
20
## Code formatting
6
21
7
22
Please use the [black](https://black.readthedocs.io/en/stable/) for formatting code before submitting a PR.
8
23
24
+
```bash
25
+
black spacytextblob
26
+
```
27
+
9
28
## Testing
10
29
11
30
Please validate that all tests pass before submitting a PR by running:
@@ -16,11 +35,8 @@ pytest
16
35
17
36
## Docs
18
37
19
-
To build the docs please run:
38
+
To build the docs and visually inspect the docs please run:
20
39
21
40
```bash
22
-
bash scripts/build_docs.sh
41
+
just docs
23
42
```
24
-
25
-
If you add new documentation using a jupyter notebook please make sure to update [scripts/build_docs.sh](scripts/build_docs.sh) to include the new notebook.
A TextBlob sentiment analysis pipeline compponent for spaCy.
10
-
11
-
Version 3.0 is a major version update providing support for spaCy 3.0's new interface for adding pipeline components. As a result, it is not backwards compatible with previous versions of spaCyTextBlob. For compatability with spaCy 2.0 please use `pip install spacytextblob==0.1.7`.
12
-
13
-
*Note that version 1.0, and 2.0 have been skipped. The numbering has been aligned with spaCy's version numbering in the hopes of making it easier to compar.*
8
+
A TextBlob sentiment analysis pipeline component for spaCy.
@@ -25,119 +20,87 @@ Version 3.0 is a major version update providing support for spaCy 3.0's new inte
25
20
26
21
## Install
27
22
28
-
Install spaCyTextBlob from pypi.
23
+
Install *spacytextblob* from PyPi.
29
24
30
25
```bash
31
26
pip install spacytextblob
32
27
```
33
28
34
-
TextBlob also requires some data to be downloaded before getting started.
29
+
TextBlob requires additional data to be downloaded before getting started.
35
30
36
31
```bash
37
32
python -m textblob.download_corpora
38
33
```
39
34
40
-
spaCy requires that you download a model to get started.
35
+
spaCy also requires that you download a model to get started.
41
36
42
37
```bash
43
38
python -m spacy download en_core_web_sm
44
39
```
45
40
46
41
## Quick Start
47
42
48
-
spaCyTextBlob allows you to access all of the attributes created by TextBlob sentiment method but within the spaCy framework. The code below will demonstrate how to use spaCyTextBlob on a simple string.
49
-
50
-
51
-
```python
52
-
text ="I had a really horrible day. It was the worst day ever! But every now and then I have a really good day that makes me happy."
53
-
```
54
-
55
-
Using `spaCyTextBlob`:
56
-
43
+
*spacytextblob* allows you to access all of the attributes created of the `textblob.TextBlob` class but within the spaCy framework. The code below will demonstrate how to use *spacytextblob* on a simple string.
57
44
58
45
```python
59
46
import spacy
60
47
from spacytextblob.spacytextblob import SpacyTextBlob
61
48
62
49
nlp = spacy.load('en_core_web_sm')
50
+
text ="I had a really horrible day. It was the worst day ever! But every now and then I have a really good day that makes me happy."
spaCyTextBlob performs sentiment analysis using the [TextBlob](https://textblob.readthedocs.io/en/dev/quickstart.html) library. Adding spaCyTextBlob to a spaCy nlp pipeline provides access to three new extension attributes.
84
+
*spacytextblob* performs sentiment analysis using the [TextBlob](https://textblob.readthedocs.io/en/dev/quickstart.html) library. Adding *spacytextblob* to a spaCy nlp pipeline creates a new extension attribute for the `Doc`, `Span`, and `Token` classes from spaCy.
85
+
86
+
-`Doc._.blob`
87
+
-`Span._.blob`
88
+
-`Token._.blob`
126
89
127
-
-`._.polarity`
128
-
-`._.subjectivity`
129
-
-`._.assessments`
90
+
The `._.blob` attribute contains all of the methods and attributes that belong to the `textblob.TextBlob` class Some of the common methods and attributes include:
130
91
131
-
These extension attributes can be accessed at the `Doc`, `Span`, or `Token` level.
92
+
-**`._.blob.polarity`**: a float within the range [-1.0, 1.0].
93
+
-**`._.blob.subjectivity`**: a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective.
94
+
-**`._.blob.sentiment_assessments.assessments`**: a list of polarity and subjectivity scores for the assessed tokens.
132
95
133
-
Polarity is a float within the range [-1.0, 1.0], subjectivity is a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective, and assessments is a list of polarity and subjectivity scores for the assessed tokens.
96
+
See the [textblob docs](https://textblob.readthedocs.io/en/dev/api_reference.html#textblob.blob.TextBlob) for the complete listing of all attributes and methods that are available in `._.blob`.
When you add *spacytextblob* into your spaCy pipeline it exposes a custom attribute `._.blob`. This attribute is available for for the `Doc`, `Span`, and `Token` classes from spaCy.
6
+
7
+
-`Doc._.blob`
8
+
-`Span._.blob`
9
+
-`Token._.blob`
10
+
11
+
The section below outlines commonly accessed `._.blob` attributes and methods. See the [textblob docs](https://textblob.readthedocs.io/en/dev/api_reference.html#textblob.blob.TextBlob) for the complete listing of all attributes and methods that are available in `._.blob`.
12
+
13
+
### Attributes
14
+
15
+
| Name | Type | Description |
16
+
|------|------|-------------|
17
+
|`doc._.blob.polarity`|`Float`| The polarity of the document. The polarity score is a float within the range [-1.0, 1.0]. |
18
+
|`doc._.blob.subjectivity`|`Float`| The subjectivity of the document. The subjectivity is a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective. |
19
+
|`doc._.blob.sentiment_assessments.assessments`|`tuple`| Return a tuple of form (polarity, subjectivity, assessments ) where polarity is a float within the range [-1.0, 1.0], subjectivity is a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective, and assessments is a list of polarity and subjectivity scores for the assessed tokens. |
20
+
21
+
### Methods
22
+
23
+
**`doc._.blob.ngrams`**
24
+
25
+
| Name | Type | Description |
26
+
|------|------|-------------|
27
+
| n |`int`| The number of words to include in the ngram. By default `3`. |
28
+
| RETURNS |`List[WordLists]`||
29
+
30
+
31
+
## Config
32
+
33
+
When adding *spacytextblob* to your spaCy pipeline you can optionally pass additional parameters into the `config` parameter:
34
+
35
+
| Name | Type | Description |
36
+
|------|------|-------------|
37
+
|`blob_only`|`bool`| If True, *spacytextblob* will only expose `._.blob` and not attempt to expose `._.polarity`, `._.subjectivity`, or `._.assessments`. This should always be set to True when using TextBlob extensions. By default `False`. |
38
+
|`custom_blob`|`Dict[str, str]`| The `"custom_blob"` key should be assigned to a dictionary that tells spaCy what function to replace `textblob.TextBlob` with. In this case, we want to replace it with `TextBlobDE`. The key of the dictionary is `"@misc"`. This tells spaCy to look into the misc section of the spaCy register. The value should be the string name of a function that you have registered with spaCy. See the [TextBlob extensions](tutorial/textblob_extensions.md) section for more details. |
39
+
40
+
41
+
```python
42
+
import spacy
43
+
from spacytextblob.spacytextblob import SpacyTextBlob
0 commit comments