allenai / allennlp

An open-source NLP research library, built on PyTorch.
http://www.allennlp.org
Apache License 2.0
11.75k stars 2.25k forks source link

error output #5080

Closed shihuanting closed 3 years ago

shihuanting commented 3 years ago

I havr a problem,hope you can give me some advice

from allennlp.predictors.predictor import Predictor
import allennlp_models.tagging
from allennlp.models import archival

def TestSRL():
    input = {"sentence": "However, voters decided that if the stadium was such a good idea someone would build it himself, and rejected it 59% to 41%."}
    arc = archival
    arch = arc.load_archive('D:/srl-model-2018.05.25.tar.gz')
    predictor = Predictor.from_archive(arch, 'semantic-role-labeling')
    result = predictor.predict_json(input)
    print(result)

if __name__ == '__main__':
    TestSRL()

error output: allennlp.common.checks.ConfigurationError: srl not in acceptable choices for dataset_reader.type: ['babi', 'conll2003', 'interleaving', 'multitask', 'sequence_tagging', 'sharded', 'text_classification_json', 'multitask_shim', 'ccgbank', 'conll2000', 'ontonotes_ner']. You should either use the --include-package flag to make sure the correct module is loaded, or use a fully qualified class name in your config file like {"model": "my_module.models.MyModel"} to have it imported automatically.

allennlp == 2.2.0
allennlp_models ==2.2.0

Thank you for your reply

dirkgr commented 3 years ago

Replace this line:

import allennlp_models.tagging

with this

import allennlp_models.structured_prediction

I'll also add that Windows is not officially supported (but it may work for you anyways).

github-actions[bot] commented 3 years ago

@dirkgr this is just a friendly ping to make sure you haven't forgotten about this issue 😜