1
0
mirror of https://github.com/balkian/gists.git synced 2025-08-23 15:12:21 +00:00

Move files

This commit is contained in:
J. Fernando Sánchez
2021-10-30 15:23:01 +02:00
parent f798a3e673
commit f48bab94dd
113 changed files with 1 additions and 0 deletions

View File

@@ -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 %}
]
}
}

View File

@@ -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 %}
]
}

View File

@@ -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%}
]
}
}

View File

@@ -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 %}
]
}

View File

@@ -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 %}
]
}

View File

@@ -0,0 +1,55 @@
{
"@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"
},
"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",
"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 }},
"field6": {{ i[6] | escapejs }}
} {% if not loop.last %} , {% endif %}
{% endfor %}
]
}

View File

@@ -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 %}
]
}

View File

@@ -0,0 +1,96 @@
{% set f=open_file("xls") %}
{% set sheet=f.sheet_by_index(0) %}
{% if not baseuri %}
{% set baseuri="default" %}
{% endif %}
{
"@context": [
"http://demos.gsi.dit.upm.es/eurosentiment/static/context.jsonld",
{
"@base": "{{ baseuri }}",
"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"
}
}],
"analysis": [
{
{% set analysisName = baseuri + "#Analysis1" %}
"@id": "{{ analysisName }}",
"@type": "marl:SentimentAnalysis"
}
],
"entries": [
{% set first = True %}
{% set instrings=False %}
{% 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 TEXT %}
{% if DOMAIN %}
{% if first %} {% set first = False %} {% else %} ,{% endif %} {
"@id": "{{ node }}",
"dc:subject": "expsys:{{ DOMAIN | escape }}",
"opinions": [ {
"marl:polarity": "expsys:{{ SENTIMENT | escape }}"
}],
{% if EMOTION %}
"emotions": [ {
"onyx:hasEmotion": { "onyx:hasEmotionCategory": {{ EMOTION | escapejs }} }
}],
{% endif %}
"prov:wasGeneratedBy": "{{ analysisName }}",
"strings": [
{% set instrings = True %}
{% set firstString = True %}
{% else %}
{% if firstString %} {% set firstString = False %} {% else %} ,{% endif %}{
"nif:anchorOf": {{ TEXT | escapejs }}{% if WN_POS not in ("N/S", "N/C") %},
"nif:posTag": {{ WN_POS | escapejs}} {% endif %}{% if LEMMA not in ("#", ) %},
"nif:lemma": {{ LEMMA | escapejs }}{%endif%}{% if WN_SYNSET not in ("N/S", "N/C") %},
"expsys:synset": {{ WN_SYNSET | escapejs }} {% endif %}
}
{% endif %}
{% else %}
{% if instrings %}
{% set instrings=False %}
]
}
{% endif %}
{% endif %}
{% if loop.last and instrings %}
]
}
{% endif %}
{% endfor %}
]
}

View File

@@ -0,0 +1,105 @@
{% set f=open_file("xls") %}
{% set sheet=f.sheet_by_index(0) %}
{% if not baseuri %}
{% set baseuri = "http://demos.gsi.dit.upm.es/eurosentiment/generator/process/default#" %}
{% endif %}
{% set prefixes = {
"a": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"marl": "http://www.gsi.dit.upm.es/ontologies/marl/ns#",
"wna": "http://www.gsi.dit.upm.es/ontologies/wnaffect/ns#",
"prov": "http://www.w3.org/ns/prov#",
"onyx": "http://www.gsi.dit.upm.es/ontologies/onyx/ns#",
"expsys": "http://expertsystem.net/ns#",
"nif": "http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#",
"dc": "http://purl.org/dc/terms/"
}
%}
{% macro p(pref, value='') -%}
<{{ prefixes[pref] }}{{ value }}>
{%- endmacro %}
{% set analysis = "<%sMachineAnnotated>" % baseuri %}
{{ analysis }} {{ p("a") }} {{ p("marl", "SentimentAnalysis") }} .
{{ analysis }} {{ p("a") }} {{ p("onyx", "EmotionAnalysis") }} .
{{ analysis }} {{ p("marl", "maxPolarityValue") }} "1.0" .
{{ analysis }} {{ p("marl", "minPolarityValue") }} "0.0" .
{{ analysis }} {{ p("prov", "wasAssociatedWith") }} {{ p("expsys", "agent") }} .
{% if language %}
{{ analysis }} {{ p("dc", "language") }} "{{ language }}" .
{% endif %}
{% 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 TEXT %}
{% if DOMAIN %}
{% set entry = "<%sContext%s>" % (baseuri, loop.index) %}
{% set opinion = "<%sOpinion%s>" % (baseuri, loop.index) %}
{{ entry }} {{ p("a") }} {{ p("nif", "Context") }} .
{{ entry }} {{ p("a") }} {{ p("nif", "RFC5147String") }} .
{{ entry }} {{ p("marl", "hasOpinion") }} {{ opinion }} .
{{ entry }} {{ p("nif", "isString") }} {{ TEXT | escapejs }} .
{{ opinion }} {{ p("a") }} {{ p("marl", "Opinion") }} .
{{ opinion }} {{ p("prov", "wasGeneratedBy") }} {{ analysis }} .
{{ opinion }} {{ p("expsys", "sentiment") }} {{ p("expsys", SENTIMENT) }} .
{% if SENTIMENT == "EXCELLENT" %}
{{ opinion }} {{ p("marl", "hasPolarity") }} {{ p("marl", "Positive") }} .
{{ opinion }} {{ p("marl", "polarityValue") }} "1.0" .
{% elif SENTIMENT == "GOOD" %}
{{ opinion }} {{ p("marl", "hasPolarity") }} {{ p("marl", "Positive") }} .
{{ opinion }} {{ p("marl", "polarityValue") }} "0.8" .
{% elif SENTIMENT == "BAD" %}
{{ opinion }} {{ p("marl", "hasPolarity") }} {{ p("marl", "Negative") }} .
{{ opinion }} {{ p("marl", "polarityValue") }} "0.2" .
{% elif SENTIMENT == "TERRIBLE" %}
{{ opinion }} {{ p("marl", "hasPolarity") }} {{ p("marl", "Negative") }} .
{{ opinion }} {{ p("marl", "polarityValue") }} "0.0" .
{% else %}
{{ opinion }} {{ p("marl", "hasPolarity") }} {{ p("marl", "Neutral") }} .
{% endif %}
{% if EMOTION %}
{% set emotionSet = "<%sEmotionSet%s>" % (baseuri, loop.index) %}
{% set emotion = "<%sEmotion%s>" % (baseuri, loop.index) %}
{{ entry }} {{ p("onyx", "hasEmotionSet") }} {{ emotionSet }} .
{{ emotionSet }} {{ p("prov", "wasGeneratedBy") }} {{ analysis }} .
{{ emotionSet }} {{ p("onyx", "hasEmotion") }} {{ emotion }} .
{{ emotion }} {{ p("onyx", "hasEmotionCategory") }} {{ p("wna", EMOTION) }} .
{% endif %}{# endif Emotion#}
{% else %}
{% set string = "<%sString%s>" % (baseuri, loop.index) %}
{{ string }} {{ p("nif", "hasContext") }} {{ entry }} .
{{ string }} {{ p("nif", "anchorOf") }} {{ TEXT | escapejs }} .
{% if WN_POS not in ("", "N/S", "N/C") %}
{{ string }} {{ p("nif", "posTag") }} {{ WN_POS | escapejs }} .
{% endif %}
{% if LEMMA not in ("", "#", "N/S", "N/C") %}
{{ string }} {{ p("nif", "lemma") }} {{ LEMMA | escapejs }} .
{% endif %}
{% if WN_SYNSET not in ("", "N/S", "N/C") %}
{{ string }} {{ p("expsys", "synset") }} {{ WN_SYNSET | escapejs }} .
{% endif %}
{% endif %}
{% endif %}
{% endfor %}

View File

@@ -0,0 +1,48 @@
{% set f = open_file() %}
{% if not base %}
{% set base = "http://demos.gsi.dit.upm.es/eurosentiment-translator/default" %}
{% endif %}
{
"@context": [
"http://demos.gsi.dit.upm.es/eurosentiment/static/context.jsonld"
],
"@id": "{{ base }}",
"results": {
"analysis": [
{
"@id": "{{ base }}#HumanAnnotated",
"@type": [
"marl:SentimentAnalysis"
],
"dc:language": "{{ language}}",
"marl:maxPolarityValue": 10.0,
"marl:minPolarityValue": 0.0
}
],
"entries": [
{% for line in f %}
{% set i=linesplit(line, "\t") %}
{% set node="_:BlankNode%s" % loop.index %}
{
"@id": "{{ node }}",
"opinions": [
{
{% set text = i[0] %}
{% set pol = i[1] | float %}
"marl:polarityValue": {{ pol/10.0 }},
{% if pol > 5 %}
"marl:hasPolarity": "marl:Positive"
{% elif pol < 5 %}
"marl:hasPolarity": "marl:Negative"
{% else %}
"marl:hasPolarity": "marl:Neutral"
{% endif %}
}
],
"nif:isString": {{ text | escapejs }},
"prov:generatedBy": "pt:agent"
} {% if not loop.last %} , {% endif %}
{% endfor%}
]
}
}

View File

@@ -0,0 +1,54 @@
{% set f = open_file() %}
{% set prefixes = {
"a": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"marl": "http://www.gsi.dit.upm.es/ontologies/marl/ns#",
"prov": "http://www.w3.org/ns/prov#",
"onyx": "http://www.gsi.dit.upm.es/ontologies/onyx/ns#",
"pt": "http://eurosentiment.eu/ns#",
"nif": "http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#",
"dc": "http://purl.org/dc/terms/"
}
%}
{% macro p(pref, value='') -%}
<{{ prefixes[pref] }}{{ value }}>
{%- endmacro %}
{% if not baseuri %}
{% set baseuri = "http://demos.gsi.dit.upm.es/eurosentiment/generator/process/default#" %}
{% endif %}
{% set analysis = "<%sHumanAnnotated>" % baseuri %}
{{ analysis }} {{ p("a") }} {{ p("marl", "SentimentAnalysis") }} .
{{ analysis }} {{ p("dc", "language") }} {{ p("marl", "SentimentAnalysis") }} .
{{ analysis }} {{ p("marl", "maxPolarityValue") }} "1.0" .
{{ analysis }} {{ p("marl", "minPolarityValue") }} "0.0" .
{{ analysis }} {{ p("prov", "wasAssociatedWith") }} {{ p("pt", "agent") }} .
{% if language %}
{{ analysis }} {{ p("dc", "language") }} "{{ language }}" .
{% endif %}
{% for line in f %}
{% set i=linesplit(line, "\t") %}
{% set text = i[0] %}
{% set pol= i[1] | float %}
{% set entry = "<%sContext%s>" % (baseuri, loop.index) %}
{% set opinion = "<%sOpinion%s>" % (baseuri, loop.index) %}
{{ entry }} {{ p("a") }} {{ p("nif", "Context") }} .
{{ entry }} {{ p("a") }} {{ p("nif", "RFC5147String") }} .
{{ entry }} {{ p("marl", "hasOpinion") }} {{ opinion }} .
{{ entry }} {{ p("nif", "isString") }} {{ text | escapejs }} .
{{ opinion }} {{ p("a") }} {{ p("marl", "Opinion") }} .
{{ opinion }} {{ p("prov", "wasGeneratedBy") }} {{ analysis }} .
{% if pol%}
{{ opinion }} {{ p("marl", "polarityValue") }} "{{ pol/10.0 }}" .
{% if pol > 5 %}
{{ opinion }} {{ p("marl", "hasPolarity") }} {{ p("marl", "Positive") }} .
{% elif pol < 5 %}
{{ opinion }} {{ p("marl", "hasPolarity") }} {{ p("marl", "Negative") }} .
{% else %}
{{ opinion }} {{ p("marl", "hasPolarity") }} {{ p("marl", "Neutral") }} .
{% endif %}
{% endif %}
{% endfor%}

View File

@@ -0,0 +1,62 @@
{% set f = open_file() %}
{% if not base %}
{% set base = "http://demos.gsi.dit.upm.es/eurosentiment/generator/process/default#" %}
{% endif %}
{
"@context": [
"http://demos.gsi.dit.upm.es/eurosentiment/static/context.jsonld"
],
"@id": "{{ base }}",
"analysis": [
{
"@id": "{{ base }}#MachineAnnotated",
"@type": [
"marl:SentimentAnalysis"
],
{% if language %}
"dc:language": "{{ language}}",
{% endif %}
"marl:maxPolarityValue": 1.0,
"marl:minPolarityValue": 0.0,
"prov:wasAssociatedWith": "pt:agent"
}
],
"entries": [
{% for line in f %}
{% set i=linesplit(line, "\t") %}
{% set node="_:BlankNode%s" % loop.index %}
{% set text = i[0] %}
{% set syntax=linesplit(i[1][1:-1], ",") %}
{% set pol= i[2] | float %}
{
"@id": "{{ node }}",
"opinions": [
{
{% if pol%}
"marl:polarityValue": {{ pol/10.0 }},
{% if pol > 5 %}
"marl:hasPolarity": "marl:Positive"
{% elif pol < 5 %}
"marl:hasPolarity": "marl:Negative"
{% else %}
"marl:hasPolarity": "marl:Neutral"
{% endif %}
{% endif %}
}
],
"nif:isString": {{ text | escapejs }},
"strings": [
{% for s in syntax %}
{
{% set parts=linesplit(s, ";;") %}
"nif:anchorOf": {{ parts[0] | escapejs }},
"nif:posTag": "pt:{{ parts[1] }}",
"nif:lemma": {{ parts[2] | escapejs }} }
{% if not loop.last %}, {% endif %}{% endfor %}
]
} {% if not loop.last %} , {% endif %}
{% endfor%}
]
}

View File

@@ -0,0 +1,68 @@
{% set f = open_file() %}
{% set prefixes = {
"a": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"marl": "http://www.gsi.dit.upm.es/ontologies/marl/ns#",
"prov": "http://www.w3.org/ns/prov#",
"onyx": "http://www.gsi.dit.upm.es/ontologies/onyx/ns#",
"pt": "http://eurosentiment.eu/ns#",
"nif": "http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#",
"dc": "http://purl.org/dc/terms/"
}
%}
{% macro p(pref, value='') -%}
<{{ prefixes[pref] }}{{ value }}>
{%- endmacro %}
{% if not baseuri %}
{% set baseuri = "http://demos.gsi.dit.upm.es/eurosentiment/generator/process/default#" %}
{% endif %}
{% set analysis = "<%sMachineAnnotated>" % baseuri %}
{{ analysis }} {{ p("a") }} {{ p("marl", "SentimentAnalysis") }} .
{{ analysis }} {{ p("dc", "language") }} {{ p("marl", "SentimentAnalysis") }} .
{{ analysis }} {{ p("marl", "maxPolarityValue") }} "1.0" .
{{ analysis }} {{ p("marl", "minPolarityValue") }} "0.0" .
{{ analysis }} {{ p("prov", "wasAssociatedWith") }} {{ p("pt", "agent") }} .
{% if language %}
{{ analysis }} {{ p("dc", "language") }} "{{ language }}" .
{% endif %}
{% for line in f %}
{% set i=linesplit(line, "\t") %}
{% set text = i[0] %}
{% set syntax=linesplit(i[1][1:-1], ",") %}
{% set pol= i[2] | float %}
{% set entry = "<%sContext%s>" % (baseuri, loop.index) %}
{% set opinion = "<%sOpinion%s>" % (baseuri, loop.index) %}
{{ entry }} {{ p("a") }} {{ p("nif", "Context") }} .
{{ entry }} {{ p("a") }} {{ p("nif", "RFC5147String") }} .
{{ entry }} {{ p("marl", "hasOpinion") }} {{ opinion }} .
{{ entry }} {{ p("nif", "isString") }} {{ text | escapejs }} .
{{ opinion }} {{ p("a") }} {{ p("marl", "Opinion") }} .
{{ opinion }} {{ p("prov", "wasGeneratedBy") }} {{ analysis }} .
{% if pol%}
{{ opinion }} {{ p("marl", "polarityValue") }} "{{ pol/10.0 }}" .
{% if pol > 5 %}
{{ opinion }} {{ p("marl", "hasPolarity") }} {{ p("marl", "Positive") }} .
{% elif pol < 5 %}
{{ opinion }} {{ p("marl", "hasPolarity") }} {{ p("marl", "Negative") }} .
{% else %}
{{ opinion }} {{ p("marl", "hasPolarity") }} {{ p("marl", "Neutral") }} .
{% endif %}
{% endif %}
{% set outer = loop %}
{% for s in syntax %}
{% set parts=linesplit(s, ";;") %}
{% set string = "<%sString%s_%s>" % (baseuri, outer.index, loop.index) %}
{{ string }} {{ p("a") }} {{ p("nif", "RFC5147String") }} .
{{ string }} {{ p("nif", "hasContext") }} {{ entry }} .
{{ string }} {{ p("nif", "anchorOf") }} {{ parts[0] | escapejs }} .
{{ string }} {{ p("nif", "posTag") }} {{ parts[1] | escapejs }} .
{{ string }} {{ p("nif", "lemma") }} {{ parts[2] | escapejs }} .
{% endfor %}
{% endfor%}

View File

@@ -0,0 +1,65 @@
{% set f=open_file(separator="\t") %}
{% if not base %}
{% set base="http://demos.gsi.dit.upm.es/eurosentiment/translator/process" %}
{% endif %}
{
"@context": [
"http://demos.gsi.dit.upm.es/eurosentiment/static/context.jsonld"
],
"@id": "{{ base }}",
"analysis": [
{
"@id": "{{ base }}#SynsetAnnotated",
"@type": [
"marl:SentimentAnalysis"
],
{% if language %}
"dc:language": "{{ language}}",
{% endif %}
"marl:maxPolarityValue": 10.0,
"marl:minPolarityValue": 0.0,
"prov:wasAssociatedWith": "pt:agent"
}
],
"entries": [
{% for line in f %}
{% set i=linesplit(line, "\t") %}
{% set node="_:BlankNode%s" % loop.index %}
{% set text = i[0] %}
{% set syntax=linesplit(i[1][1:-1], ",") %}
{% set pol= i[2] | float %}
{
"@id": "{{ node }}",
"opinions": [
{
{% 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 %}
}
],
"nif:isString": {{ text | escapejs }},
"strings": [
{% for s in syntax %}
{
{% set parts=linesplit(s, ";;") %}
{% set synsets=linesplit(parts[3][1:-1], ",") %}
"nif:anchorOf": {{ parts[0] | escapejs }},
"nif:posTag": "pt:{{ parts[1] }}",
"nif:lemma": {{ parts[2] | escapejs }},
"pt:synset": [{% for synset in synsets if synset %}"{{synset}}"{% if not loop.last %}, {% endif %}{% endfor %}]
}{% if not loop.last %}, {% endif %}{% endfor %}
]
} {% if not loop.last %} , {% endif %}
{% endfor%}
]
}

View File

@@ -0,0 +1,68 @@
{% set f = open_file() %}
{% set prefixes = {
"a": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
"marl": "http://www.gsi.dit.upm.es/ontologies/marl/ns#",
"prov": "http://www.w3.org/ns/prov#",
"onyx": "http://www.gsi.dit.upm.es/ontologies/onyx/ns#",
"pt": "http://eurosentiment.eu/ns#",
"nif": "http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#",
"dc": "http://purl.org/dc/terms/"
}
%}
{% macro p(pref, value='') -%}
<{{ prefixes[pref] }}{{ value }}>
{%- endmacro %}
{% if not baseuri %}
{% set baseuri = "http://demos.gsi.dit.upm.es/eurosentiment/generator/process/default#" %}
{% endif %}
{% set analysis = "<%sMachineAnnotated>" % baseuri %}
{{ analysis }} {{ p("a") }} {{ p("marl", "SentimentAnalysis") }} .
{{ analysis }} {{ p("dc", "language") }} {{ p("marl", "SentimentAnalysis") }} .
{{ analysis }} {{ p("marl", "maxPolarityValue") }} "1.0" .
{{ analysis }} {{ p("marl", "minPolarityValue") }} "0.0" .
{{ analysis }} {{ p("prov", "wasAssociatedWith") }} {{ p("pt", "agent") }} .
{% if language %}
{{ analysis }} {{ p("dc", "language") }} "{{ language }}" .
{% endif %}
{% for line in f %}
{% set i = linesplit(line, "\t") %}
{% set text = i[0] %}
{% set syntax=linesplit(i[1][1:-1], ",") %}
{% set pol= i[2] | float %}
{% set entry = "<%sContext%s>" % (baseuri, loop.index) %}
{% set opinion = "<%sOpinion%s>" % (baseuri, loop.index) %}
{{ entry }} {{ p("a") }} {{ p("nif", "Context") }} .
{{ entry }} {{ p("a") }} {{ p("nif", "RFC5147String") }} .
{{ entry }} {{ p("marl", "hasOpinion") }} {{ opinion }} .
{{ entry }} {{ p("nif", "isString") }} {{ text | escapejs }} .
{{ opinion }} {{ p("a") }} {{ p("marl", "Opinion") }} .
{{ opinion }} {{ p("prov", "wasGeneratedBy") }} {{ analysis }} .
{% if pol%}
{{ opinion }} {{ p("marl", "polarityValue") }} "{{ pol/10.0 }}" .
{% if pol > 5 %}
{{ opinion }} {{ p("marl", "hasPolarity") }} {{ p("marl", "Positive") }} .
{% elif pol < 5 %}
{{ opinion }} {{ p("marl", "hasPolarity") }} {{ p("marl", "Negative") }} .
{% else %}
{{ opinion }} {{ p("marl", "hasPolarity") }} {{ p("marl", "Neutral") }} .
{% endif %}
{% endif %}
{% set outer = loop %}
{% for s in syntax %}
{% set parts = linesplit(s, ";;") %}
{% set synsets = linesplit(parts[3][1:-1], ",") %}
{% set string = "<%sString%s_%s>" % (baseuri, outer.index, loop.index) %}
{{ string }} {{ p("nif", "hasContext") }} {{ entry }} .
{{ string }} {{ p("nif", "anchorOf") }} {{ parts[0] | escapejs }} .
{{ string }} {{ p("nif", "posTag") }} {{ parts[1] | escapejs }} .
{{ string }} {{ p("nif", "lemma") }} {{ parts[2] | escapejs }} .
{% for synset in synsets if synset %}
{{ string }} {{ p("pt", "synset") }} {{ synset | escapejs }}
{% endfor %}
{% endfor %}
{% endfor%}

View File

@@ -0,0 +1,45 @@
{% set f = open_file(encoding="utf-8-sig") %}
{% set posdic = {
"N": "lexinfo:noun",
"AJ": "lexinfo:adjective",
"V": "lexinfo:verb"
}
%}
{% if not language %}
{% endif %}
{
"@context": {
{% if baseuri %}
"@base": {{ baseuri | escapejs }},
{% endif %}
"lemon": "http://lemon-model.net/lemon#",
"marl": "http://www.gsi.dit.upm.es/ontologies/marl/ns#",
"lexinfo": "http://www.lexinfo.net/ontology/2.0/lexinfo",
"entries": {
"@type": "lemon:LexicalEntry",
"@id": "lemon:entry"
},
"sense": {
"@id": "lemon:sense",
"@type": "lemon:Sense"
}
},
"@type": "lemon:Lexicon",
{% if language %}
"lemon:language": {{ language | escapejs }},
{% endif %}
"entries": [
{% for line in islice(f, 1, None) %}
{
{% set i=re.split('[^\w.]+', line.strip(" \t\n\r")) %}
"lemon:canonicalForm": { "lemon:writtenRep": {{ i[0].strip() | escapejs }}},
"sense": {
"marl:hasPolarityValue": {{ i[2] | escapejs }}
},
"lexinfo:partOfSpeech": {{ posdic.get(i[1],i[1]) | escapejs }},
"weight": {{ i[3] | escapejs }}
} {{ "," if not loop.last }}
{% endfor %} {# for line #}
]
}

View File

@@ -0,0 +1,2 @@
{% set file=open_file() %}
{% for line in file %}{{ line }}{% endfor %}

View File

@@ -0,0 +1,51 @@
{% set f = open_file(informat="csv", delimiter='\t') %}
{
"@context": [
"http://demos.gsi.dit.upm.es/eurosentiment/static/context.jsonld"
],
"@id": "GSI-UPM",
"analysis": [
{
"prov:wasAssociatedWith": "GSI_UPM",
"dc:language": "en",
"marl:maxPolarityValue": 1,
"marl:minPolarityValue": -1
}
],
"entries": [ {% for row in f %}
{% if not row %}
]
}{% if not loop.last %},{% endif -%}
{% elif row[0] == "#webanno.custom.Sentiment | Sentimentvalue" %}
{% elif row[0][0:4] == '#id=' %}
{% set currentid = row[0][4:] %}
{
"@id": {{ currentid | escapejs }},
{% elif row[0][0:6] == '#text=': %}
"nif:isString": {{ row[0][6:] | escapejs }},
"strings": [
{% set first = True %}
{% elif row and row[0].split('-')[0] == currentid %}
{% set word = row[1] %}
{% set pol = row[2].split('-')[-1] %}
{% if not first %},
{% else %} {% set first = False %} {% endif %}
{
"@id": "substring{{ row[0] }}",
"nif:anchorOf": {{ word | escapejs }},
{% if pol == 'Positive' %}
"marl:polarityValue": 1,
"marl:hasPolarity": "Positive"
{% elif pol == 'Negative' %}
"marl:polarityValue": -1,
"marl:hasPolarity": "Negative"
{% elif pol == 'Neutral' or pol == "O" %}
"marl:polarityValue": 0,
"marl:hasPolarity": "Neutral"
{%endif%}
}
{%- endif %}
{% endfor %}
]
}