mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 04:12:45 +00:00 
			
		
		
		
	CQi updates
This commit is contained in:
		@@ -15,6 +15,8 @@ class APIClient:
 | 
				
			|||||||
    >>> client = cqi.APIClient('127.0.0.1')
 | 
					    >>> client = cqi.APIClient('127.0.0.1')
 | 
				
			||||||
    >>> client.ctrl_connect('user', 'password')
 | 
					    >>> client.ctrl_connect('user', 'password')
 | 
				
			||||||
    {'code': 258, 'msg': 'CQI_STATUS_CONNECT_OK'}
 | 
					    {'code': 258, 'msg': 'CQI_STATUS_CONNECT_OK'}
 | 
				
			||||||
 | 
					    >>> client.ctrl_ping()
 | 
				
			||||||
 | 
					    {'code': 260, 'msg': 'CQI_STATUS_PING_OK'}
 | 
				
			||||||
    >>> client.ctrl_bye()
 | 
					    >>> client.ctrl_bye()
 | 
				
			||||||
    {'code': 259, 'msg': 'CQI_STATUS_BYE_OK'}
 | 
					    {'code': 259, 'msg': 'CQI_STATUS_BYE_OK'}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,31 @@ from .models.corpora import CorpusCollection
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class CQiClient:
 | 
					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):
 | 
					    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)
 | 
					        self.api = APIClient(host, port=port)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def connect(self, username='anonymous', password=''):
 | 
					    def connect(self, username='anonymous', password=''):
 | 
				
			||||||
@@ -14,3 +38,6 @@ class CQiClient:
 | 
				
			|||||||
    def disconnect(self):
 | 
					    def disconnect(self):
 | 
				
			||||||
        del self.corpora
 | 
					        del self.corpora
 | 
				
			||||||
        return self.api.ctrl_bye()
 | 
					        return self.api.ctrl_bye()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def ping(self):
 | 
				
			||||||
 | 
					        return self.api.ctrl_ping()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,6 +8,18 @@ class AttributeCollection:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Attribute:
 | 
					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):
 | 
					    def __init__(self, client, corpus, name):
 | 
				
			||||||
        self.client = client
 | 
					        self.client = client
 | 
				
			||||||
        self.corpus = corpus
 | 
					        self.corpus = corpus
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user