Python wrapper around the Stanford Named Entity Recognizer (NER) Server and the Part-Of-Speech (POS) Tagger Server.
[](https://badge.fury.io/py/sner)
[](https://raw.githubusercontent.com/caihaoyu/sner/master/LICENSE)
# Stanford Named Entity Recognizer Project
* [Home Page](https://nlp.stanford.edu/software/CRF-NER.shtml)
* [Running NER as a Server](https://nlp.stanford.edu/software/crf-faq.shtml#cc)
# Stanford Part-Of-Speech Tagger Project
* [Home Page](https://nlp.stanford.edu/software/tagger.shtml)
* [Running POS as a Server](https://nlp.stanford.edu/software/pos-tagger-faq.html#e)
# Installation
```bash
pip install sner
```
or
```bash
python setup install
```
# Start
## NER Client
Run the following commands to start the NER server
```bash
cd your_stanford_ner_dir
java -Djava.ext.dirs=./lib -cp stanford-ner.jar edu.stanford.nlp.ie.NERServer -port 9199 -loadClassifier ./classifiers/english.all.3class.distsim.crf.ser.gz -tokenizerFactory edu.stanford.nlp.process.WhitespaceTokenizer -tokenizerOptions tokenizeNLs=false
```
Use the following in Python to access the NER server
```python
from sner import Ner
test_string = "Alice went to the Museum of Natural History."
tagger = Ner(host='localhost',port=9199)
print(tagger.get_entities(test_string))
```
The following results are expected
```python
[('Alice', 'PERSON'),
('went', 'O'),
('to', 'O'),
('the', 'O'),
('Museum', 'ORGANIZATION'),
('of', 'ORGANIZATION'),
('Natural', 'ORGANIZATION'),
('History', 'ORGANIZATION'),
('.', 'O')]
```
## POS Client
Run the following commands to start the POS server
```bash
cd your_stanford_pos_dir
java -cp stanford-postagger.jar edu.stanford.nlp.tagger.maxent.MaxentTaggerServer -port 9198 -model models/english-bidirectional-distsim.tagger
```
Use the following in Python to access the POS server
```python
from sner import POSClient
test_string = "Alice went to the Museum of Natural History."
tagger = POSClient(host='localhost', port=9198)
print(tagger.tag(test_string))
```
The following results are expected
```python
[('Alice', 'NNP'),
('went', 'VBD'),
('to', 'TO'),
('the', 'DT'),
('Museum', 'NNP'),
('of', 'IN'),
('Natural', 'NNP'),
('History', 'NN'),
('.', '.')]
```
Metadata
Release files for sner 0.2.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sner-0.2.12.tar.gz | 3.1 kB | Without provenance | Details for sner-0.2.12.tar.gz |
Release files / sner-0.2.12.tar.gz
| Download URL | sner-0.2.12.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e349cddd1bc26d89e69d8e7e9be7d35a6cf194094948576d39236bbf906f5134
|
|
BLAKE2b-256 checksum How to use checksums |
dd122532ca59b722b1573dd9015e831bc553524d9292199b131ea2b730911288
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for sner 0.2.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.