mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 10:54:18 +00:00
Merge branch 'development' of gitlab.ub.uni-bielefeld.de:sfb1288inf/opaque into development
This commit is contained in:
commit
49dc7c4cdb
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user