The UCREL Tool Chain API class:

class UCREL_API[source]

UCREL_API(email:str, server_address:str, port:str='', timeout:int=60)

UCREL_API.__init__[source]

UCREL_API.__init__(email:str, server_address:str, port:str='', timeout:int=60)

Creates a UCREL API instance that is used to call the UCREL Tool chain.

  1. email: Email address of the user. This is used to identify the user calling the UCREL Tool Chain API.
  2. server_address: The address of the UCREL Tool Chain e.g. http://ucrel-api.lancaster.ac.uk
  3. port: The port to the server e.g. 8080. Can be left as empty string if port number is not required.
  4. timeout: The amount of time to allow each request to take before raising a requests.exceptions.Timeout
ucrel_api = UCREL_API('a.moore@lancaster.ac.uk', 'http://ucrel-api.lancaster.ac.uk')

UCREL_API.__repr__[source]

UCREL_API.__repr__()

String representation of the UCREL API instance, format:

UCREL API, server address {self.server_address}, port {self.port}, timeout {self.timeout}

, port {self.port} -- will only exist in string if self.port!=''

ucrel_api
UCREL API, server address http://ucrel-api.lancaster.ac.uk, timeout 60 seconds

UCREL_API.usas[source]

UCREL_API.usas(text:str, tagset:str='c7')

  1. text: The text to be tagged by USAS.
  2. tagset: The tagset to be used by USAS. Either c5 or c7.

returns: A UCREL_Doc representing the text and the lingustic attributes that are generared from tagging it with USAS.

ucrel_doc = ucrel_api.usas(('Hope you have a nice day. '
                            'Works with SGML entities e.g. 5 > 4.'
                            'Also with MWE like New York.'))
for index, sentence in enumerate(ucrel_doc.sentences):
    print(f'Sentence {index}')
    for token in sentence:
        print(token)
    if index == 0 or index == 1:
        print('\n')
Sentence 0
UCREL Token: Hope	Lemma: hope	POS tag: VV0	USAS tag: X2.6+
UCREL Token: you	Lemma: you	POS tag: PPY	USAS tag: Z8mf
UCREL Token: have	Lemma: have	POS tag: VH0	USAS tag: A9+
UCREL Token: a	Lemma: a	POS tag: AT1	USAS tag: Z5
UCREL Token: nice	Lemma: nice	POS tag: JJ	USAS tag: O4.2+
UCREL Token: day	Lemma: day	POS tag: NNT1	USAS tag: T1.3
UCREL Token: .	Lemma: PUNC	POS tag: .


Sentence 1
UCREL Token: Works	Lemma: works	POS tag: NN	USAS tag: I4/H1c
UCREL Token: with	Lemma: with	POS tag: IW	USAS tag: Z5
UCREL Token: SGML	Lemma: sgml	POS tag: NP1	USAS tag: Z99
UCREL Token: entities	Lemma: entity	POS tag: NN2	USAS tag: O2
UCREL Token: e.g.	Lemma: e.g.	POS tag: REX	USAS tag: A4.1
UCREL Token: 5	Lemma: 5	POS tag: MC	USAS tag: N1
UCREL Token: >	Lemma: >	POS tag: FO	USAS tag: Z99
UCREL Token: 4	Lemma: 4	POS tag: MC	USAS tag: N1
UCREL Token: .	Lemma: PUNC	POS tag: .


Sentence 2
UCREL Token: Also	Lemma: also	POS tag: RR	USAS tag: N5++
UCREL Token: with	Lemma: with	POS tag: IW	USAS tag: Z5
UCREL Token: MWE	Lemma: mwe	POS tag: NP1	USAS tag: Z99
UCREL Token: like	Lemma: like	POS tag: II	USAS tag: Z5
UCREL Token: New	Lemma: new	POS tag: NP1	USAS tag: Z2	MWE tag: 2.2.1
UCREL Token: York	Lemma: york	POS tag: NP1	USAS tag: Z2	MWE tag: 2.2.2
UCREL Token: .	Lemma: PUNC	POS tag: .

Note that even though New York is the first MWE identified as shown above, it has the MWE tag: 2.2.1 and 2.2.2 suggesting that there has been a MWE previously due to the first number in the tag being 2. Actually the USAS, POS, and MWE tags shown above are the most likely tags and other less probable tags are generated for each token, but they are not shown here as we only output the most probable tag for each token.