Giter Club home page Giter Club logo

python-wrapper-openie5's Introduction

pyopenie

Python wrapper for OpenIE5. This simply wraps the API from the server included with OpenIE 5.1.0.

Install

pip install pyopenie

Usage

First make sure you have the OpenIE5 server running. See the instructions here 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'

python-wrapper-openie5's People

Contributors

vaibhavad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

python-wrapper-openie5's Issues

Server does not seem to be able to take incoming requests from multiple IPs

I am hosting the server on an EC2 instance. I then make a request from another computer and it seems to work fine. However, when a second computer tries to make a request, the code hangs and the request doesn't seem to be able to make it to the server. Weirdly enough, the original computer will start having the same problem too.

Offset

Hi @vaibhavad ,

Can you please elaborate more on the offset with an example?

Thanks.

<class 'json.decoder.JSONDecodeError'>

For some reason, I am getting a lot of these issues.

I am loading the text from .txt for context
bob_dylan.txt

Error:
<class 'json.decoder.JSONDecodeError'>

Would it be possible that I need to parse the text through a json first before sending it off? Or is this a problem in the response? Are all characters accepted?

Failing sentences

The sentences containing “ fail, maybe an encoding issue with my documents.

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

A very long text leads to the following error:
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Server started with
java -Xmx10-XX:+UseConcMarkSweepGC -jar openie-assembly-5.0-SNAPSHOT.jar --split --ignore-errors --httpPort 8000
The input text was text extracted from a research paper.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.