Пример #1
0
def MUSE_mapping_to_KR_precomputed(input_dict):
    url = input_dict['url']
    data = input_dict['input_data']

    cli = JSONWSPClient(url)
    result = cli.mapping_to_KR_precomputed(SRL=data)

    return {'mapping': result.response_dict['result']}
Пример #2
0
def MUSE_mapping_to_KR_precomputed_latest(input_dict):
    url = input_dict['url']
    data = input_dict['input_data']

    cli = JSONWSPClient(url)
    result = cli.mapping_to_KR_precomputed_latest(SRL=data)
    mapping, xml = result.response_dict['result']

    return {'mapping': mapping, 'xml': xml}
Пример #3
0
def MUSE_semantic_role_labeling(input_dict):
    url = input_dict['url']
    data = input_dict['xml']

    cli = JSONWSPClient(url)
    result = cli.semantic_role_labeling(xml=data)
    srl, txt = result.response_dict['result']

    return {'xml': srl, 'txt': txt}
Пример #4
0
def MUSE_mapping_to_KR_latest(input_dict):
    url = input_dict['url']
    data = input_dict['input_data']

    import socket
    cli = JSONWSPClient(url)
    socket.setdefaulttimeout(None)
    result = cli.mapping_to_KR_latest(SRL=data)
    mapping, xml = result.response_dict['result']
    return {'mapping': mapping, 'xml': xml}
Пример #5
0
def MUSE_event_temprel_detection(input_dict):
    text = input_dict['text']
    url = input_dict['url']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.event_temprel_detection(text=text)
    result = result.response_dict['result']
    return {'xml': result}
Пример #6
0
def MUSE_SRL(input_dict):
    url = input_dict['url']
    tokens = input_dict['tokens']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.SRL(tokens=tokens)
    srl = result.response_dict['result']
    return {'srl': srl}
Пример #7
0
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}
Пример #8
0
def MUSE_PG_event_temprel_detection(input_dict):
    url = input_dict['url']
    preproc = input_dict['preproc'].strip()

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.PG_event_temprel_detection(preprocessed=preproc)
    result = result.response_dict['result']
    return {'xml': result}
Пример #9
0
def MUSE_PG_preprocessing(input_dict):
    text = input_dict['text']
    url = input_dict['url']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.PG_preprocessing(text=text)
    result = result.response_dict['result']
    return {'structure': result[0], 'tokens': result[1]}
Пример #10
0
def testCalculator():

    global base_url
    print("\n\nTesting Calculator:\n")
    # Load the Calculator description

    calc_client = JSONWSPClient(base_url + '/Calculator/jsonwsp/description')

    # Add the numbers 23 and 45
    jsonwsp_resp = calc_client.add(a=23, b=45)
    return print_result(jsonwsp_resp)
Пример #11
0
def MUSE_preprocessing(input_dict):
    url = input_dict['url']
    text = input_dict['text']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.preprocessing(text=text)
    tokens = result.response_dict['result']
    return {'tokens': tokens}
Пример #12
0
def MUSE_PG_GDEE_text(input_dict):
    url = input_dict['url']
    text = input_dict['text']
    lang = input_dict['lang']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.PG_GDEE_text(text=text, lang=lang)
    result = result.response_dict['result']
    return {'xml': result}
Пример #13
0
def MUSE_prepare_mapping(input_dict):
    url = input_dict['url']
    srlp = input_dict['srlp']
    quots = input_dict['quots']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.prepare_for_mapping(srlpronouns=srlp, quotations=quots)
    imapping = result.response_dict['result']
    return {'imapping': imapping}
Пример #14
0
def MUSE_semantic_role_labeling_tuk(input_dict):
    url = input_dict['url']
    data = input_dict['xml']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.semantic_role_labeling_tuk(xml=data)
    srl, txt = result.response_dict['result']

    return {'xml': srl, 'txt': txt}
Пример #15
0
def MUSE_PG_GDEE_path(input_dict):
    url = input_dict['url']
    path = input_dict['path']
    lang = input_dict['lang']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.PG_GDEE_path(path=path, lang=lang)
    result = result.response_dict['result']
    return {'xml': result}
Пример #16
0
def MUSE_pronoun_resolution(input_dict):
    url = input_dict['url']
    srl = input_dict['srl']
    coref = input_dict['coref']
    entities = input_dict['entities'].replace(' ', '')

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.pronoun_resolution(srl=srl, coref=coref, entities=entities)
    srlp = result.response_dict['result']
    return {'srlpronouns': srlp}
Пример #17
0
def MUSE_directspeech(input_dict):
    url = input_dict['url']
    srl = input_dict['srl']
    coref = input_dict['coref']
    entities = input_dict['entities'].replace(' ', '')

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.direct_speech(srl=srl, coref=coref, entities=entities)
    dspeech = result.response_dict['result']
    return {'directspeech': dspeech}
Пример #18
0
def testAlbumService():

    print("\n\nTesting AlbumService:\n")
    # Load the AlbumService description
    album_client = JSONWSPClient(base_url +
                                 '/AlbumService/jsonwsp/description')

    # Fetch albums containing the substring "Zoo" in the album title
    jsonwsp_resp = album_client.listAlbums(search_frase='Bowie')
    print_result(jsonwsp_resp)

    # Fetch all bands containing the substring "Bowie" in the band name
    jsonwsp_resp = album_client.listBands(search_frase='Bowie')
    print_result(jsonwsp_resp)
Пример #19
0
def MUSE_PG_mappingVWR(input_dict):
    url = input_dict['url']
    srl = input_dict['srl']
    coref = input_dict['coref']
    info = input_dict['info']
    events = input_dict['events']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.PG_mappingVWR(srl=srl, coref=coref, info=info, events=events)
    mapping = result.response_dict['result']

    return {'mapping': mapping}
Пример #20
0
def testTransferService():
    global files_dir, download_dir

    print("\n\nTesting TransferService:\n")
    # Load the TransferService description
    transfer_client = JSONWSPClient(base_url +
                                    '/TransferService/jsonwsp/description')

    # File list for the upload() call
    file_list = []
    # list of file names fot the download() call
    name_list = []

    # Get a list of files in the "files" folder
    files = os.listdir(files_dir)
    for f in files:
        fpath = os.path.join(files_dir, f)
        # Check if the entry is a file
        if os.path.isfile(fpath):
            # Add the file as a TransferService.File object (for the upload() call)
            file_list += [{
                'data':
                open(fpath, 'rb'),  # Attach the file using an open file-handle
                'name': f  # The file name
            }]

            # Add the file name to the list of file names (for the download() call)
            name_list += [f]

    # Upload multiple files (all files found in the "files" directory) in one request
    jsonwsp_resp = transfer_client.upload(incomming=file_list)
    print_result(jsonwsp_resp)

    # Download all the files we just uploaded in one request
    jsonwsp_resp = transfer_client.download(names=name_list)
    print_result(jsonwsp_resp)

    # The attachments are referenced as open file-handles in the response object
    # read their content and save it as files in the "download" folder.
    if jsonwsp_resp.status == 200:
        for f in jsonwsp_resp.response_dict['result']:
            print(f)
            fp = open(os.path.join(download_dir, f['name']), 'wb')
            fp.write(f['data'].read())
            fp.close()
Пример #21
0
def test_ShopService():
    album_client = JSONWSPClient(
        'http://localhost:8099/service/ShopService/jsonwsp/description')
    m_Grocery1 = {
        'item_name': '苹果',
        'price': 5,
    }
    m_Grocery2 = {
        'item_name': '香蕉',
        'price': 6,
    }
    m_Purchase1 = {
        'grocery': m_Grocery1,
        'quantity': 2,
    }
    m_Purchase2 = {
        'grocery': m_Grocery1,
        'quantity': 3,
    }
    m_GroceryList = {'purchases': [m_Purchase1, m_Purchase2]}
    jsonwsp_resp = album_client.addToBasket(glist=m_GroceryList)
    print jsonwsp_resp.response_dict['result']
Пример #22
0
def getOpcServer(opt):
    global base_url
    print "\n\nGet OPC Server Name from Server"
    opc_read = JSONWSPClient(base_url + '/LoadOPC/jsonwsp/description')
    jsonwsp_resp = opc_read.get_server(a=opt)
    return print_result(jsonwsp_resp)
Пример #23
0
from ladon.clients.jsonwsp import JSONWSPClient
import pprint

cli = JSONWSPClient('http://127.0.0.1:8888/TestService/jsonwsp/description')

r = cli.createServerFault()
pprint.pprint(r.response_dict)

r = cli.blameClientFault()
pprint.pprint(r.response_dict)

r = cli.unmanagedFault(anumber=1)
pprint.pprint(r.response_dict)

r = cli.unmanagedFault(anumber='hfiuwef')
pprint.pprint(r.response_dict)