Skip to content

Commit

Permalink
Merge pull request #51 from kent-rasmussen/segsorts
Browse files Browse the repository at this point in the history
Segsorts
  • Loading branch information
kent-rasmussen authored Feb 16, 2022
2 parents 9c7177d + 4a5b2ee commit 8233e7b
Show file tree
Hide file tree
Showing 30 changed files with 44,588 additions and 39 deletions.
25 changes: 24 additions & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
#Roadmap
-check for remove file URL if file not present (and not preferred filename)
- Figure out why next frame isn't changing to new frame when all are done
- check if using top or all profiles (autoadvance should just be top)
- remove ps-profile line from comprehensive report (add how many to do?)
- fix exit on asklift. Exit button shouldn't shut down AZT...
- look at what it would take to make two copies of each sound file. one in hires/, the other in lowres/. We could then make a link to whichever was appropriate.
-Problem:
-If we keep the same filename for each file (lowres and highres versions), then we run the risk of either overwriting the other, on a (user error) copy.
-If we make different filenames (e.g., _hires.wav, _lowres.mp3), then the link to the filename would have to be updated as needed, or else each in their own link.
-Rationale: one sample 96khz wav file was 2.5% as large as a 48khz mp3
-This has drastic consequences on collaboration
-This is not obviously an important difference for tone study
- check for remove file URL if file not present (and not preferred filename)
- get AOR working:
- /usr/share/SIL/ImageCollections/ArtOfReading/index.txt (search for gloss elements)
- make object for image repo, with location on disk as attribute
- find out how big a pic is
- scale (to ?200px wide/tall?) to present on screen in formatted data
- maybe larger for selection, smaller for buttons?
- store scaled image in memory
- save full version in repo
- and smaller version, too? Would this be better than ad hoc scaling?
- save link to LIFT
- use LIFT link to make button images (w/wo ad hoc scaling?)

-look at lx nodes not being written to examples? (is there anything to this? How could this possibly happen, except with no lx data in database? In that case, provide a sensible result)
-scrolling left to right

Expand Down
48 changes: 28 additions & 20 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ def __init__(self, parent, taskchooser, task, **kwargs):
self.fieldsline()
if (isinstance(self.task,Sort) or
(isinstance(self.task,Report) and
not isinstance(self.task,ReportCitationBasic)) or
not isinstance(self.task,Comprehensive)) or
isinstance(self.task,Tone)
):
self.cvt=self.settings.params.cvt()
Expand Down Expand Up @@ -3264,19 +3264,25 @@ def verifictioncode(self,**kwargs):
log.info("about to return {}={}".format(check,group))
return check+'='+group
def maybewrite(self):
if self.timetowrite():
try:
self.runwindow.wait("Writing to LIFT")
w=self.runwindow
except AttributeError:
self.wait("Writing to LIFT")
w=self
self.db.write()
w.waitdone()
def schedule_check(t):
"""Schedule `check_if_done()` function after five seconds."""
self.after(5000, check_if_done, t)
def check_if_done(t):
# If the thread has finished, allow another write.
if not t.is_alive():
self.taskchooser.writing=False
else:
# Otherwise check again later.
schedule_check(t)
if self.timetowrite() and not self.taskchooser.writing:
t = threading.Thread(target=self.db.write)
self.taskchooser.writing=True
t.start()
schedule_check(t)
def timetowrite(self):
"""only write to file every self.writeeverynwrites times you might."""
self.writeable+=1 #and tally here each time this is asked
return not self.writeable%self.writeeverynwrites
self.taskchooser.writeable+=1 #and tally here each time this is asked
return not self.taskchooser.writeable%self.settings.writeeverynwrites
def __init__(self,parent):
log.info("Initializing TaskDressing")
self.parent=parent
Expand Down Expand Up @@ -3311,11 +3317,6 @@ def __init__(self,parent):
self.makestatusframe()
self._taskchooserbutton()
self.correlatemenus()
if not self.settings.writeeverynwrites: #0/None are not sensible values
self.settings.writeeverynwrites=5
self.settings.storesettingsfile()
self.writeeverynwrites=self.settings.writeeverynwrites
self.writeable=0 #start the count
# back=ui.Button(self.outsideframe,text=_("Tasks"),cmd=self.taskchooser)
# self.setfontsdefault()
class TaskChooser(TaskDressing,ui.Window):
Expand Down Expand Up @@ -3766,6 +3767,7 @@ def ifcollectionlc(self):
def __init__(self,parent):
# self.testdefault=Transcribe
self.start_time=time.time() #this enables boot time evaluation
self.writing=False
self.datacollection=True # everyone starts here?
self.ifcollectionlcsettingsdone=False
self.setiflang() #before Splash
Expand All @@ -3782,6 +3784,10 @@ def __init__(self,parent):
self.analang=self.file.analang #I need to keep this alive until objects are done
self.makesettings()
TaskDressing.__init__(self,parent)
if not self.settings.writeeverynwrites: #0/None are not sensible values
self.settings.writeeverynwrites=5
self.settings.storesettingsfile()
self.writeable=0 #start the count
self.makedefaulttask() #normal default
# self.gettask() # let the user pick
"""Do I want this? Rather give errors..."""
Expand Down Expand Up @@ -5975,6 +5981,8 @@ def __init__(self):
self.distinguish=self.settings.distinguish
self.profilesbysense=self.settings.profilesbysense
self.s=self.settings.s
class Comprehensive(object):
pass
class SortCV(Sort,Segments,TaskDressing,ui.Window):
"""docstring for SortCV."""
def __init__(self, parent):
Expand Down Expand Up @@ -7662,7 +7670,7 @@ def runcheck(self):
i+=1
return
self.getresults()
class ReportCitationBasic(Report,Segments,TaskDressing,ui.Window):
class ReportCitationBasic(Report,Comprehensive,Segments,TaskDressing,ui.Window):
"""docstring for ReportCitation."""
def tasktitle(self):
return _("Comprehensive Alphabet Report") # on Citation Forms
Expand Down Expand Up @@ -7751,7 +7759,7 @@ def __init__(self, parent): #frame, filename=None
TaskDressing.__init__(self,parent)
Report.__init__(self)
self.bylocation=True
class ReportCitationBasicT(Report,Tone,TaskDressing,ui.Window):
class ReportCitationBasicT(Report,Comprehensive,Tone,TaskDressing,ui.Window):
"""docstring for ReportCitationT."""
def tasktitle(self):
return _("Comprehensive Tone Report")
Expand Down Expand Up @@ -10401,7 +10409,7 @@ def name(x):
i18n={}
i18n['en'] = gettext.translation('azt', transdir, languages=['en_US'])
i18n['fr'] = gettext.translation('azt', transdir, languages=['fr_FR'])
for exe in ['praat','hg']: #'sendpraat' now in 'praat', if useful
for exe in ['praat','hg','ffmpeg','lame']: #'sendpraat' now in 'praat', if useful
findexecutable(exe)
# i18n['fub'] = gettext.azttranslation('azt', transdir, languages=['fub'])
if exceptiononload:
Expand Down
7 changes: 6 additions & 1 deletion rx.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def tonerxs():
re.compile(' ', re.UNICODE),
re.compile(' ', re.UNICODE))
def texmllike(x):
"""This attempts to implement TeXMLLikeCharacterConversion.java from
XLingPaper"""
repls={
'\\': "\\textbackslash{}",
'{': "\\{",
Expand All @@ -66,7 +68,10 @@ def texmllike(x):
'%': "\\%",
'|': "\\textbar{}",
'<': "\\textless{}",
'>': "\\textgreater{}"
'>': "\\textgreater{}",
'.\u200b ': ".\\ ",
'\u200c ': ".\\ \\ ",
'\u200d ': ".~"
}
for y in repls:
print("Replacing",y,"with",repls[y])
Expand Down
8 changes: 6 additions & 2 deletions ui_tkinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,12 +630,16 @@ def __init__(self, theme=None, program=None, *args, **kwargs):
self.mainwindow=False
self.exitFlag = ExitFlag()
tkinter.Tk.__init__(self)
if program:
self.program=program
else:
self.program={}
if theme and not isinstance(theme,Theme) and type(theme) is str:
self.theme=Theme(program,theme)
self.theme=Theme(self.program,theme)
elif theme and isinstance(theme,Theme):
self.theme=theme
else:
self.theme=Theme(program) #OK if program==None
self.theme=Theme(self.program) #OK if program==None
self.renderer=Renderer()
Exitable.__init__(self)
UI.__init__(self)
Expand Down
48 changes: 34 additions & 14 deletions xlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def close(self,me=False):
m=int(t/60)
s=t%60
log.info("Finished in {} minutes, {} seconds.".format(m,s))
# if me:
# self.compile() #This isn't working yet.
if me:
self.compile() #This isn't working yet.
def write(self):
"""This writes changes to XML which can be read by XXE as XLP."""
doctype=self.node.tag
Expand Down Expand Up @@ -87,19 +87,29 @@ def compile(self):
entry.type_name, entry.filename))
transform[n] = lxml.etree.XSLT(trans)
for error in transform[n].error_log:
log.error("XSLT Error {}: {}".format(error.message, error.line))
log.error("XSLT Error {}: {} ({})".format(error.message,
error.line,
error.filename))
newdom = transform[1](dom)
with open(outfile+'a', 'wb') as f:
f.write(lxml.etree.tostring(newdom, pretty_print=True))
f.write(lxml.etree.tostring(newdom,
encoding="utf-8",
xml_declaration=True,
pretty_print=True))
# newdom2 = transform[2](newdom1) #not used; always using stylesheets!
dom=newdom
try:
newdom = transform[3](dom)
with open(outfile+'b', 'wb') as f:
f.write(lxml.etree.tostring(newdom, pretty_print=True))
f.write(lxml.etree.tostring(newdom,
encoding="utf-8",
xml_declaration=True,
pretty_print=True))
except:
for error in transform[3].error_log:
log.error("XSLT Error {}: {}".format(error.message, error.line))
log.error("XSLT Error {}: {} ({})".format(error.message,
error.line,
error.filename))
dom=newdom
# Convert this to pure XeLaTeX form *here*, using converted java classes
# A Java class that reads the input and changes certain sequences to
Expand All @@ -110,19 +120,29 @@ def compile(self):
with open(outfile+'c', 'wb') as f:
f.write(newdom.encode('utf_8'))
dom = lxml.etree.parse(outfile+'c')
newdom = transform[4](dom)
texfile=outfile.replace('.xml','.tex')
outdir=file.getfilenamedir(outfile)
log.info("writing to tex file {}".format(texfile))
with open(texfile, 'wb') as f:
f.write(newdom) #this isn't xml anymore!
xetexargs=["xelatex", "--interaction=nonstopmode","-output-directory",
try:
newdom = transform[4](dom)
texfile=outfile.replace('.xml','.tex')
outdir=file.getfilenamedir(outfile)
log.info("writing to tex file {}".format(texfile))
with open(texfile, 'wb') as f:
f.write(newdom) #this isn't xml anymore!
except:
for error in transform[4].error_log:
log.error("XSLT Error {}: {} ({})".format(error.message,
error.line,
error.filename))
xetexargs=[
# "/usr/texbinxlingpaper/xelatex",
# "/usr/local/xlingpapertexbin/xelatex",
"xelatex",
"--interaction=nonstopmode","-output-directory",
outdir, texfile]
try:
subprocess.run(xetexargs,shell=False) # was call
# subprocess.call(xetexargs,shell=False) #does twice help?
exts=['out','aux','log']
exts+=['xmla','xmlb','xmlc','tex'] #once this is working...
# exts+=['xmla','xmlb','xmlc','tex'] #once this is working...
for ext in exts:
file.remove(outfile.replace('.xml', '.'+ext))
except Error as e:
Expand Down
22 changes: 21 additions & 1 deletion xlptransforms/ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The XSL transforms and DTDs in this folder are from https://github.com/sillsdev/XLingPap, retrieved on September 1, 2021. While that site was not accompanied by a license, it links to software.sil.org/xlingpaper/, which contains in its footer the text:
The XSL transforms and DTDs in this folder are from https://github.com/sillsdev/XLingPap, retrieved on September 1, 2021 and since. While that site was not accompanied by a license, it links to software.sil.org/xlingpaper/, which contains in its footer the text:

`This software is free to use, modify and redistribute according to the terms of the MIT License`

Expand All @@ -20,3 +20,23 @@ Modifications I have made so far are limited to implementing the exslt.org nodes
- select="$childDoc/root/node()"
to node sets like
- select="exsl:node-set($childDoc)/root/node()"

Search for (\$[^],/=") []+)([/[]+)
replace with exsl:node-set(\1)\2
inside normalize-space() is OK
There were a few cases requiring more manual work… but mostly incorporated

XLingPapPublisherStylesheetXeLaTeX.xsl
XLingPapXeLaTeXCommon.xsl
XLingPapPublisherStylesheetXeLaTeXContents.xsl
XLingPapPublisherStylesheetCommon.xsl
/home/kentr/IT/azt/repo_stable/xlptransforms/XLingPapXeLaTeX1.xsl
/home/kentr/IT/azt/repo_stable/xlptransforms/XLingPapRemoveAnyContent.xsl
/home/kentr/IT/azt/repo_stable/xlptransforms/XLingPapPublisherStylesheetCommonContents.xsl
/home/kentr/IT/azt/repo_stable/xlptransforms/XLingPapCommon.xsl
/home/kentr/IT/azt/repo_stable/xlptransforms/XLingPapCannedCommon.xsl
/home/kentr/IT/azt/repo_stable/xlptransforms/XLingPapPublisherStylesheetXeLaTeXReferences.xsl
/home/kentr/IT/azt/repo_stable/xlptransforms/XLingPapPublisherStylesheetXeLaTeXBookmarks.xsl



Loading

0 comments on commit 8233e7b

Please sign in to comment.