Coder Social home page Coder Social logo

giacbrd / python-dandelion-eu Goto Github PK

View Code? Open in Web Editor NEW
36.0 11.0 15.0 73 KB

A python client for connecting to all the services provided by https://dandelion.eu

Home Page: http://python-dandelion-eu.readthedocs.org

License: GNU General Public License v2.0

Python 100.00%
python entity-extraction entity-linking machine-learning text-classification sentiment-analysis language-detection api-client api-wrapper api

python-dandelion-eu's Introduction

https://travis-ci.org/giacbrd/python-dandelion-eu.svg?branch=master https://coveralls.io/repos/SpazioDati/python-dandelion-eu/badge.png?branch=master Latest PyPI version

python-dandelion-eu

Bring the power of the dandelion.eu semantic to your python applications and scripts! Semantic in python couldn't be easier.

>>> from dandelion import DataTXT
>>> datatxt = DataTXT(token='YOUR_TOKEN')
>>> response = datatxt.nex('The doctor says an apple is better than an orange')
>>> for annotation in response.annotations:
      print(annotation)
...

Register on dandelion to obtain your authentication token and enrich your application with our semantic intelligence.

Installation

dandelion-eu is available on PyPI install it simply with:

pip install dandelion-eu

Documentation

Documentation is available on ReadTheDocs.

python-dandelion-eu's People

Contributors

armisael avatar giacbrd avatar martino avatar vad 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-dandelion-eu's Issues

Failing to use datagem

I am just trying to follow this example:

from dandelion import Datagem

YOUR_APP_ID='2d30226a'
YOUR_APP_KEY='98e8e00736738db994a3e8d515a6402a'

d = Datagem('administrative-regions', app_id=YOUR_APP_ID, app_key=YOUR_APP_KEY)
for obj in d.items.select('acheneID')[:10]:
print(obj)

but i get this error:

Traceback (most recent call last):
File "/Users/Ludovica1/Desktop/dande.py", line 9, in
for obj in d.items.select('acheneID')[:10]:
File "/Library/Python/2.7/site-packages/dandelion/datagem.py", line 96, in iter
response = self.datagem.do_request(params, method='get')
File "/Library/Python/2.7/site-packages/dandelion/base.py", line 88, in do_request
raise DandelionException(obj)
dandelion.base.DandelionException: usage limits are exceeded

Cannot detect language on EN text

Hello, I am getting this error when I try to process this English text:

I'm getting a bit confused by tech companies' thinking around the future of remote working, and I imagine I'm not the only one.

Months of working from home have made many businesses and their employees question whether the typical 9-5 working model is necessary in an age where work is increasingly done in front of a computer that provides instantaneous connection to anyone, anywhere in the world.

In this special feature, ZDNet examines technology's role in helping business leaders build tomorrow's workforce, and employees keep their skills up to date and grow their careers.

The article is longer, you can find it here: https://www.zdnet.com/article/is-remote-working-good-or-bad-big-tech-companies-just-cant-seem-to-decide/

The error message:

Traceback (most recent call last):
  File "/home/manentai/mambaforge/envs/flaskenv/lib/python3.8/site-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/manentai/mambaforge/envs/flaskenv/lib/python3.8/site-packages/flask/app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/home/manentai/mambaforge/envs/flaskenv/lib/python3.8/site-packages/flask_restful/__init__.py", line 467, in wrapper
    resp = resource(*args, **kwargs)
  File "/home/manentai/mambaforge/envs/flaskenv/lib/python3.8/site-packages/flask/views.py", line 84, in view
    return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
  File "/home/manentai/mambaforge/envs/flaskenv/lib/python3.8/site-packages/flask_restful/__init__.py", line 582, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/home/manentai/flaskAI/app.py", line 119, in post
    app.PD.process(document_id)
  File "/home/manentai/flaskAI/process_data.py", line 97, in process
    response = datatxt.nex(sentence)#, include_categories=True, include_types=True)
  File "/home/manentai/mambaforge/envs/flaskenv/lib/python3.8/site-packages/dandelion/datatxt.py", line 14, in nex
    return self.do_request(
  File "/home/manentai/mambaforge/envs/flaskenv/lib/python3.8/site-packages/dandelion/base.py", line 102, in do_request
    raise DandelionException(obj)
dandelion.base.DandelionException: Cannot detect language

what can cause this confusion on an English text? Am I supposed to tell Dandelion that it's in English?

Can't use new authentication

Apparently, we don't need any "app_id" anymore but this is still required in the python API.
The problem is that we can't create it on the website.
Thanks

HTTP response code is not checked before doing any parsing

HTTP response code is not checked before doing any parsing in base.py and this may lead to parsing exceptions.
A scenario I've been running into lately:

Ignoring the reason why the request took so much time, the client library should check the return code.

Installation through pip in virtualenv fails

Installing via pip fails because the cache subdir is not copied with the rest of the module.

Hotfix copying cache from source in:

~/.virtualenvs/<venv_name>/lib/python2.7/site-packages/dandelion

Below a walk-through to reproduce the bug.

Cloning the repo and installing with:

python setup.py install

works well.

cristian@FBK-41512:~$ 
cristian@FBK-41512:~$ mkvirtualenv dandeliontest
New python executable in dandeliontest/bin/python
Installing setuptools, pip...done.
(dandeliontest)cristian@FBK-41512:~$ pip install dandelion-eu
Downloading/unpacking dandelion-eu
  Downloading dandelion-eu-0.2.0.tar.gz
  Running setup.py egg_info for package dandelion-eu

Downloading/unpacking requests (from dandelion-eu)
  Downloading requests-2.2.1.tar.gz (421kB): 421kB downloaded
  Running setup.py egg_info for package requests

Downloading/unpacking six (from dandelion-eu)
  Downloading six-1.5.2.tar.gz
  Running setup.py egg_info for package six

    no previously-included directories found matching 'documentation/_build'
Installing collected packages: dandelion-eu, requests, six
  Running setup.py install for dandelion-eu

  Running setup.py install for requests

  Running setup.py install for six

    no previously-included directories found matching 'documentation/_build'
Successfully installed dandelion-eu requests six
Cleaning up...
(dandeliontest)cristian@FBK-41512:~$ 
(dandeliontest)cristian@FBK-41512:~$ 
[snip installazione ipython]
(dandeliontest)cristian@FBK-41512:~$ ipython
Python 2.7.5+ (default, Sep 19 2013, 13:48:49) 
Type "copyright", "credits" or "license" for more information.

IPython 1.2.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import dandelion
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-13ab65f33a19> in <module>()
----> 1 import dandelion

/home/cristian/.virtualenvs/dandeliontest/local/lib/python2.7/site-packages/dandelion/__init__.py in <module>()
      2 """
      3 
----> 4 from dandelion.base import DandelionException, DandelionConfig
      5 from dandelion.datagem import Datagem
      6 from dandelion.datatxt import DataTXT

/home/cristian/.virtualenvs/dandeliontest/local/lib/python2.7/site-packages/dandelion/base.py in <module>()
     10 import requests
     11 
---> 12 from dandelion.cache.base import NoCache
     13 from dandelion.utils import AttributeDict
     14 

ImportError: No module named cache.base

In [2]: from dandelion import DataTXT
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-4b899f3ee938> in <module>()
----> 1 from dandelion import DataTXT

/home/cristian/.virtualenvs/dandeliontest/local/lib/python2.7/site-packages/dandelion/__init__.py in <module>()
      2 """
      3 
----> 4 from dandelion.base import DandelionException, DandelionConfig
      5 from dandelion.datagem import Datagem
      6 from dandelion.datatxt import DataTXT

/home/cristian/.virtualenvs/dandeliontest/local/lib/python2.7/site-packages/dandelion/base.py in <module>()
     10 import requests
     11 
---> 12 from dandelion.cache.base import NoCache
     13 from dandelion.utils import AttributeDict
     14 

ImportError: No module named cache.base

In [3]: 

Cristian

Input type parameters are hard-coded

DataTXT APIs have more than one input type such as plain text, url, html fragment and others.
They are implemented as required and mutually exclusive parameters as described in API documentation.

Currently in this library some of them are hard-coded preventing the user to choose the right one.
In particular, at the moment the only content type available is plain text since it's hard-coded in the following lines:

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.