How can I change the code below to produce horizontal annotations in Stanford NLP?

55 views Asked by At

When I use the code java -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma -file 1.txt -outputFormat conll -output.columns lemma to annotate this example sentence

Stanford University is located in California. It is a great university, founded in 1891.

I get the result like this: Annotations formatted vertically But I couldn't manage to output the annotations horizontally. For instance, I could not have the annotated lemmas or POS output this way in a txt file:

Stanford University be locate in California. it be a great university, found in 1891.

I know this must be a very silly question, but it has been bugging me for a while. I know too little about scripting and there's no one around me that I could turn to. I will be very grateful for any generous help to help me modify the code to meet my purpose.

1

There are 1 answers

1
John On

There are a few alternate output formats which you could use. From StanfordCoreNLP.java:

public enum OutputFormat { TEXT, TAGGED, XML, JSON, CONLL, CONLLU, INLINEXML, SERIALIZED, CUSTOM }

SERIALIZED is a protobuf format, probably not too helpful. CUSTOM literally means you write custom code to handle the produced objects. You already know you don't like CONLL, which probably rules out CONLLU as well. Perhaps one of the others will be more to your liking.

Although I will also say that turning my laptop 90 degrees to the right made the output horizontal.