Skip to content

Commit 52d928e

Browse files
authored
Add files via upload
1 parent 4b21fb6 commit 52d928e

File tree

5 files changed

+49
-4
lines changed

5 files changed

+49
-4
lines changed

LICENSE

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
MIT License
2-
3-
Copyright (c) 2020 vaibhavad
1+
Copyright (c) 2018 The Python Packaging Authority
42

53
Permission is hereby granted, free of charge, to any person obtaining a copy
64
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# python-wrapper-OpenIE5
1+
# Example Package

pyopenie/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from pyopenie.openie import OpenIE5

pyopenie/openie.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import json, requests
2+
3+
4+
class OpenIE5:
5+
6+
def __init__(self, server_url):
7+
if server_url[-1] == '/':
8+
server_url = server_url[:-1]
9+
self.server_url = server_url
10+
self.extract_context = '/getExtraction'
11+
12+
def extract(self, text, properties=None):
13+
assert isinstance(text, str)
14+
if properties is None:
15+
properties = {}
16+
else:
17+
assert isinstance(properties, dict)
18+
19+
try:
20+
requests.get(self.server_url)
21+
except requests.exceptions.ConnectionError:
22+
raise Exception('Check whether you have started the OpenIE5 server')
23+
24+
data = text.encode('utf-8')
25+
26+
r = requests.post(
27+
self.server_url + self.extract_context, params={
28+
'properties': str(properties)
29+
}, data=data, headers={'Connection': 'close'})
30+
31+
return json.loads(r.text)

setup.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
name = 'pyopenie',
5+
packages = ['pyopenie'],
6+
version = '0.1.0',
7+
description = 'Python wrapper for OpenIE5',
8+
author = 'Vaibhav Adlakha',
9+
author_email = '[email protected]',
10+
url = 'https://github.com/vaibhavad/python-wrapper-OpenIE5',
11+
keywords = ['nlp'],
12+
classifiers = [],
13+
install_requires = ['requests','json']
14+
)
15+

0 commit comments

Comments
 (0)