mirror of
https://github.com/balkian/gists.git
synced 2024-11-25 10:42:28 +00:00
e167429310
git-subtree-dir: repos/06c454a48156dccc6f55 git-subtree-mainline:bef5400be9
git-subtree-split:214ea51a72
68 lines
2.6 KiB
Plaintext
68 lines
2.6 KiB
Plaintext
{% 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%} |