Exemplo n.º 1
0
# -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2021-01-08 12:44
import elit
from elit.pretrained.mtl import LEM_POS_NER_DEP_SDP_CON_AMR_ROBERTA_BASE_EN
from elit.server.en_util import eos, tokenize
from elit.server.service_parser import ServiceParser
from elit.server.service_tokenizer import ServiceTokenizer

service_tokenizer = ServiceTokenizer(eos, tokenize)
service_parser = ServiceParser(
    service_tokenizer=service_tokenizer,
    model=elit.load(LEM_POS_NER_DEP_SDP_CON_AMR_ROBERTA_BASE_EN))
Exemplo n.º 2
0
class BundledServices:
    def __init__(self,
                 tokenizer: ServiceTokenizer = None,
                 parser: ServiceParser = None,
                 doc_coref: ServiceCoreference = None,
                 online_coref: ServiceCoreference = None):
        self.tokenizer = tokenizer
        self.parser = parser
        self.doc_coref = doc_coref
        self.online_coref = online_coref
        self.emotion_detection = None


service_doc_coref = ServiceCoreference(
    service_tokenizer=service_tokenizer,
    models=elit.load(DOC_COREF_SPANBERT_LARGE_EN))
# service_doc_coref = ServiceCoreference(
#     service_tokenizer=service_tokenizer,
#     models=[elit.load(DOC_COREF_SPANBERT_LARGE_EN, devices=0),
#             elit.load(DOC_COREF_SPANBERT_LARGE_EN, devices=1)]
# )

service_online_coref = ServiceCoreference(
    service_tokenizer=service_tokenizer,
    models=elit.load(ONLINE_COREF_SPANBERT_LARGE_EN))

en_services = BundledServices(tokenizer=service_tokenizer,
                              parser=service_parser,
                              doc_coref=service_doc_coref,
                              online_coref=service_online_coref)
Exemplo n.º 3
0
 def test_parse(self):
     parser = elit.load(elit.pretrained.amr.AMR3_BART_LARGE_EN)
     amr = parser('The boy wants the girl to believe him.')
     print(amr)
Exemplo n.º 4
0
 def test_parse(self):
     parser = elit.load('KOREAN_TREEBANK_BIAFFINE_DEP')
     tree = parser('그는 르노가 3 월말까지 인수제의 시한을 갖고 있다고 덧붙였다 .'.split())
     print(tree)
Exemplo n.º 5
0
# ========================================================================
# Copyright 2020 Emory University
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ========================================================================

# -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2021-01-08 12:44
import elit
from elit.server import parser_config
from elit.server.en_util import eos, tokenize
from elit.server.service_parser import ServiceParser
from elit.server.service_tokenizer import ServiceTokenizer

service_tokenizer = ServiceTokenizer(eos, tokenize)
service_parser = ServiceParser(
    service_tokenizer=service_tokenizer,
    model=elit.load(parser_config.MTL_MODEL)
)
Exemplo n.º 6
0
 def build_teacher(self, teacher: str, devices) -> TorchComponent:
     return elit.load(teacher, load_kwargs={'devices': devices})