Commit 92d56103 authored by Arndt Heilmann's avatar Arndt Heilmann
Browse files

Ready

parent d1d2d6f4
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Some modifications (deletions/production events) could have been mapped to inappropriate tokens.
The following procedure allows you to manually re-align modification ids to the correct token ids.
1) Put .Event.xml-files into the EventFiles folder.
2) Run 1_CreatePuzzleFileFromEventFile.py from Script folder.
3) Open .pzl-file from ManualRealignment-Folder in a spreadsheet program.
4) Re-align modifications by cutting and pasting modification ids to token ids.
5) Run 2_CreateFixedEventFiles.py from Scripts-Folder to get an updated kd.-file.
6) Use and upload .Event.xml-files from the FixedEventFiles folder.
\ No newline at end of file
Manual Re-Alignment of Keystrokes to Tokens. In some cases, keystrokes are not mapped to the correct token. The manual re-alignment procedure below helps rectify this issue:
1) Download the following repository from GitLab:
2) Download the Event.xml-files from your study form the Management Tool: https://critt.as.kent.edu/cgi-bin/yawat/yawat.cgi
3) Move the Event.xml-files to the folder "EventFiles"
4) Run "1_CreatePuzzleFileFromEventFile.py" from the Scripts folder.
5) In the Folder "ManualRealignment" you will find so called .pzl files. These are basically tab-separated tables.
6) Open the .pzl-File in a spreadsheet program (or copy-paste the content of a .pzl-file into the spreadsheet program)
7) Cut-and-paste misaligned keystroke ids to the correct token id.
8) Save your changes under the .pzl-file again (tab-separated)
9) Run "2_CreateFixedEventFile".
10) Retrieve updated .Event.xml-Files from "FixedEventFiles" Folder
11) Upload .Event.xml-files via the CRITT TPRDB management tool and re-create the tables.
12) The tool was developed as part of the TRICKLET-project
\ No newline at end of file
......@@ -8,20 +8,25 @@ Created on Wed Apr 28 11:42:17 2021
import os
import numpy as np
from lxml import etree
KDdict={}
for dirs,subdirs,files in os.walk('..\\EventFiles\\'):
for file in files:
if file.endswith("Event.xml") :
# print(file)
KDdict={}
Alignmentdict={}
FixedKDdict={}
filename=file.replace(".Event.xml","")
print(file)
with open(dirs+"//"+file,"r",encoding="utf-8") as infile:
mytext=infile.read()
root = etree.fromstring(bytes(mytext,"utf-8"))
file=file.replace(".Event.xml","")
mytext=mytext.replace("LogFile","logfile")
mytext=mytext.replace("chr=\"\"\"","char=\""\"")
p = etree.XMLParser(remove_blank_text=True)
root = etree.fromstring(mytext,parser=p)
for i,Mod in enumerate(root.iter("Mod")):
Mod.attrib["chr"]=Mod.attrib["chr"].replace("\n","_")
Mod.attrib["chr"]=Mod.attrib["chr"].replace(" ","_")
......@@ -30,35 +35,42 @@ for dirs,subdirs,files in os.walk('..\\EventFiles\\'):
if key=="chr" and Mod.attrib["type"]=="Mdel":
Mod.attrib["chr"]=f'[{Mod.attrib["chr"]}]'
KDdict.setdefault(filename,{}).setdefault(i,{}).setdefault(key,value)
#%%
FixedKDdict=KDdict.copy()
for translation in FixedKDdict:
with open("..\ManualRealignment\\"+translation+".pzl","r",encoding="utf-8") as infile:
for i,line in enumerate(infile):
line=line.replace("\n","").split("\t")
if line[1]=="TT" and line[2]=="Ids":
for item in line[5:]:
if item!="":
item=int(item)
for i,Align in enumerate(root.iter("Align")):
Alignmentdict.setdefault(filename,{}).setdefault(Align.attrib["tid"],[]).append(Align.attrib["sid"])
#%%
FixedKDdict=KDdict.copy()
with open("..\ManualRealignment\\"+filename+".pzl","r",encoding="utf-8") as infile:
for i,line in enumerate(infile):
line=line.replace("\n","").split("\t")
if line[1]=="TT" and line[2]=="Ids":
if FixedKDdict[translation][item]["tid"]!=(line[3]):
FixedKDdict[translation][item]["tid"]=(line[3])
for item in line[5:]:
if item!="":
item=int(item)
if FixedKDdict[filename][item]["tid"]!=(line[3]):
FixedKDdict[filename][item]["tid"]=(line[3])
#%%
for dirs,subdirs,files in os.walk('..\\EventFiles\\'):
for file in files:
if file.endswith("Event.xml") :
print(file)
filename=file.replace(".Event.xml","")
with open(dirs+"//"+file,"r",encoding="utf-8") as infile:
mytext=infile.read()
root = etree.fromstring(bytes(mytext,"utf-8"))
mytext=mytext.replace("LogFile","logfile")
mytext=mytext.replace("chr=\"\"\"","char=\""\"")
p = etree.XMLParser(remove_blank_text=True)
root = etree.fromstring(mytext,parser=p)
filename=file.replace(".Event.xml","")
for i,Mod in enumerate(root.iter("Mod")):
for key,value in Mod.attrib.items():
Mod.attrib[key]= FixedKDdict[filename][i][key]
try:
Mod.attrib["sid"]="+".join(Alignmentdict[filename][FixedKDdict[filename][i]["tid"]])
except:
pass
et = etree.ElementTree(root)
out=etree.tostring(et,encoding="utf-8", pretty_print=True).decode('utf-8')
out=out.replace("
","
")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment