Last active
October 30, 2021 11:29
-
-
Save balkian/9056b004cfa3edcb1ef3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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 %} | |
] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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 %} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"@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%} | |
] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"@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 %} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"@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 %} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"@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 %} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"@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 %} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment