1
0
mirror of https://github.com/balkian/gists.git synced 2024-12-21 22:08:13 +00:00
gists/templates marl generator/template-PT_HA-nt
J. Fernando Sánchez f48bab94dd Move files
2021-10-30 15:23:01 +02:00

54 lines
2.1 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 = "<%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%}