Commit 4c6e600f authored by Janez K's avatar Janez K

added new triplet extraction widget

parent d059fbdd
......@@ -6,6 +6,8 @@ Streaming widgets librarby
'''
from workflows.security import safeOpen
from workflows.streaming.tripletclient import TripletClient
def streaming_add_neutral_zone(input_dict):
import copy
......@@ -295,7 +297,21 @@ def streaming_triplet_wordnet_lemmatizer(input_dict,widget,stream=None):
new_triplets.append(new_triplet)
output_dict = {}
output_dict['triplets']=new_triplets
return output_dict
return output_dict
def streaming_triplet_extraction_2(input_dict, widget, stream=None):
output_dict = {}
text = input_dict['text']
t = TripletClient()
triplets = t.reverb(text)
new_triplets = []
for extraction in triplets['extractions']:
triplet = [extraction['arg1'].lower(), extraction['relNorm'].lower(), extraction['arg2'].lower()]
new_triplets.append(triplet)
output_dict['triplets'] = new_triplets
return output_dict
def streaming_triplet_extraction(input_dict,widget,stream=None):
from pysimplesoap.client import SoapClient, SoapFault
......
[
{
"model": "workflows.abstractwidget",
"fields": {
"category": "ca549cd5-2041-46f1-b175-a743b71b0e9b",
"treeview_image": "",
"uid": "1e16b03c-a64b-4907-9a1a-11c84073a70b",
"windows_queue": false,
"package": "streaming",
"interaction_view": "",
"has_progress_bar": false,
"image": "",
"description": "Extracts triplets from sentences.",
"static_image": "triplets.png",
"action": "streaming_triplet_extraction_2",
"visualization_view": "",
"streaming_visualization_view": "",
"post_interact_action": "",
"wsdl_method": "",
"wsdl": "",
"interactive": false,
"is_streaming": true,
"order": 1,
"name": "Triplet Extraction (ver 2)"
}
},
{
"model": "workflows.abstractinput",
"fields": {
"widget": "1e16b03c-a64b-4907-9a1a-11c84073a70b",
"name": "Text",
"short_name": "str",
"default": "",
"description": "Sentences to extract triplets from.",
"required": false,
"multi": false,
"parameter_type": null,
"variable": "text",
"parameter": false,
"order": 1,
"uid": "5e8999ac-6b8c-45ec-9089-3c4f93f24f08"
}
},
{
"model": "workflows.abstractoutput",
"fields": {
"widget": "1e16b03c-a64b-4907-9a1a-11c84073a70b",
"name": "Triplets",
"short_name": "tri",
"description": "Triplets",
"variable": "triplets",
"order": 1,
"uid": "df2091c8-502f-4930-9d11-1b1b148bb060"
}
}
]
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment