Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify .pre-commit-config.yaml #5014

Merged
merged 4 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ repos:
rev: v3.2.0
hooks:
- id: trailing-whitespace
exclude: ^(egs2/TEMPLATE/asr1/utils|egs2/TEMPLATE/asr1/steps|egs2/TEMPLATE/tts1/sid)
exclude: ^(egs2/TEMPLATE/asr1/utils|egs2/TEMPLATE/asr1/steps|egs2/TEMPLATE/tts1/sid|tools/installers/patch_mwerSegmenter)
- id: end-of-file-fixer
exclude: ^(egs2/TEMPLATE/asr1/utils|egs2/TEMPLATE/asr1/steps|egs2/TEMPLATE/tts1/sid)
exclude: ^(egs2/TEMPLATE/asr1/utils|egs2/TEMPLATE/asr1/steps|egs2/TEMPLATE/tts1/sid|tools/installers/patch_mwerSegmenter)
- id: check-yaml
exclude: ^(egs2/TEMPLATE/asr1/utils|egs2/TEMPLATE/asr1/steps|egs2/TEMPLATE/tts1/sid)
exclude: ^(egs2/TEMPLATE/asr1/utils|egs2/TEMPLATE/asr1/steps|egs2/TEMPLATE/tts1/sid|tools/installers/patch_mwerSegmenter)
- id: check-added-large-files
exclude: ^(egs2/TEMPLATE/asr1/utils|egs2/TEMPLATE/asr1/steps|egs2/TEMPLATE/tts1/sid)
exclude: ^(egs2/TEMPLATE/asr1/utils|egs2/TEMPLATE/asr1/steps|egs2/TEMPLATE/tts1/sid|tools/installers/patch_mwerSegmenter)
58 changes: 29 additions & 29 deletions tools/installers/patch_mwerSegmenter/hyp2sgm.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
***************
*** 1,4 ****
! #!/usr/bin/env python

import sys
from sgmllib import SGMLParser
--- 1,4 ----
! #!/usr/bin/env python2

import sys
from sgmllib import SGMLParser
***************
*** 8,16 ****
--- 8,18 ----
debugPrint = sys.stderr.write
verbosePrint = sys.stderr.write

+
+
def normalize(reference):
return reference.replace("#", "\\#").replace("\n", " ").strip()

+
+
class SGMLRefParser(SGMLParser):
def __init__(self, sysid, targetLanguage, fpIn, fpOut, verbose):
SGMLParser.__init__(self)
Expand All @@ -30,15 +30,15 @@
self.fpIn = fpIn
self.fpOut = fpOut
self.verbose = verbose
!
!
def __writeAttributes(self, attributes):
for (attr, value) in attributes:
self.fpOut.write(" %s=\"%s\"" % (attr, value))
--- 21,27 ----
self.fpIn = fpIn
self.fpOut = fpOut
self.verbose = verbose
!
!
def __writeAttributes(self, attributes):
for (attr, value) in attributes:
self.fpOut.write(" %s=\"%s\"" % (attr, value))
Expand All @@ -47,25 +47,25 @@
self.__setAttribute(attributes, "sysid", self.sysid)
self.__writeAttributes(attributes)
self.fpOut.write(">\n")
!
!
def start_hl(self, attributes):
if self.verbose:
verbosePrint("start_hl\n")
self.fpOut.write("<hl>\n")
!
!
def start_p(self, attributes):
if self.verbose:
verbosePrint("start_p\n")
--- 60,71 ----
self.__setAttribute(attributes, "sysid", self.sysid)
self.__writeAttributes(attributes)
self.fpOut.write(">\n")
!
!
def start_hl(self, attributes):
if self.verbose:
verbosePrint("start_hl\n")
self.fpOut.write("<hl>\n")
!
!
def start_p(self, attributes):
if self.verbose:
verbosePrint("start_p\n")
Expand All @@ -74,23 +74,23 @@
def end_p(self):
if self.verbose:
verbosePrint("end_p\n")
! self.fpOut.write("</p>\n")

! self.fpOut.write("</p>\n")
def end_srcset(self):
if self.verbose:
--- 89,95 ----
def end_p(self):
if self.verbose:
verbosePrint("end_p\n")
! self.fpOut.write("</p>\n")

def end_srcset(self):
if self.verbose:
***************
*** 105,117 ****
verbosePrint("end_seg\n")
self.fpOut.write("</seg>\n")

def main():
usage = "usage: %prog [options] [sgmfile]"
optionParser = optparse.OptionParser(usage=usage)
Expand All @@ -100,12 +100,12 @@
! optionParser.add_option("-l", "--targetLang", metavar="language", dest="targetLanguage", help="Set target language")
optionParser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
help="write every step to stderr, useful for finding errors in sgml files")

--- 107,123 ----
verbosePrint("end_seg\n")
self.fpOut.write("</seg>\n")

+
+
def main():
usage = "usage: %prog [options] [sgmfile]"
optionParser = optparse.OptionParser(usage=usage)
Expand All @@ -118,22 +118,22 @@
! dest="targetLanguage", help="Set target language")
optionParser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
help="write every step to stderr, useful for finding errors in sgml files")

***************
*** 125,139 ****
else:
try:
fpIn = open(args[0])
! except IOError, ioError:
! optionParser.error("couldn't open %s, %s" % (args[0], ioError[1]))

if not options.sourceFilename:
optionParser.error("a source filename should be given")
try:
fpSource = open(options.sourceFilename)
! except IOError, ioError:
! optionParser.error("couldn't open %s, %s" % (args[0], ioError[1]))

if not options.targetLanguage:
optionParser.error("a target language should be given")
--- 131,145 ----
Expand All @@ -142,14 +142,14 @@
fpIn = open(args[0])
! except IOError:
! optionParser.error("couldn't open %s, %s" % (args[0]))

if not options.sourceFilename:
optionParser.error("a source filename should be given")
try:
fpSource = open(options.sourceFilename)
! except IOError:
! optionParser.error("couldn't open %s, %s" % (args[0]))

if not options.targetLanguage:
optionParser.error("a target language should be given")
***************
Expand All @@ -159,10 +159,10 @@
fpOut = open(options.outFilename, "w")
! except IOError, ioError:
! optionParser.error("couldn't open %s for writing, %s" % (options.outFilename, ioError[1]))

! parser = SGMLRefParser(options.sysid, options.targetLanguage, fpIn, fpOut, options.verbose)
parser.feed(fpSource.read())
!
!
if __name__ == "__main__":
main()
--- 152,165 ----
Expand All @@ -172,11 +172,11 @@
! except IOError:
! optionParser.error("couldn't open %s for writing, %s" %
! (options.outFilename))

! parser = SGMLRefParser(options.sysid, options.targetLanguage,
! fpIn, fpOut, options.verbose)
parser.feed(fpSource.read())
!
!
!
!
if __name__ == "__main__":
main()
46 changes: 23 additions & 23 deletions tools/installers/patch_mwerSegmenter/sgm2mref.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
***************
*** 1,12 ****
! #!/usr/bin/env python

import sys
from sgmllib import SGMLParser
import optparse

def normalize(reference):
return reference.replace("#", "\\#").replace("\n", " ").strip()

class ReferenceSet:
def __init__(self):
self.references = []
--- 1,14 ----
! #!/usr/bin/env python2

import sys
from sgmllib import SGMLParser
import optparse

+
+
def normalize(reference):
return reference.replace("#", "\\#").replace("\n", " ").strip()

+
+
class ReferenceSet:
def __init__(self):
self.references = []
Expand All @@ -34,8 +34,8 @@
--- 28,34 ----
output.write(" # %s" % normalize(r))
output.write("\n")

+
+
class SGMLRefParser(SGMLParser):
def __init__(self, referenceSet, verbose):
SGMLParser.__init__(self)
Expand All @@ -47,7 +47,7 @@
! self.referenceSet.addReference("%s#%s" % (self.basekey, self.segid), self.lastReference)
self.inSegment = False
self.lastReference = None

--- 57,64 ----
if self.verbose:
sys.stderr.write("end_seg\n")
Expand All @@ -56,14 +56,14 @@
! self.basekey, self.segid), self.lastReference)
self.inSegment = False
self.lastReference = None

***************
*** 66,77 ****
self.lastReference += " %s" % (data.strip())
else:
self.lastReference = data.strip()
!

!
def main():
usage = "usage: %prog [options] sgmfile"
optionParser = optparse.OptionParser(usage=usage)
Expand All @@ -75,8 +75,8 @@
self.lastReference += " %s" % (data.strip())
else:
self.lastReference = data.strip()
!

!
def main():
usage = "usage: %prog [options] sgmfile"
optionParser = optparse.OptionParser(usage=usage)
Expand All @@ -92,20 +92,20 @@
fpIn = open(args[0])
! except IOError, ioError:
! optionParser.error("couldn't open %s, %s" % (args[0], ioError[1]))

if not options.outFilename:
fpOut = sys.stdout
else:
try:
fpOut = open(options.outFilename, "w")
! except IOError, ioError:
! optionParser.error("couldn't open %s for writing, %s" % (options.outFilename, ioError[1]))
!
!
referenceSet = ReferenceSet()
parser = SGMLRefParser(referenceSet, options.verbose)
parser.feed(fpIn.read())
referenceSet.printReferences(fpOut)
!
!
if __name__ == "__main__":
main()
--- 86,108 ----
Expand All @@ -114,7 +114,7 @@
fpIn = open(args[0])
! except IOError:
! optionParser.error("couldn't open %s, %s" % (args[0]))

if not options.outFilename:
fpOut = sys.stdout
else:
Expand All @@ -123,12 +123,12 @@
! except IOError:
! optionParser.error("couldn't open %s for writing, %s" %
! (options.outFilename))
!
!
referenceSet = ReferenceSet()
parser = SGMLRefParser(referenceSet, options.verbose)
parser.feed(fpIn.read())
referenceSet.printReferences(fpOut)
!
!
!
!
if __name__ == "__main__":
main()