1
0
mirror of https://github.com/balkian/gists.git synced 2024-11-21 17:22:29 +00:00

Add 'repos/06c454a48156dccc6f55/' from commit '214ea51a72d4ce24a93cc3dcccd4ebae0fa48ac5'

git-subtree-dir: repos/06c454a48156dccc6f55
git-subtree-mainline: bef5400be9
git-subtree-split: 214ea51a72
This commit is contained in:
J. Fernando Sánchez 2021-10-30 15:13:22 +02:00
commit e167429310
10 changed files with 613 additions and 0 deletions

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