From 02b8ce82124b0633e003cc0afa8ee6a3d6c4588c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20S=C3=A1nchez?= Date: Mon, 21 Oct 2013 04:26:10 -0700 Subject: [PATCH 1/6] --- PT_HA_to_Marl | 47 ++++++++++++++++++++++++++++++++++++++++++++ PT_SA_to_Marl | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 PT_HA_to_Marl create mode 100644 PT_SA_to_Marl diff --git a/PT_HA_to_Marl b/PT_HA_to_Marl new file mode 100644 index 0000000..bfc3227 --- /dev/null +++ b/PT_HA_to_Marl @@ -0,0 +1,47 @@ +{ + "@context": { + "marl": "http://gsi.dit.upm.es/ontologies/marl#", + "pt": "http://paradigmatecnologico.com/domains#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "marl:domain": { + "@type": "@id" + }, + "field0": { + "@id": "_:field0", + "@type" : "xsd:string" + }, + "field3": { + "@id": "_:field3", + "@type" : "xsd:string" + }, + "field4": { + "@id": "_:field4", + "@type" : "xsd:string" + } + }, + "@graph": [ + + { + "@id": "{{ linesplit(f.name,"/")[-1] }}", + "@type": "marl:SentimentAnalysis", + "marl:maxPolarityValue": 10, + "marl:minPolarityValue": 0 + }, +{% for line in f %} +{% set i=linesplit(line, "\t") %} +{% set node="_:BlankNode%s" % loop.index %} + { + "@id": "{{ node }}", + "@type": "marl:opinion", + "marl:opinionText": "{{ i[2] | escape }}", + "marl:extractedfrom": "{{ i[5] }}", + "marl:domain": "pt:{{ i[1] }}", + "marl:polarityValue": {{ i[6] }}, + "field0": "{{ i[0] }}", + "field3": "{{ i[3] }}", + "field4": "{{ i[4] }}" + + } {% if not loop.last %} , {% endif %} +{% endfor %} +] +} \ No newline at end of file diff --git a/PT_SA_to_Marl b/PT_SA_to_Marl new file mode 100644 index 0000000..adb7d75 --- /dev/null +++ b/PT_SA_to_Marl @@ -0,0 +1,54 @@ +{ + "@context": { + "marl": "http://gsi.dit.upm.es/ontologies/marl#", + "pt": "http://paradigmatecnologico.com/domains#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "marl:domain": { + "@type": "@id" + }, + "field2": { + "@id": "_:field2", + "@type" : "xsd:string", + "http://www.w3.org/2000/01/rdf-schema#label": "Field with the POS tagging" + }, + "field3": { + "@id": "_:field3", + "@type" : "xsd:string", + "http://www.w3.org/2000/01/rdf-schema#label": "Modified version of the source, verbs in infinitive and singular forms" + }, + "field3": { + "@id": "_:field3", + "@type" : "xsd:string", + "http://www.w3.org/2000/01/rdf-schema#label": "Modified version of the source, verbs in infinitive and singular forms" + }, + "field4": { + "@id": "_:field4", + "@type" : "xsd:string", + "http://www.w3.org/2000/01/rdf-schema#label": "Entity" + } + }, + "@graph": [ + + { + "@id": "{{ linesplit(f.name,"/")[-1] }}", + "@type": "marl:SentimentAnalysis", + "marl:maxPolarityValue": 10, + "marl:minPolarityValue": 0 + }, +{% for line in f %} +{% set i=linesplit(line, "\t") %} +{% set node="_:BlankNode%s" % loop.index %} + { + "@id": "{{ node }}", + "@type": "marl:opinion", + "marl:opinionText": "{{ i[1] | escape }}", + "marl:domain": "pt:{{ i[0] }}", + "marl:polarityValue": {{ i[5] }}, + "field0": "{{ i[0] | escape }}", + "field3": "{{ i[3] | escape }}", + "field4": "{{ i[4] | escape }}" + + } {% if not loop.last %} , {% endif %} +{% endfor %} +] +} \ No newline at end of file From ab5f7d61bd38f3559ef918dc62a9c5eba8467325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20S=C3=A1nchez?= Date: Mon, 21 Oct 2013 08:40:57 -0700 Subject: [PATCH 2/6] --- ES_MA_to_Marl | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 ES_MA_to_Marl diff --git a/ES_MA_to_Marl b/ES_MA_to_Marl new file mode 100644 index 0000000..d8b099c --- /dev/null +++ b/ES_MA_to_Marl @@ -0,0 +1,75 @@ +{% set sheet=f.sheet_by_index(0) %} +{ + "@context": { + "marl": "http://gsi.dit.upm.es/ontologies/marl#", + "expsys": "http://expertsystems.com/domains#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "prov": "http://www.w3.org/ns/prov#", + "marl:domain": { + "@type": "@id" + }, + "brand": { + "@id": "_:brand", + "@type" : "xsd:string", + "http://www.w3.org/2000/01/rdf-schema#label": "Brand of the entity" + }, + "model": { + "@id": "_:model", + "@type" : "xsd:string", + "http://www.w3.org/2000/01/rdf-schema#label": "Model of the entity" + }, + "part": { + "@id": "_:part", + "@type" : "xsd:string", + "http://www.w3.org/2000/01/rdf-schema#label": "Part of the entity" + }, + "quality": { + "@id": "_:quality", + "@type" : "xsd:string", + "http://www.w3.org/2000/01/rdf-schema#label": "Quality" + }, + "emotion": { + "@id": "_:emotion", + "@type" : "xsd:string", + "http://www.w3.org/2000/01/rdf-schema#label": "Emotion" + } + }, + "@graph": [ + { + {% set analysisName = "".join(linesplit(filename,"/")[-1].rsplit(".")[:-1]) %} + "@id": "{{ analysisName}}", + "@type": "marl:SentimentAnalysis" + } +{% for i in range(1, sheet.nrows) %} +{% set node="_:BlankNode%s" % i %} + {% set row= sheet.row_values(i) %} + {% set TEXT = row[0] %} + {% set LEMMA = row[1] %} + {% set WN_POS = row[2] %} + {% set WN_SYNSET = row[3] %} + {% set DOMAIN = row[4] %} + {% set BRAND = row[5] %} + {% set KIND = row[6] %} + {% set PRODUCT = row[7] %} + {% set PART = row[8] %} + {% set QUALITY = row[9] %} + {% set SENTIMENT = row[10] %} + {% set EMOTION = row[11] %} + {% if DOMAIN %} + ,{ + "@id": "{{ node }}", + "@type": "marl:opinion", + "marl:opinionText": {{ TEXT | escapejs }}, + "marl:domain": "expsys:{{ DOMAIN | escape }}", + "marl:polarity": "expsys:{{ SENTIMENT | escape }}", + "brand": {{ BRAND | escapejs }}, + "kind": {{ KIND | escapejs }}, + "product": {{ PRODUCT | escapejs }}, + "quality": {{ QUALITY | escapejs }}, + "emotion": {{ EMOTION | escapejs }}, + "prov:wasGeneratedBy": "{{ analysisName }}" + } + {% endif %} +{% endfor %} +] +} \ No newline at end of file From adb813afb46fe41d5bc88933f90d7eeafeca8b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20S=C3=A1nchez?= Date: Mon, 21 Oct 2013 08:41:53 -0700 Subject: [PATCH 3/6] --- PT_MA_to_Marl | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 PT_MA_to_Marl diff --git a/PT_MA_to_Marl b/PT_MA_to_Marl new file mode 100644 index 0000000..edddfa3 --- /dev/null +++ b/PT_MA_to_Marl @@ -0,0 +1,49 @@ +{ + "@context": { + "marl": "http://gsi.dit.upm.es/ontologies/marl#", + "pt": "http://paradigmatecnologico.com/domains#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "marl:domain": { + "@type": "@id" + }, + "field2": { + "@id": "_:field2", + "@type" : "xsd:string", + "http://www.w3.org/2000/01/rdf-schema#label": "Field with the POS tagging" + }, + "field3": { + "@id": "_:field3", + "@type" : "xsd:string", + "http://www.w3.org/2000/01/rdf-schema#label": "Modified version of the source, verbs in infinitive and singular forms" + }, + "field4": { + "@id": "_:field4", + "@type" : "xsd:string", + "http://www.w3.org/2000/01/rdf-schema#label": "Entity" + } + }, + "@graph": [ + + { + "@id": "{{ linesplit(f.name,"/")[-1] }}", + "@type": "marl:SentimentAnalysis", + "marl:maxPolarityValue": 10, + "marl:minPolarityValue": 0 + }, +{% for line in f %} +{% set i=linesplit(line, "\t") %} +{% set node="_:BlankNode%s" % loop.index %} + { + "@id": "{{ node }}", + "@type": "marl:opinion", + "marl:opinionText": {{ i[1] | escapejs }}, + "marl:domain": "pt:{{ i[0] }}", + "marl:polarityValue": {{ i[5] }}, + "field0": {{ i[0] | escapejs }}, + "field3": {{ i[3] | escapejs }}, + "field4": {{ i[4] | escapejs }} + + } {% if not loop.last %} , {% endif %} +{% endfor %} +] +} \ No newline at end of file From 87d74170616117b2673802a4b6fe7fbb47297583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20S=C3=A1nchez?= Date: Mon, 21 Oct 2013 08:42:24 -0700 Subject: [PATCH 4/6] --- PT_SA_to_Marl | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/PT_SA_to_Marl b/PT_SA_to_Marl index adb7d75..39c03cc 100644 --- a/PT_SA_to_Marl +++ b/PT_SA_to_Marl @@ -16,19 +16,19 @@ "@type" : "xsd:string", "http://www.w3.org/2000/01/rdf-schema#label": "Modified version of the source, verbs in infinitive and singular forms" }, - "field3": { - "@id": "_:field3", - "@type" : "xsd:string", - "http://www.w3.org/2000/01/rdf-schema#label": "Modified version of the source, verbs in infinitive and singular forms" - }, "field4": { "@id": "_:field4", "@type" : "xsd:string", "http://www.w3.org/2000/01/rdf-schema#label": "Entity" + }, + "field6": { + "@id": "_:field6", + "@type" : "xsd:string", + "http://www.w3.org/2000/01/rdf-schema#label": "Synsets in the text" } }, "@graph": [ - + { "@id": "{{ linesplit(f.name,"/")[-1] }}", "@type": "marl:SentimentAnalysis", @@ -41,13 +41,14 @@ { "@id": "{{ node }}", "@type": "marl:opinion", - "marl:opinionText": "{{ i[1] | escape }}", + "marl:opinionText": {{ i[1] | escapejs }}, "marl:domain": "pt:{{ i[0] }}", "marl:polarityValue": {{ i[5] }}, - "field0": "{{ i[0] | escape }}", - "field3": "{{ i[3] | escape }}", - "field4": "{{ i[4] | escape }}" - + "field0": {{ i[0] | escapejs }}, + "field3": {{ i[3] | escapejs }}, + "field4": {{ i[4] | escapejs }}, + "field6": {{ i[6] | escapejs }} + } {% if not loop.last %} , {% endif %} {% endfor %} ] From 848622e34e8a31024a0ccdef7bbcbbd3fdbf8968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Thu, 20 Feb 2014 08:03:09 -0800 Subject: [PATCH 5/6] --- ES_MA_NIF | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ PT_HA_NIF | 80 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+) create mode 100644 ES_MA_NIF create mode 100644 PT_HA_NIF diff --git a/ES_MA_NIF b/ES_MA_NIF new file mode 100644 index 0000000..cbab36b --- /dev/null +++ b/ES_MA_NIF @@ -0,0 +1,102 @@ +{% set sheet=f.sheet_by_index(0) %} +{ + "@context": { + "@base": "http://demos.gsi.dit.upm.es/eurosentiment/generator#{{ filename }}", + "dc": "http://purl.org/dc/terms/", + "dc:subject": { + "@type": "@id" + }, + "emotions": { + "@container": "@list", + "@id": "onyx:hasEmotionSet", + "@type": "onyx:EmotionSet" + }, + "marl": "http://www.gsi.dit.upm.es/ontologies/marl#", + "nif": "http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#", + "onyx": "http://www.gsi.dit.upm.es/ontologies/onyx#", + "pt": "http://paradigmatecnologico.com/domains#", + "opinions": { + "@container": "@list", + "@id": "marl:hasOpinion", + "@type": "marl:Opinion" + }, + "prov": "http://www.w3.org/ns/prov#", + "rdfs": "http://www.w3.org/2000/01/rdf-schema#", + "results": { + "@container": "@index", + "@id": "@graph" + }, + "strings": { + "@reverse": "nif:hasContext", + "@type": "nif:String" + }, + "wnaffect": "http://www.gsi.dit.upm.es/ontologies/wnaffect#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "brand": { + "@id": "_:brand", + "@type" : "xsd:string", + "http://www.w3.org/2000/01/rdf-schema#label": "Brand of the entity" + }, + "model": { + "@id": "_:model", + "@type" : "xsd:string", + "http://www.w3.org/2000/01/rdf-schema#label": "Model of the entity" + }, + "part": { + "@id": "_:part", + "@type" : "xsd:string", + "http://www.w3.org/2000/01/rdf-schema#label": "Part of the entity" + }, + "quality": { + "@id": "_:quality", + "@type" : "xsd:string", + "http://www.w3.org/2000/01/rdf-schema#label": "Quality" + } + }, + "results": { + "analysis": [ + { + {% set analysisName = "".join(linesplit(filename,"/")[-1].rsplit(".")[:-1]) %} + "@id": "{{ analysisName}}", + "@type": "marl:SentimentAnalysis" + } +], +"entries": [ +{% set first = True %} +{% for i in range(1, sheet.nrows) %} +{% set node="_:BlankNode%s" % i %} + {% set row= sheet.row_values(i) %} + {% set TEXT = row[0] %} + {% set LEMMA = row[1] %} + {% set WN_POS = row[2] %} + {% set WN_SYNSET = row[3] %} + {% set DOMAIN = row[4] %} + {% set BRAND = row[5] %} + {% set KIND = row[6] %} + {% set PRODUCT = row[7] %} + {% set PART = row[8] %} + {% set QUALITY = row[9] %} + {% set SENTIMENT = row[10] %} + {% set EMOTION = row[11] %} + {% if DOMAIN %} + {% if first %} {% set first = False %} {% else %} ,{% endif %} { + "@id": "{{ node }}", + "dc:subject": "expsys:{{ DOMAIN | escape }}", + "strings": [ {{ TEXT | escapejs }} ], + "opinions": [ { + "marl:polarity": "expsys:{{ SENTIMENT | escape }}", + "brand": {{ BRAND | escapejs }}, + "kind": {{ KIND | escapejs }}, + "product": {{ PRODUCT | escapejs }}, + "quality": {{ QUALITY | escapejs }} + }], + "emotions": [ { + "onyx:hasEmotion": { "onyx:hasEmotionCategory": {{ EMOTION | escapejs }} } + }], + "prov:wasGeneratedBy": "{{ analysisName }}" + } + {% endif %} +{% endfor %} +] +} +} \ No newline at end of file diff --git a/PT_HA_NIF b/PT_HA_NIF new file mode 100644 index 0000000..ce1add7 --- /dev/null +++ b/PT_HA_NIF @@ -0,0 +1,80 @@ +{ + "@context": { + "@base": "http://demos.gsi.dit.upm.es/eurosentiment/generator#{{ filename }}", + "dc": "http://purl.org/dc/terms/", + "dc:subject": { + "@type": "@id" + }, + "emotions": { + "@container": "@list", + "@id": "onyx:hasEmotionSet", + "@type": "onyx:EmotionSet" + }, + "marl": "http://www.gsi.dit.upm.es/ontologies/marl#", + "nif": "http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#", + "onyx": "http://www.gsi.dit.upm.es/ontologies/onyx#", + "pt": "http://paradigmatecnologico.com/domains#", + "opinions": { + "@container": "@list", + "@id": "marl:hasOpinion", + "@type": "marl:Opinion" + }, + "prov": "http://www.w3.org/ns/prov#", + "rdfs": "http://www.w3.org/2000/01/rdf-schema#", + "results": { + "@container": "@index", + "@id": "@graph" + }, + "strings": { + "@reverse": "nif:hasContext", + "@type": "nif:String" + }, + "wnaffect": "http://www.gsi.dit.upm.es/ontologies/wnaffect#", + "xsd": "http://www.w3.org/2001/XMLSchema#" + }, + "@id": "{{ linesplit(f.name,"/")[-1] }}", + "results": { + "analysis": [ + { + "@id": "{{ linesplit(f.name,"/")[-1] }}#Analysis1", + "@type": [ + "marl:SentimentAnalysis" + ], + "dc:language": "{{ language}}", + "marl:maxPolarityValue": 1.0, + "marl:minPolarityValue": 0.0 + } + ], + "entries": [ +{% for line in f %} +{% set i=linesplit(line, "\t") %} +{% set node="_:BlankNode%s" % loop.index %} + { + "@id": "{{ node }}", + "dc:subject": "pt:{{ i[1] }}", + "opinions": [ + { +{% set pol= i[6] | int %} +{% if pol%} + "marl:polarityValue": {{ pol }}, +{% if pol > 5 %} + "marl:hasPolarity": "marl:Positive", +{% elif pol < 5 %} + "marl:hasPolarity": "marl:Negative", +{% else %} + "marl:hasPolarity": "marl:Neutral", +{% endif %} +{% endif %} + "marl:describesObject": "pt:{{ i[3] }}", + "marl:extractedFrom": "{{ i[5] }}" + } + ], + "nif:isString": {{ i[2] | escapejs }}, + "prov:generatedBy": "pt:agent", + "strings": [ + ] + } {% if not loop.last %} , {% endif %} +{% endfor%} + ] + } +} \ No newline at end of file From cb19669f89c51f6fd189a8e4c30765d7c976e140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Tue, 11 Mar 2014 12:48:22 -0700 Subject: [PATCH 6/6] --- TripAdvisor.json | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 TripAdvisor.json diff --git a/TripAdvisor.json b/TripAdvisor.json new file mode 100644 index 0000000..6c53587 --- /dev/null +++ b/TripAdvisor.json @@ -0,0 +1,88 @@ +{ + "@context": "http://demos.gsi.dit.upm.es/eurosentiment/static/context.jsonld", + "analysis": [ + { + "@id": "es:TripAdvisor", + "@type": [ + "marl:SentimentAnalysis" + ], + "marl:maxPolarityValue": 0.0, + "marl:minPolarityValue": 5.0 + } + ], + "entries": [ +{% set current = {} %} +{% set number = 0 %} +{% for line in f %} + {% if line[0] != "<" or loop.last %} + {% if "Author" in current %} + { + "nif:isString": {{ current["Content"] | escapejs}}, + "dc:language": "en", + "prov:wasDerivedFrom": { + "@type": "es:TripadvisorComment", + "date": "{{ convertDate(current["Date"], "%b %d, %Y") if "Date" in current}}"{% if "Author" in current %}, + "user": {{ current["Author"] | escapejs }} + {% endif %} + }, + "opinions": [ + {% if "Overall" in current %} + { + "@id": "_:Opinion{{ number }}1", + "marl:hasPolarity": "marl:Positive", + "marl:polarityValue": {{ current["Overall"] }}, + "marl:describesObjectFeature": "Overall" + }, {%endif %}{% if "Value" in current %} + { + "@id": "_:Opinion{{ number }}2", + "marl:hasPolarity": "marl:Positive", + "marl:polarityValue": {{ current["Value"] }}, + "marl:describesObjectFeature": "es:Value" + }, {% endif %}{% if "Rooms" in current %} + { + "@id": "_:Opinion{{ number }}3", + "marl:hasPolarity": "marl:Positive", + "marl:polarityValue": {{ current["Rooms"] }}, + "marl:describesObjectPart": "es:Rooms" + }, {% endif %}{% if "Location" in current %} + { + "@id": "_:Opinion{{ number }}4", + "marl:hasPolarity": "marl:Positive", + "marl:polarityValue": {{ current["Location"] }}, + "marl:describesObjectFeature": "es:Location" + }, {% endif %}{% if "Cleanliness" in current %} + { + "@id": "_:Opinion{{ number }}5", + "marl:hasPolarity": "marl:Positive", + "marl:polarityValue": {{ current["Cleanliness"] }}, + "marl:describesObjectFeature": "es:Cleanliness" + }, {% endif %}{% if "Check in / front desk" in current %} + { + "@id": "_:Opinion{{ number }}6", + "marl:hasPolarity": "marl:Positive", + "marl:polarityValue": {{ current["Check in / front desk"] }}, + "marl:describesObjectPart": "es:Check_In" + }, {% endif %}{% if "Service" in current %} + { + "@id": "_:Opinion{{ number }}7", + "marl:hasPolarity": "marl:Positive", + "marl:polarityValue": {{ current["Service"] }}, + "marl:describesObjectFeature": "es:Service" + }, {% endif %}{% if "Business service" in current %} { + "@id": "_:Opinion{{ number }}8", + "marl:hasPolarity": "marl:Positive", + "marl:polarityValue": {{ current["Business service"] }}, + "marl:describesObjectPart": "es:Business_Service" + }{% endif %} + ] + } {{ "," if not loop.last }} + {% endif %} + {% set current = {} %} + {% set number = number+1 %} + {% else %} + {% set attr,value = line[1:].strip().split(">", 1) %} + {% do current.update({attr: value}) %} + {% endif %} +{% endfor %} + ] +}