https://github.com/vaibhavad/python-wrapper-openie5
Python wrapper for OpenIE5
https://github.com/vaibhavad/python-wrapper-openie5
information-extraction openie openie5-server python-wrapper
Last synced: 5 months ago
JSON representation
Python wrapper for OpenIE5
- Host: GitHub
- URL: https://github.com/vaibhavad/python-wrapper-openie5
- Owner: vaibhavad
- License: mit
- Created: 2020-01-23T19:20:34.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-25T13:30:17.000Z (over 5 years ago)
- Last Synced: 2025-01-04T22:41:22.252Z (6 months ago)
- Topics: information-extraction, openie, openie5-server, python-wrapper
- Language: Python
- Homepage: https://pypi.org/project/pyopenie/
- Size: 9.77 KB
- Stars: 40
- Watchers: 1
- Forks: 6
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pyopenie
Python wrapper for OpenIE5. This simply wraps the API from the server included with [OpenIE 5.1.0](https://github.com/dair-iitd/OpenIE-standalone).# Install
```
pip install pyopenie
```# Usage
First make sure you have the OpenIE5 server running. See [the instructions here](https://github.com/dair-iitd/OpenIE-standalone#running-as-http-server) for how to do that.Then the setup just requires you to pass in the url of the server:
```
>>> from pyopenie import OpenIE5
>>> extractor = OpenIE5('http://localhost:9000')
```
Any English sentence can be passed to OpenIE5 server.
```
>>> extractions = extractor.extract("The U.S. president Barack Obama gave his speech to thousands of people.")
```
The result is a JSON list of extractions with confidence, offset and other properties.
```
>>> extractions
[
{
"confidence": 0.38089450366724514,
"sentence": "The U.S. president Barack Obama gave his speech on Tuesday to thousands of people.",
"extraction": {
"arg1": {
"text": "Barack Obama",
"offsets": [...]
},
"rel": {
"text": "[is] president [of]",
"offsets": [...]
},
"arg2s": [
{
"text": "United States",
"offsets": [...]
}
],
"context": null,
"negated": false,
"passive": false
}
},
{
"confidence": 0.9168198459177435,
"sentence": "The U.S. president Barack Obama gave his speech on Tuesday to thousands of people.",
"extraction": {
"arg1": {
"text": "The U.S. president Barack Obama",
"offsets": [...]
},
"rel": {
"text": "gave",
"offsets": [...]
},
"arg2s": [
{
"text": "his speech",
"offsets": [...]
},
{
"text": "on Tuesday",
"offsets": [...]
},
{
"text": "to thousands of people",
"offsets": [...]
}
],
"context": null,
"negated": false,
"passive": false
}
}
]
```
Individual properties can also be accessed.
```
>>> extractions[0]['confidence']
0.38089450366724514>>> extractions[0]['extraction']['arg1']['text']
'Barack Obama'
```