Examples

Here are some examples of linguistic analyses using MeaningCloud:

Syntactic analysis of a sentence

To show how to carry out a syntactic analysis extracting topics we will use the following text as an example:

"Robert Downey Jr has topped Forbes magazine's annual list of the highest paid actors for the second year in a row."

  • Use the txt parameter to submit the text.
  • Choose with lang the language in which the text is going to be analyzed, in this case English, en.
  • Include your MeaningCloud license key as value for key parameter.
  • Choose an output format, for instance json as value for of.
  • Change the default value of the unknown words parameter, uwso the engine tries to find possible analysis when there are typos in the text.
  • Send tt with the value eto obtain the entities detected in the text in the corresponding token.
Example using curl:
curl 'http://api.meaningcloud.com/parser-2.0' \
    --form 'key=YOUR API KEY' \
    --form 'lang=en' \
    --form 'txt=Robert Downey Jr has topped Forbes magazines annual list of the highest paid actors for the second year in a row.' \
    --form 'uw=y' \
    --form 'tt=e'
MeaningCloud API output:
{
"status":{
"code":
"0"
"msg":
"OK"
"credits":
"1"
}
"token_list":[
0:{
"type":
"sentence"
"id":
"15"
"inip":
"0"
"endp":
"66"
"style":{
...
}
"separation":
"A"
"quote_level":
"0"
"affected_by_negation":
"no"
"sentiment":{
...
}
"token_list":[
...
]
}
]
"global_sentiment":{
"model":
"general_en"
"score_tag":
"P"
"agreement":
"AGREEMENT"
"subjectivity":
"OBJECTIVE"
"confidence":
"100"
"irony":
"NONIRONIC"
}
}

Morphological analysis of a sentence

To show how to work with the output to obtain the morphological analysis of a sentence we will use the following text as an example:

"Robert Downey Jr has topped Forbes magazine's annual list of the highest paid actors for the second year in a row."

We will:

  • Use the txt parameter to submit the text.
  • Choose with lang the language in which the text is going to be analyzed, in this case English, en.
  • Include your MeaningCloud license key as value for key parameter.
  • Choose an output format, for instance json as value for of.
  • Activate the verbose parameter to obtain the morphological tag explained.

The following code contains a request to the API using this parameters, and processes the output to obtain an array (morpho) with the tokens with the morphological analysis. After that we will print them

The code would be called like this:
php parser-2.0-gist-morpho.php
And this will be the output for the example sentence:

Lemmatization of a sentence

To show how to work with the output to lemmatize a sentence we will use the following text as an example:

"Robert Downey Jr has topped Forbes magazine's annual list of the highest paid actors for the second year in a row."

We will:

  • Use the txt parameter to submit the text.
  • Choose with lang the language in which the text is going to be analyzed, in this case English, en.
  • Include your MeaningCloud license key as value for key parameter.
  • Choose an output format, for instance json as value for of.

The following code contains a request to the API using this parameters, and processes the output to obtain an array (morpho) with the tokens with the morphological analysis. After that we will print them

The code would be called like this:
php parser-2.0-gist-lemma.php

And this will be the output for the example sentence, where for each token the form followed by all the possible lemmas will be printed, and the different levels in the tree will be marked with curly brackets:
Tokens:
  =============
  {{{{Robert Downey Jr|Robert Downey Jr|Robert Downey Jr|Robert Downey Jr|Robert Downey Jr}}{has topped|top}{{{Forbes|Forbes|Forbes|Forbes|Forbes}{magazine|magazine}}{'s|'s}{{annual|annual}{list|list}{{of|of}{{the|the}{highest|high}{paid|pay}{actors|actor}{{for|for}{{the|the}{second|second}{year|year}}}}}}}{{{in|in}{{a|a}{row|row}}}}{.|.}}