Skip to content
Snippets Groups Projects
Commit 606c4dee authored by Patrick Jentsch's avatar Patrick Jentsch
Browse files

CQi updates

parent b78558fc
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,8 @@ class APIClient:
>>> client = cqi.APIClient('127.0.0.1')
>>> client.ctrl_connect('user', 'password')
{'code': 258, 'msg': 'CQI_STATUS_CONNECT_OK'}
>>> client.ctrl_ping()
{'code': 260, 'msg': 'CQI_STATUS_PING_OK'}
>>> client.ctrl_bye()
{'code': 259, 'msg': 'CQI_STATUS_BYE_OK'}
......
......@@ -3,7 +3,31 @@ from .models.corpora import CorpusCollection
class CQiClient:
"""
A client for communicating with a CQi server.
Example:
>>> import cqi
>>> client = cqi.CQiClient('127.0.0.1')
>>> client.connect()
{'code': 258, 'msg': 'CQI_STATUS_CONNECT_OK'}
>>> client.ping()
{'code': 260, 'msg': 'CQI_STATUS_PING_OK'}
>>> client.disconnect()
{'code': 259, 'msg': 'CQI_STATUS_BYE_OK'}
Attributes:
api (APIClient): A client pointing to the specified to the CQP server.
"""
def __init__(self, host, port=4877):
"""
CQiClient constructor
Args:
host (str): URL to the CQP server. For example,
``cqpserver.localhost`` or ``127.0.0.1``.
port (int): Port the CQP server listens on. Default: ``4877``
"""
self.api = APIClient(host, port=port)
def connect(self, username='anonymous', password=''):
......@@ -14,3 +38,6 @@ class CQiClient:
def disconnect(self):
del self.corpora
return self.api.ctrl_bye()
def ping(self):
return self.api.ctrl_ping()
......@@ -8,6 +8,18 @@ class AttributeCollection:
class Attribute:
"""
This is a class representing an attribute. Attributes denote the general
category of information. A specific occurence is identified by an Id.
Attributes:
client (CQiClient): A connected client pointing at the server that this
object is on.
corpus (Corpus): The corpus, this attribute belongs to.
name (str): The name of the Attribute.
size (int): The number of occurences of this attribute within the corpus.
"""
def __init__(self, client, corpus, name):
self.client = client
self.corpus = corpus
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment