KAF to JSON Web Service

Example Usage

kaf2json-server start
curl -d 'input=<?xml version="1.0" encoding="UTF-8"?><KAF xml:lang="en"><kafHeader><linguisticProcessors layer="text"><lp timestamp="2013-04-11T09:21:29CEST" version="1.0" name="Open-nlp sentence splitter"/><lp timestamp="2013-04-11T09:21:29CEST" version="1.0" name="Open-nlp tokenizer"/></linguisticProcessors><linguisticProcessors layer="opinions"><lp timestamp="*" version="1.0" name="Basic opinion detector with Pos"/></linguisticProcessors><linguisticProcessor layer="terms"><lp timestamp="2013-04-11T09:23:08CEST" version="1.0" name="Basic_polarity_tagger_with_pos"/></linguisticProcessor><linguisticProcessor layer="term"><lp timestamp="2013-04-11T09:23:07CEST" version="1.0" name="TreeTagger_from_kaf"/></linguisticProcessor></kafHeader><text><wf wid="w_1" sent="s_1">This</wf><wf wid="w_2" sent="s_1">is</wf><wf wid="w_3" sent="s_1">a</wf><wf wid="w_4" sent="s_1">very</wf><wf wid="w_5" sent="s_1">nice</wf><wf wid="w_6" sent="s_1">hotel</wf><wf wid="w_7" sent="s_1">in</wf><wf wid="w_8" sent="s_1">Amsterdam</wf></text><terms><term tid="t_1" lemma="this" morphofeat="DT" type="close" pos="D"><span><target id="w_1"/></span></term><term tid="t_2" lemma="be" morphofeat="VBZ" type="open" pos="V"><span><target id="w_2"/></span></term><term tid="t_3" lemma="a" morphofeat="DT" type="close" pos="D"><span><target id="w_3"/></span></term><term tid="t_4" lemma="very" morphofeat="RB" type="open" pos="A"><span><target id="w_4"/></span><sentiment sentiment_modifier="intensifier" resource="VUA_olery_lexicon_en_lmf"/></term><term tid="t_5" lemma="nice" morphofeat="JJ" type="open" pos="G"><span><target id="w_5"/></span><sentiment polarity="positive" resource="VUA_olery_lexicon_en_lmf"/></term><term tid="t_6" lemma="hotel" morphofeat="NN" type="open" pos="N"><span><target id="w_6"/></span></term><term tid="t_7" lemma="in" morphofeat="IN" type="close" pos="P"><span><target id="w_7"/></span></term><term tid="t_8" lemma="Amsterdam" morphofeat="NP" type="open" pos="R"><span><target id="w_8"/></span></term></terms><entities><entity eid="e15" type="location"><references><span><!--Amsterdam --><target id="t_8"/></span></references></entity></entities><opinions><opinion oid="o1"><opinion_target><!--hotel--><span><target id="t_6"/></span></opinion_target><opinion_expression polarity="positive" strength="2"><!--very nice--><span><target id="t_4"/><target id="t_5"/></span></opinion_expression></opinion></opinions></KAF>' http://localhost:9292 -XPOST
outputs:
{
"text": "This is a very nice hotel in Amsterdam ",
"language": "en",
"terms": {
"t_1": {
"type": "close",
"lemma": "this",
"text": "This",
"pos": "D",
"morphofeat": "DT"
},
"t_2": {
"type": "open",
"lemma": "be",
"text": "is",
"pos": "V",
"morphofeat": "VBZ"
},
"t_3": {
"type": "close",
"lemma": "a",
"text": "a",
"pos": "D",
"morphofeat": "DT"
},
"t_4": {
"type": "open",
"lemma": "very",
"text": "very",
"pos": "A",
"morphofeat": "RB",
"polarity": ""
},
"t_5": {
"type": "open",
"lemma": "nice",
"text": "nice",
"pos": "G",
"morphofeat": "JJ",
"polarity": "positive"
},
"t_6": {
"type": "open",
"lemma": "hotel",
"text": "hotel",
"pos": "N",
"morphofeat": "NN"
},
"t_7": {
"type": "close",
"lemma": "in",
"text": "in",
"pos": "P",
"morphofeat": "IN"
},
"t_8": {
"type": "open",
"lemma": "Amsterdam",
"text": "Amsterdam",
"pos": "R",
"morphofeat": "NP",
"entity": "e15"
}
},
"sentiments": [
{
"lexicon": "VUA_olery_lexicon_en_lmf",
"polarity": "",
"termId": "t_4",
"text": "very"
},
{
"lexicon": "VUA_olery_lexicon_en_lmf",
"polarity": "positive",
"termId": "t_5",
"text": "nice"
}
],
"entities": {
"e15": {
"type": "location",
"text": "Amsterdam",
"reference": "",
"terms": [
"t_8"
]
}
},
"opinions": {
"o1": {
"holder": "",
"target": "",
"polarity": "positive",
"strength": "2",
"text": "very nice",
"terms": [
"t_4",
"t_5"
]
}
}
}

Try the webservice

* required

** When entering a value no response will be displayed in the browser.













Actions

POST /
Convert the input KAF text. See arguments listing for more options.
GET /
Show this page

Arguments

The webservice takes the following arguments:

* required

text*
The input text in KAF format. Sample KAF input:
<?xml version='1.0' encoding='UTF-8'?>
<KAF xml:lang="en">
<kafHeader>
<linguisticProcessors layer="text">
<lp timestamp="2013-04-11T09:21:29CEST" version="1.0" name="Open-nlp sentence splitter"/>
<lp timestamp="2013-04-11T09:21:29CEST" version="1.0" name="Open-nlp tokenizer"/>
</linguisticProcessors>
<linguisticProcessors layer="opinions">
<lp timestamp="*" version="1.0" name="Basic opinion detector with Pos"/>
</linguisticProcessors>
<linguisticProcessor layer="terms">
<lp timestamp="2013-04-11T09:23:08CEST" version="1.0" name="Basic_polarity_tagger_with_pos"/>
</linguisticProcessor>
<linguisticProcessor layer="term">
<lp timestamp="2013-04-11T09:23:07CEST" version="1.0" name="TreeTagger_from_kaf"/>
</linguisticProcessor>
</kafHeader>
<text>
<wf wid="w_1" sent="s_1">This</wf>
<wf wid="w_2" sent="s_1">is</wf>
<wf wid="w_3" sent="s_1">a</wf>
<wf wid="w_4" sent="s_1">very</wf>
<wf wid="w_5" sent="s_1">nice</wf>
<wf wid="w_6" sent="s_1">hotel</wf>
<wf wid="w_7" sent="s_1">in</wf>
<wf wid="w_8" sent="s_1">Amsterdam</wf>
</text>
<terms>
<term tid="t_1" lemma="this" morphofeat="DT" type="close" pos="D">
<span>
<target id="w_1"/>
</span>
</term>
<term tid="t_2" lemma="be" morphofeat="VBZ" type="open" pos="V">
<span>
<target id="w_2"/>
</span>
</term>
<term tid="t_3" lemma="a" morphofeat="DT" type="close" pos="D">
<span>
<target id="w_3"/>
</span>
</term>
<term tid="t_4" lemma="very" morphofeat="RB" type="open" pos="A">
<span>
<target id="w_4"/>
</span>
<sentiment sentiment_modifier="intensifier" resource="VUA_olery_lexicon_en_lmf"/>
</term>
<term tid="t_5" lemma="nice" morphofeat="JJ" type="open" pos="G">
<span>
<target id="w_5"/>
</span>
<sentiment polarity="positive" resource="VUA_olery_lexicon_en_lmf"/>
</term>
<term tid="t_6" lemma="hotel" morphofeat="NN" type="open" pos="N">
<span>
<target id="w_6"/>
</span>
</term>
<term tid="t_7" lemma="in" morphofeat="IN" type="close" pos="P">
<span>
<target id="w_7"/>
</span>
</term>
<term tid="t_8" lemma="Amsterdam" morphofeat="NP" type="open" pos="R">
<span>
<target id="w_8"/>
</span>
</term>
</terms>
<entities>
<entity eid="e15" type="location">
<references>
<span>
<!--Amsterdam -->
<target id="t_8"/>
</span>
</references>
</entity>
</entities>
<opinions>
<opinion oid="o1">
<opinion_target>
<!--hotel-->
<span>
<target id="t_6"/>
</span>
</opinion_target>
<opinion_expression polarity="positive" strength="2">
<!--very nice-->
<span>
<target id="t_4"/>
<target id="t_5"/>
</span>
</opinion_expression>
</opinion>
</opinions>
</KAF>
callbacks
You can provide a list of callback urls. If you provide callback urls the POS tagger will run as a background job and a callback with the results will be performed (POST) to the first url in the callback list. The other urls in callback list will be provided in the "callbacks" argument.

Using callback you can chain together several OpeNER webservices in one call. The first, will call the second, which will call the third, etc. See for more information the webservice documentation online.
error_callback
URL to notify if errors occur in the background process. The error callback will do a POST with the error message in the 'error' field.