我如何在西班牙语中使用Stanford NLP词性标签?

问题描述 投票:0回答:1

我正在与Stanford CoreNLP合作,我对此表示怀疑。我想确定每个单词的语法类别,并在命令行中使用以下命令执行文本时:

java -cp "*" -Xmx2g edu.stanford.nlp.pipeline.StanfordCoreNLP -props StanfordCoreNLP-spanish.properties  -annotators tokenize,ssplit,pos, ner  -file entrada.txt -outputFormat conll

输出类似于:

1       tomar   _       VERB    _       _       _
2       una     _       DET     _       _       _
3       cerveza _       NOUN    _       _       _
4       en      _       ADP     _       _       _
5       Madrid  _       PROPN   _       _       _

但是当我从NetBeans执行以下代码时:

Properties props = new Properties();
        props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner");
        props.setProperty("tokenize.language", "es");
        props.setProperty("pos.model", "edu/stanford/nlp/models/pos-tagger/spanish/spanish-distsim.tagger");
        props.setProperty("ner.model", "edu/stanford/nlp/models/ner/spanish.ancora.distsim.s512.crf.ser.gz");
        props.setProperty("ner.applyNumericClassifiers", "true");
        props.setProperty("ner.useSUTime", "false");
        props.setProperty("ner.applyFineGrained", "false");
        props.setProperty("ner.language", "es");

        String text = "Ver una película de miedo, pasear por un parque";
        StanfordCoreNLP pipeline = new StanfordCoreNLP(props);

        Annotation document = new Annotation(text);


        pipeline.annotate(document);
        List<CoreMap> sentences = document.get(SentencesAnnotation.class);
        for(CoreMap sentence: sentences) {
            for (CoreLabel token: sentence.get(TokensAnnotation.class)) {
              String g = token.tag();
              String word = token.get(TextAnnotation.class);
              String pos = token.get(PartOfSpeechAnnotation.class);
              String ne = token.get(NamedEntityTagAnnotation.class);
              String lema = token.get(LemmaAnnotation.class);


              System.out.println(String.format("[%s] "
                      + "[%s] "
                      + "[%s] "
                      + "[%s] " , word, pos, ne, lema));
            }
        }

输出是这样的:

[Ver] [vmn0000] [O] [ver] 
[una] [di0000] [O] [una] 
[película] [nc0s000] [O] [película] 
[de] [sp000] [O] [de] 
[miedo] [nc0s000] [O] [miedo] 
[,] [fc] [O] [,] 
[pasear] [vmn0000] [O] [pasear] 
[por] [sp000] [O] [por] 
[un] [di0000] [O] [un] 
[parque] [nc0s000] [O] [parque] 

所以,如何在“动词”中转换“ vmn0000”之类的标签?

先谢谢您!

java nlp stanford-nlp part-of-speech
1个回答
0
投票

请确保将Stanford CoreNLP 3.9.2和UD模型用于词性。

edu/stanford/nlp/models/pos-tagger/spanish/spanish-ud.tagger
© www.soinside.com 2019 - 2024. All rights reserved.