0

I am working with Stanford CoreNLP and I have a doubt. I want to determinate the grammatical category of each word and when I execute the text in the command line with:

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

the output is like :

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

But when I execute from NetBeans with this code:

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));
            }
        }

the output is like this:

[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] 

So, How can I convert the tags like "vmn0000" in "Verb" ?

Thank you in advance !!

  • I don't know and I don't speak Spanish, but I think removing `lemma` and the NER properties might solve the problem – Anwarvic Nov 07 '19 at 20:06

1 Answers1

0

Make sure to use Stanford CoreNLP 3.9.2 and the UD model for part-of-speech.

edu/stanford/nlp/models/pos-tagger/spanish/spanish-ud.tagger
StanfordNLPHelp
  • 8,699
  • 1
  • 11
  • 9