1
0
mirror of https://github.com/balkian/gists.git synced 2024-12-23 14:58:11 +00:00

Add 'repos/9056b004cfa3edcb1ef3/' from commit 'cb19669f89c51f6fd189a8e4c30765d7c976e140'

git-subtree-dir: repos/9056b004cfa3edcb1ef3
git-subtree-mainline: 62679193ca
git-subtree-split: cb19669f89
This commit is contained in:
J. Fernando Sánchez 2021-10-30 15:14:06 +02:00
commit d8729e4833
7 changed files with 496 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 %}
]
}