Editing Module:LuaExtractionDiscourseLayers

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

This page is not enabled for semantic in-text annotations due to namespace restrictions. Details about how to enable the namespace can be found on the configuration help page.

Latest revision Your text
Line 35: Line 35:
 
 
 
local lookup = {
 
local lookup = {
argumentation2 = "annotator-hl-blue",
+
argumentation = "annotator-hl-blue",
innovationsdiskurs2 = "annotator-hl-red",
+
innovationsdiskurs = "annotator-hl-red",
narrativ2 = "annotator-hl-lime",
+
narrativ = "annotator-hl-green",
wissenschaftlichereferenz2 = "annotator-hl-yellow",
+
wissenschaftlichereferenz = "annotator-hl-yellow"
beispiel3 = "annotator-hl-blueviolet",
 
praemisse3 = "annotator-hl-orange",
 
schlussfolgerung3 = "annotator-hl-cyan"
 
 
}
 
}
 
local title = mw.title.makeTitle('', pagetitle)
 
local title = mw.title.makeTitle('', pagetitle)
Line 65: Line 62:
 
local category = metadata['category']
 
local category = metadata['category']
 
category = category:lower()
 
category = category:lower()
category = category:gsub("%d%_", "")
+
category[1] = category[3]
category = category:gsub("ä", "ae")
 
local selector = type(lookup[category]) == "function" and lookup[category]() or lookup[category] or "blubb"
 
local prefix = '<div class="' .. "box-layer2 " .. selector .. '">'
 
local suffix = "</div>"
 
local prefix_title = '<span class="box-layer2-title' .. '">'
 
local suffix_title = '</span>'
 
rv = rv .. prefix .. prefix_title .. metadata['category'] .. suffix_title .. '<br>' .. "" .. metadata['quote'] .. suffix
 
t[i] = _xpathToSortableIndex(start)
 
end
 
 
 
table.sort(t)
 
 
 
-- local page = mw.title.makeTitle('', annotationspage)
 
-- local content = page:getContent()
 
 
 
-- Todo: sort annotations by position in text by the use of XPATH info in metadata
 
-- local result = ""
 
--for i, e in ipairs(t) do
 
-- result = result .. e .. '<br>'
 
--end
 
return rv
 
end
 
 
return 'should not have reached this point'
 
end
 
 
 
function p.ExtractLayer3(frame)
 
 
-- get title from arguments
 
local pagetitle = frame.args[1]
 
pagetitle = 'Text:' .. pagetitle:gsub("Annotationen:", "")
 
if pagetitle == nil then
 
return 'No title supplied as parameter'
 
else
 
 
local lookup = {
 
argumentation2 = "annotator-hl-blue",
 
innovationsdiskurs2 = "annotator-hl-red",
 
narrativ2 = "annotator-hl-lime",
 
wissenschaftlichereferenz2 = "annotator-hl-yellow",
 
beispiel3 = "annotator-hl-blueviolet",
 
praemisse3 = "annotator-hl-orange",
 
schlussfolgerung3 = "annotator-hl-cyan"
 
}
 
local title = mw.title.makeTitle('', pagetitle)
 
local pagecontent = title:getContent()
 
 
 
local query = '[[Annotation of::' .. pagetitle .. ']]|?=#|?AnnotationMetadata=#'
 
local result = mw.smw.ask(query)
 
local rv = ''
 
local t = {}
 
 
if result == nil then
 
return 'No annotions found for page ' .. pagetitle
 
end
 
 
for i=1,#result do
 
-- result[i][1] -> title of page
 
-- result[i]['#'] -> metadata
 
 
local metadata = result[i]['#']
 
metadata = _annotationMetadataExtract(metadata)
 
local start = metadata['ranges'][1]['start']
 
local startoffset = metadata['ranges'][1]['startOffset']
 
local category = metadata['category']
 
category = category:lower()
 
-- rv = rv .. category .. ' ' .. lookup[category] .. '\n\n'
 
 
local selector = type(lookup[category]) == "function" and lookup[category]() or lookup[category] or "blubb"
 
local selector = type(lookup[category]) == "function" and lookup[category]() or lookup[category] or "blubb"
 
local prefix = '<div class="' .. "box-layer2 " .. selector .. '">'
 
local prefix = '<div class="' .. "box-layer2 " .. selector .. '">'

Please note that all contributions to DigiVis are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see DigiVis:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Template used on this page: