Skip to content

Commit

Permalink
Merge branch 'master' into sonicbranch
Browse files Browse the repository at this point in the history
  • Loading branch information
dpalmasan authored Apr 14, 2021
2 parents 395bf50 + 10b0326 commit 553872f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ While most of the indices could be computed for different languages, currently w
Spanish. We are happy if you contribute with indices implemented for your language!

<p align="center">
<a href="https://travis-ci.com/dpalmasan/TRUNAJOD2.0"><img alt="Build Status" src="https://travis-ci.com/dpalmasan/TRUNAJOD2.0.svg?branch=master"></a>
<a href="https://trunajod20.readthedocs.io/en/latest/?badge=latest"><img alt="Documentation Status" src="https://readthedocs.org/projects/trunajod20/badge/?version=latest"></a>
<a href="https://github.com/dpalmasan/TRUNAJOD2.0/actions"><img alt="Actions Status" src="https://github.com/dpalmasan/TRUNAJOD2.0/workflows/Test/badge.svg"></a>
<a href="https://trunajod20.readthedocs.io/en/stable/?badge=stable"><img alt="Documentation Status" src="https://readthedocs.org/projects/trunajod20/badge/?version=stable"></a>
<img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/trunajod">
<a href="https://github.com/dpalmasan/TRUNAJOD2.0/blob/master/LICENSE"><img alt="License: MIT" src="https://img.shields.io/github/license/dpalmasan/TRUNAJOD2.0"></a>
<a href="https://pypi.org/project/TRUNAJOD/"><img alt="PyPI" src="https://img.shields.io/pypi/v/TRUNAJOD"></a>
<a href="https://pepy.tech/project/trunajod"><img alt="Downloads" src="https://static.pepy.tech/badge/TRUNAJOD"></a>
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
</p>

## Features
Expand All @@ -33,11 +35,7 @@ Spanish. We are happy if you contribute with indices implemented for your langua

## Installation

To install the package:

```
pip install TRUNAJOD
```
`TRUNAJOD` can be installed by running `pip install trunajod`. It requires Python 3.6.2+ to run.

## Getting Started

Expand All @@ -47,6 +45,9 @@ You can download pre-build `TRUNAJOD` models from the repo, under the `models` d

Below is a small snippet of code that can help you in getting started with this lib. Don´t forget to take a look at the [documentation](https://trunajod20.readthedocs.io/en/latest).

The example below assumes you have the `es_core_news_sm` spaCy Spanish model installed. You can install the model running: `python -m spacy download es_core_news_sm`. For other models, please check [spaCy docs](https://spacy.io/usage/models).


```python
from TRUNAJOD import surface_proxies
from TRUNAJOD.entity_grid import EntityGrid
Expand Down Expand Up @@ -90,7 +91,7 @@ class ModelLoader(object):
model = ModelLoader("trunajod_models_v0.1.tar.gz")

# Load spaCy model
nlp = spacy.load("es", disable=["ner", "textcat"])
nlp = spacy.load("es_core_news_sm", disable=["ner", "textcat"])

example_text = (
"El espectáculo del cielo nocturno cautiva la mirada y suscita preguntas"
Expand Down Expand Up @@ -138,6 +139,14 @@ Entity grid:
```


## Contributing to _TRUNAJOD_

Bug reports and fixes are always welcome! Feel free to file issues, or ask for a feature request. We use `Github` issue tracker for this. If you'd like to contribute, feel free to submit a pull request. For more questions you can contact me at `dipalma (at) udec (dot) cl`.

More details can be found in
[CONTRIBUTING](https://github.com/dpalmasan/TRUNAJOD2.0/blob/master/CONTRIBUTING.md).


## References

If you find anything of this useful, feel free to cite the following papers, from which a lot of this python library was made for (I am also in the process of submitting this lib to an open software journal):
Expand Down
6 changes: 5 additions & 1 deletion src/TRUNAJOD/emotions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
The following emotions are captured: alegría, enojo, miedo, repulsión,
sorpresa, tristeza.
"""
from typing import Dict
from typing import Optional

from spacy.tokens import Doc
from TRUNAJOD.spanish_emotion_lexicon import SPANISH_EMOTION_LEXICON
from TRUNAJOD.utils import lemmatize

Expand All @@ -29,7 +33,7 @@ class Emotions(object):
- Averaging over emotions and not the total count?
"""

def __init__(self, doc, lemmatizer=None):
def __init__(self, doc: Doc, lemmatizer: Optional[Dict[str, str]] = None):
"""Initialize emotions class.
Average over number of tokens.
Expand Down

0 comments on commit 553872f

Please sign in to comment.