Name | stanford-openie JSON |
Version |
1.3.2
JSON |
| download |
home_page | |
Summary | Minimalist wrapper around Stanford OpenIE |
upload_time | 2024-01-11 00:11:51 |
maintainer | |
docs_url | None |
author | Philippe Remy |
requires_python | |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Python wrapper for Stanford OpenIE (MacOS/Linux)
[![Downloads](https://static.pepy.tech/badge/stanford-openie)](https://pepy.tech/project/stanford-openie)
[![Downloads](https://static.pepy.tech/badge/stanford-openie/month)](https://pepy.tech/project/stanford-openie)
![Stanford NLP Wrapper CI](https://github.com/philipperemy/Stanford-OpenIE-Python/workflows/Stanford%20NLP%20Wrapper%20CI/badge.svg)
*Supports the latest CoreNLP library 4.5.3 (as of 2023-03-10).*
Open information extraction (open IE) refers to the extraction of structured relation triples from plain text, such that
the schema for these relations does not need to be specified in advance. For example, Barack Obama was born in Hawaii
would create a triple `(Barack Obama; was born in; Hawaii)`, corresponding to the open domain relation "was born in".
CoreNLP is a Java implementation of an open IE system as described in the paper:
More information can be found [here](http://nlp.stanford.edu/software/openie.html). The OpenIE library is only available
in [english](https://stanfordnlp.github.io/CoreNLP/human-languages.html).
## Installation
You need python3 and Java (JRE) installed. Java is used by the CoreNLP library.
Make sure Java is installed first.
```bash
java -version
```
Then install the lib.
```bash
pip install stanford_openie
```
## Example
```python
from openie import StanfordOpenIE
# https://stanfordnlp.github.io/CoreNLP/openie.html#api
# Default value of openie.affinity_probability_cap was 1/3.
properties = {
'openie.affinity_probability_cap': 2 / 3,
}
with StanfordOpenIE(properties=properties) as client:
text = 'Barack Obama was born in Hawaii. Richard Manning wrote this sentence.'
print('Text: %s.' % text)
for triple in client.annotate(text):
print('|-', triple)
graph_image = 'graph.png'
client.generate_graphviz_graph(text, graph_image)
print('Graph generated: %s.' % graph_image)
with open('corpus/pg6130.txt', encoding='utf8') as r:
corpus = r.read().replace('\n', ' ').replace('\r', '')
triples_corpus = client.annotate(corpus[0:5000])
print('Corpus: %s [...].' % corpus[0:80])
print('Found %s triples in the corpus.' % len(triples_corpus))
for triple in triples_corpus[:3]:
print('|-', triple)
print('[...]')
```
*Expected output*
```
|- {'subject': 'Barack Obama', 'relation': 'was', 'object': 'born'}
|- {'subject': 'Barack Obama', 'relation': 'was born in', 'object': 'Hawaii'}
|- {'subject': 'Richard Manning', 'relation': 'wrote', 'object': 'sentence'}
Graph generated: graph.png.
Corpus: According to this document, the city of Cumae in Ćolia, was, at an early period [...].
Found 1664 triples in the corpus.
|- {'subject': 'city', 'relation': 'is in', 'object': 'Ćolia'}
|- {'subject': 'Menapolus', 'relation': 'son of', 'object': 'Ithagenes'}
|- {'subject': 'Menapolus', 'relation': 'was Among', 'object': 'immigrants'}
```
It will generate a [GraphViz DOT](http://www.graphviz.org/) in `graph.png`:
<div align="center">
<img src="img/out.png"><br><br>
</div>
*Note*: Make sure GraphViz is installed beforehand. Try to run the `dot` command to see if this is the case. If not,
run `sudo apt-get install graphviz` if you're running on Ubuntu. On MacOS, it is `brew install graphviz`.
## References
- https://www.kaggle.com/asitang/stanford-resources
- https://www.kaggle.com/geofila/corenlp?select=stanford-corenlp-full-2018-10-05
## Cite
```
@misc{StanfordOpenIEWrapper,
author = {Philippe Remy},
title = {Python wrapper for Stanford OpenIE},
year = {2020},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/philipperemy/Stanford-OpenIE-Python}},
}
```
## Contributors
<a href="https://github.com/philipperemy/stanford-openie-python/graphs/contributors">
<img src="https://contrib.rocks/image?repo=philipperemy/stanford-openie-python" />
</a>
Raw data
{
"_id": null,
"home_page": "",
"name": "stanford-openie",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Philippe Remy",
"author_email": "",
"download_url": "",
"platform": null,
"description": "# Python wrapper for Stanford OpenIE (MacOS/Linux)\n\n[![Downloads](https://static.pepy.tech/badge/stanford-openie)](https://pepy.tech/project/stanford-openie)\n[![Downloads](https://static.pepy.tech/badge/stanford-openie/month)](https://pepy.tech/project/stanford-openie)\n![Stanford NLP Wrapper CI](https://github.com/philipperemy/Stanford-OpenIE-Python/workflows/Stanford%20NLP%20Wrapper%20CI/badge.svg)\n\n*Supports the latest CoreNLP library 4.5.3 (as of 2023-03-10).*\n\nOpen information extraction (open IE) refers to the extraction of structured relation triples from plain text, such that\nthe schema for these relations does not need to be specified in advance. For example, Barack Obama was born in Hawaii\nwould create a triple `(Barack Obama; was born in; Hawaii)`, corresponding to the open domain relation \"was born in\".\nCoreNLP is a Java implementation of an open IE system as described in the paper:\n\nMore information can be found [here](http://nlp.stanford.edu/software/openie.html). The OpenIE library is only available\nin [english](https://stanfordnlp.github.io/CoreNLP/human-languages.html).\n\n## Installation\n\nYou need python3 and Java (JRE) installed. Java is used by the CoreNLP library.\n\nMake sure Java is installed first.\n```bash\njava -version\n```\n\nThen install the lib.\n```bash\npip install stanford_openie\n```\n\n## Example\n\n```python\nfrom openie import StanfordOpenIE\n\n# https://stanfordnlp.github.io/CoreNLP/openie.html#api\n# Default value of openie.affinity_probability_cap was 1/3.\nproperties = {\n 'openie.affinity_probability_cap': 2 / 3,\n}\n\nwith StanfordOpenIE(properties=properties) as client:\n text = 'Barack Obama was born in Hawaii. Richard Manning wrote this sentence.'\n print('Text: %s.' % text)\n for triple in client.annotate(text):\n print('|-', triple)\n\n graph_image = 'graph.png'\n client.generate_graphviz_graph(text, graph_image)\n print('Graph generated: %s.' % graph_image)\n\n with open('corpus/pg6130.txt', encoding='utf8') as r:\n corpus = r.read().replace('\\n', ' ').replace('\\r', '')\n\n triples_corpus = client.annotate(corpus[0:5000])\n print('Corpus: %s [...].' % corpus[0:80])\n print('Found %s triples in the corpus.' % len(triples_corpus))\n for triple in triples_corpus[:3]:\n print('|-', triple)\n print('[...]')\n ```\n\n*Expected output*\n\n ```\n |- {'subject': 'Barack Obama', 'relation': 'was', 'object': 'born'}\n |- {'subject': 'Barack Obama', 'relation': 'was born in', 'object': 'Hawaii'}\n |- {'subject': 'Richard Manning', 'relation': 'wrote', 'object': 'sentence'}\n Graph generated: graph.png.\n Corpus: \ufeffAccording to this document, the city of Cumae in \u0106olia, was, at an early period [...].\n Found 1664 triples in the corpus.\n |- {'subject': 'city', 'relation': 'is in', 'object': '\u0106olia'}\n |- {'subject': 'Menapolus', 'relation': 'son of', 'object': 'Ithagenes'}\n |- {'subject': 'Menapolus', 'relation': 'was Among', 'object': 'immigrants'}\n ```\n\nIt will generate a [GraphViz DOT](http://www.graphviz.org/) in `graph.png`:\n\n<div align=\"center\">\n <img src=\"img/out.png\"><br><br>\n</div>\n\n*Note*: Make sure GraphViz is installed beforehand. Try to run the `dot` command to see if this is the case. If not,\nrun `sudo apt-get install graphviz` if you're running on Ubuntu. On MacOS, it is `brew install graphviz`.\n\n## References\n\n- https://www.kaggle.com/asitang/stanford-resources\n- https://www.kaggle.com/geofila/corenlp?select=stanford-corenlp-full-2018-10-05\n\n## Cite\n\n```\n@misc{StanfordOpenIEWrapper,\n author = {Philippe Remy},\n title = {Python wrapper for Stanford OpenIE},\n year = {2020},\n publisher = {GitHub},\n journal = {GitHub repository},\n howpublished = {\\url{https://github.com/philipperemy/Stanford-OpenIE-Python}},\n}\n```\n\n## Contributors\n\n<a href=\"https://github.com/philipperemy/stanford-openie-python/graphs/contributors\">\n <img src=\"https://contrib.rocks/image?repo=philipperemy/stanford-openie-python\" />\n</a>\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Minimalist wrapper around Stanford OpenIE",
"version": "1.3.2",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d7366125ebead04fd9e35df2eea86cfe20ac2c885ebb9f78759c2046f1d11136",
"md5": "114377ca9c79e1077abedbf1bf0f08e8",
"sha256": "73210dbc522c7e9d972859faf5fe3dd9f0a5e08bb8bbef94895f50e5b01ee1af"
},
"downloads": -1,
"filename": "stanford_openie-1.3.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "114377ca9c79e1077abedbf1bf0f08e8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5537,
"upload_time": "2024-01-11T00:11:51",
"upload_time_iso_8601": "2024-01-11T00:11:51.016698Z",
"url": "https://files.pythonhosted.org/packages/d7/36/6125ebead04fd9e35df2eea86cfe20ac2c885ebb9f78759c2046f1d11136/stanford_openie-1.3.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-11 00:11:51",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "stanford-openie"
}