library.py 819 Bytes
Newer Older
1
import re
vpodpecan's avatar
vpodpecan committed
2 3 4 5 6 7
import subprocess
import logging
try:
    from ladon.clients.jsonwsp import JSONWSPClient
except ImportError:
    logging.warning('Ladon package not available, most of MUSE stuff will not work.')
8 9 10



vpodpecan's avatar
vpodpecan committed
11 12 13
def MUSE_preprocessing(input_dict):
    url = input_dict['url']
    text = input_dict['text']
14

vpodpecan's avatar
vpodpecan committed
15 16 17 18 19 20 21 22
    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.preprocessing(text=text)
    tokens = result.response_dict['result']
    return {'tokens': tokens}
#end
23

vpodpecan's avatar
vpodpecan committed
24 25 26 27 28 29 30 31 32 33 34 35 36

def MUSE_coreference(input_dict):
    url = input_dict['url']
    tokens = input_dict['tokens']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.coreference(tokens=tokens)
    corefs = result.response_dict['result']
    return {'coreferences': corefs}
#end