luminoso-api

Python client library for communicating with the Luminoso REST API
Download

luminoso-api Ranking & Summary

Advertisement

  • Rating:
  • License:
  • MIT/X Consortium Lic...
  • Price:
  • FREE
  • Publisher Name:
  • Luminoso, LLC
  • Publisher web site:
  • http://github.com/LuminosoInsight/

luminoso-api Tags


luminoso-api Description

luminoso-api is a Python client library for communicating with the Luminoso REST API.This package contains Python code for interacting with a Luminoso text processing server through its REST API.In this code, instead of having to authenticate each request separately, you make a "session" object that keeps track of your login information, and call methods on it that will be properly authenticated.Getting startedThis client API is designed to be used with Python 2.6 or 2.7.You can download and install it using a Python package manager:pip install luminoso-apioreasy_install luminoso-apiOr you can download this repository and install it the usual way:python setup.py installIf you are installing into the main Python environment on a Mac or Unix system, you will probably need to prefix those commands with sudo and enter your password, as in sudo python setup.py install.Getting startedYou interact with the API using a LuminosoClient object, which sends HTTP requests to URLs starting with a given path, and keeps track of your authentication information.>>> from luminoso_api import LuminosoClient>>> db = LuminosoClient.connect('/my_username/my_database', username='my_username')Password for my_username: >>> db.get('get_relevance'){u'result': }The URLs you can communicate with are documented at https://api.lumino.so/v2. That documentation is the authoritative source for what you can do with the API, and this Python code is just here to help you do it.A LuminosoClient object has methods such as .get, .post, and .put, which correspond to the corresponding HTTP methods that the API uses. For example, .get is used for retrieving information without changing anything, .post is generally used for creating new things or taking actions, and .put is generally used for updating information.ExamplesMost of the time, you'll want your LuminosoClient to refer to a particular project (also known as a database), but one case where you don't is to get a list of projects in the first place:from luminoso_api import LuminosoClientclient = LuminosoClient.connect(username='jane', password=MY_SECRET_PASSWORD)project_names = for project in client.get('.list_dbs')]print project_namesFor that reason, we have a simpler form for making a single GET request:result = LuminosoClient.get_once('.list_dbs', username='jane', password=SECRET_PASSWORD)project_names = for project in result]print project_namesAn example of working with a project, including the .upload_documents method that we provide to make it convenient to upload documents in the right format:from luminoso_api import LuminosoClientproject = LuminosoClient.connect('/jane/test-project')project.post('create_project')docs = project.upload_documents(docs)result = project.post('create_project')When the project is ready (it shouldn't take long with 2 documents)*:response = project.get('get_relevance')terms = , term) for term in response]print terms* We're working on an API call to see the progress of your project.VectorsThe semantics of terms are represented by "vector" objects, which this API will return as inscrutable base64-encoded strings like this:'WAB6AJG6kL_6D_6yAHE__R9kSAE8BlgKMo_80y8cCOCCSN-9oAQcABP_TMAFhAmMCUA'If you want to look inside these vectors and compare them to each other, download our library called pack64, available as pip install pack64. It will turn these into NumPy vectors, so it requires NumPy. >>> from pack64 import unpack64 >>> unpack64('WAB6AJG6kL_6D_6y') array(, dtype=float32)Product's homepage


luminoso-api Related Software