From cd67aeba90aee429cbbb67d3da2d63a850da3f39 Mon Sep 17 00:00:00 2001 From: Tino Didriksen Date: Wed, 20 Nov 2019 13:34:20 +0000 Subject: [PATCH] Release 2.2.0; Use shared tools; Python3 --- AUTHORS | 17 ++-- Makefile.am | 23 ++--- configure.ac | 13 ++- gent1x.py | 25 +++-- genvrdix.py | 66 ------------ metalrx-to-lrx.xslt | 129 ----------------------- metalrx.py | 56 ---------- translate-to-default-equivalent.xsl | 153 ---------------------------- 8 files changed, 39 insertions(+), 443 deletions(-) delete mode 100644 genvrdix.py delete mode 100644 metalrx-to-lrx.xslt delete mode 100644 metalrx.py delete mode 100644 translate-to-default-equivalent.xsl diff --git a/AUTHORS b/AUTHORS index 22520b38..694d1466 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,9 +1,14 @@ -2010-2017, Xavi Ivars -2017, Hèctor Alòs i Font -2013-2017, Kevin Brubeck Unhammer -2007-2016, Gema Ramírez Sánchez -2007-2015, Mikel L. Forcada -2007-2015, Francis M. Tyers +2017-2019, Jaume Ortolà i Font +2010-2019, Xavi Ivars +2018-2019, Marc Riera Irigoyen +2017-2019, Hèctor Alòs i Font +2007-2019, Gema Ramírez Sánchez +2013-2019, Kevin Brubeck Unhammer +2017-2019, Donís Seguí +2018, Alberto Navalon +2007-2018, Mikel L. Forcada +2007-2018, Francis M. Tyers +2018, Sushain Cherivirala 2007-2014, Sergio Ortiz Rojas 2008-2012, Jim O'Regan 2012, Anthony J. Bentley diff --git a/Makefile.am b/Makefile.am index 21567bb4..c564efc0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,6 @@ ## Makefile for Spanish--Catalan ############################################################################### -VERSION=2.1.0 LANG1=spa LANG2=cat @@ -144,16 +143,16 @@ $(PREFIX2).rlx.bin: $(AP_SRC2)/apertium-$(LANG2).$(LANG2).rlx ############################################################################### .deps/$(PREFIX1).dix: $(BASENAME).$(PREFIX1).dix .deps/.d - xsltproc translate-to-default-equivalent.xsl $< > $@ + apertium-translate-to-default-equivalent $< $@ .deps/$(PREFIX1).cat.dix: .deps/$(PREFIX1).dix - python genvrdix.py cat $< >$@ + apertium-genvrdix cat $< >$@ .deps/$(PREFIX1).val_gva.dix: .deps/$(PREFIX1).dix - python genvrdix.py val_gva $< >$@ + apertium-genvrdix val_gva $< >$@ .deps/$(PREFIX1).val_uni.dix: .deps/$(PREFIX1).dix - python genvrdix.py val_uni $< >$@ + apertium-genvrdix val_uni $< >$@ $(PREFIX1C).autobil.bin: .deps/$(PREFIX1).cat.dix apertium-validate-dictionary $< @@ -176,12 +175,10 @@ $(PREFIX2).autobil.bin: $(BASENAME).$(PREFIX1).dix ############################################################################### .deps/%.metalrx: %.metalrx - python3 metalrx.py $< $@ + apertium-metalrx $< $@ -.deps/%.lrx: metalrx-to-lrx.xslt .deps/%.metalrx - xsltproc $^ > $@.tmp - @xmllint --format $@.tmp > $@ - @rm $@.tmp +.deps/%.lrx: .deps/%.metalrx + apertium-metalrx-to-lrx $< $@ $(PREFIX1).autolex.bin: .deps/$(BASENAME).$(PREFIX1).lrx lrx-comp $< $@ @@ -207,13 +204,13 @@ $(PREFIX1U).t1x.bin: $(PREFIX1U).t1x apertium-preprocess-transfer $< $@ .deps/$(BASENAME).$(PREFIX1).cat.t1x: $(BASENAME).$(PREFIX1).t1x - python gent1x.py cat $< >$@ + python3 gent1x.py cat $< >$@ .deps/$(BASENAME).$(PREFIX1).val_gva.t1x: $(BASENAME).$(PREFIX1).t1x - python gent1x.py val_gva $< >$@ + python3 gent1x.py val_gva $< >$@ .deps/$(BASENAME).$(PREFIX1).val_uni.t1x: $(BASENAME).$(PREFIX1).t1x - python gent1x.py val_uni $< >$@ + python3 gent1x.py val_uni $< >$@ $(PREFIX1C).t1x: .deps/$(BASENAME).$(PREFIX1).cat.t1x xsltproc --stringparam alt cat alt.xsl $< >$@ diff --git a/configure.ac b/configure.ac index c1a6e7cd..74d67039 100644 --- a/configure.ac +++ b/configure.ac @@ -1,23 +1,22 @@ AC_PREREQ(2.52) -AC_INIT([Apertium Spanish-Catalan], [2.1.0], [xavi.ivars@gmail.com], [apertium-spa-cat], [http://wiki.apertium.org/wiki/Apertium-spa-cat]) +AC_INIT([Apertium Spanish-Catalan], [2.2.0], [apertium-stuff@lists.sourceforge.net], [apertium-spa-cat], [http://wiki.apertium.org/wiki/Apertium-spa-cat]) AM_INIT_AUTOMAKE -AC_PROG_LN_S AC_PROG_AWK -m4_define([required_apertium_version], [3.4.0]) -PKG_CHECK_MODULES(APERTIUM, apertium >= required_apertium_version, [], [PKG_CHECK_MODULES(APERTIUM, apertium-3.2 >= required_apertium_version)]) +PKG_CHECK_MODULES(APERTIUM, apertium >= 3.6.0) +PKG_CHECK_MODULES(LTTOOLBOX, lttoolbox >= 3.5.0) +PKG_CHECK_MODULES(CG3, cg3 >= 1.3.0) AC_PATH_PROGS(ZCAT, [gzcat zcat], [false]) AS_IF([test x$ZCAT = xfalse], [AC_MSG_ERROR([You don't have zcat nor gzcat installed])]) m4_ifdef([AP_CHECK_LING],[],[AC_MSG_ERROR([AP_CHECK_LING not defined, is apertium.m4 in ACLOCAL_PATH? See: http://wiki.apertium.org/wiki/Installation_troubleshooting])]) -AP_CHECK_LING([1], [apertium-spa]) -AP_CHECK_LING([2], [apertium-cat]) +AP_CHECK_LING([1], [apertium-spa], [1.2.0]) +AP_CHECK_LING([2], [apertium-cat], [2.8.0]) AP_MKINCLUDE AC_OUTPUT([Makefile]) - diff --git a/gent1x.py b/gent1x.py index 17f7f0b3..12e5b3bb 100644 --- a/gent1x.py +++ b/gent1x.py @@ -13,29 +13,29 @@ def printAttrs(attrsmap): if len(attrsmap) == 0: return "" output = [] - for (i,j) in attrsmap.items(): + for (i,j) in list(attrsmap.items()): output.append(i) output.append("=\"") output.append(saxutils.escape(j)) output.append("\" ") - - return " " + "".join(output).strip() + + return " " + "".join(output).strip() class DixHandler(handler.ContentHandler): def __init__(self, out = sys.stdout): handler.ContentHandler.__init__(self) self._out = out self._buf = [] - + def flush(self): for i in self._buf: - self._out.write(i.encode("utf-8")) + self._out.write(i) self._buf = [] - - + + def startElement(self, name, attrs): if "alt" in attrs: - attrs2 = {i:j for (i,j) in attrs.items() if i != "alt"} + attrs2 = {i:j for (i,j) in list(attrs.items()) if i != "alt"} vals = attrs["alt"].split() if alternative in vals: attrs2["alt"] = alternative @@ -43,7 +43,7 @@ def startElement(self, name, attrs): attrs2["alt"] = alt_other attrs = attrs2 self._buf.append("<" + name + printAttrs(attrs) + ">") - + def endElement(self, name): if len(self._buf) > 0 and self._buf[-1][0:1] == "<" and self._buf[-1][-1:] == ">" and self._buf[-1][1:2] != "/": self._buf[-1] = self._buf[-1][0:-1]+"/>" @@ -53,14 +53,13 @@ def endElement(self, name): self._out.write("") - + def characters(self, content): self.flush() - self._out.write(saxutils.escape(content).encode("utf-8")) - + self._out.write(saxutils.escape(content)) + parser = make_parser() parser.setContentHandler(DixHandler()) with open(dixfile, "r") as f: parser.parse(f) - \ No newline at end of file diff --git a/genvrdix.py b/genvrdix.py deleted file mode 100644 index b1af61e4..00000000 --- a/genvrdix.py +++ /dev/null @@ -1,66 +0,0 @@ -from xml.sax import handler, saxutils, make_parser -import sys - -vr_other = "other" - -alternative = sys.argv[1] -dixfile = sys.argv[2] - -if alternative == "other": - vr_other = vr_other[::-1] # reverse string - -def printAttrs(attrsmap): - if len(attrsmap) == 0: - return "" - output = [] - for (i,j) in attrsmap.items(): - output.append(i) - output.append("=\"") - output.append(saxutils.escape(j)) - output.append("\" ") - - return " " + "".join(output).strip() - -class DixHandler(handler.ContentHandler): - def __init__(self, out = sys.stdout): - handler.ContentHandler.__init__(self) - self._out = out - self._buf = [] - - def flush(self): - for i in self._buf: - self._out.write(i.encode("utf-8")) - self._buf = [] - - - def startElement(self, name, attrs): - if name == "e" and "vr" in attrs: - attrs2 = {i:j for (i,j) in attrs.items() if i != "vr"} - vals = attrs["vr"].split() - if alternative in vals: - attrs2["vr"] = alternative - else: - attrs2["vr"] = vr_other - attrs = attrs2 - self._buf.append("<" + name + printAttrs(attrs) + ">") - - def endElement(self, name): - if len(self._buf) > 0 and self._buf[-1][0:1] == "<" and self._buf[-1][-1:] == ">" and self._buf[-1][1:2] != "/": - self._buf[-1] = self._buf[-1][0:-1]+"/>" - self.flush() - else: - self.flush() - self._out.write("") - - def characters(self, content): - self.flush() - self._out.write(saxutils.escape(content).encode("utf-8")) - -parser = make_parser() -parser.setContentHandler(DixHandler()) - -with open(dixfile, "r") as f: - parser.parse(f) - \ No newline at end of file diff --git a/metalrx-to-lrx.xslt b/metalrx-to-lrx.xslt deleted file mode 100644 index 950afede..00000000 --- a/metalrx-to-lrx.xslt +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Several repeats per rule not supported yet - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/metalrx.py b/metalrx.py deleted file mode 100644 index 5fdc46c2..00000000 --- a/metalrx.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/python3 -# -# Copyright (C) 2018 Xavi Ivars -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# - -import sys -import xml.etree.ElementTree as ET - -source = sys.argv[1] -target = sys.argv[2] - -tree = ET.ElementTree() -tree.parse(source) - -rules = tree.find('rules') - -macros = [] - -for macro in tree.iter(tag='macro'): - - defmacro = tree.find('.//def-macro[@name="' + macro.attrib['name'] + '"]') - - macrostr = ET.tostring(defmacro, encoding="unicode") - for k,v in macro.attrib.items(): - if k.startswith('p'): - kstr = '{{' + k + '}}' - macrostr = macrostr.replace(kstr, v) - - newtree = ET.fromstring('' + macrostr + '') - - for r in newtree.iter(tag='rule'): - rules.append(r) - - macros.append(macro) - -allmacrodefs = tree.getroot().find('def-macros') -if allmacrodefs is not None: - tree.getroot().remove(allmacrodefs) - -for macro in macros: - rules.remove(macro) - -tree.write(target) diff --git a/translate-to-default-equivalent.xsl b/translate-to-default-equivalent.xsl deleted file mode 100644 index 1174230d..00000000 --- a/translate-to-default-equivalent.xsl +++ /dev/null @@ -1,153 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\ No newline at end of file