You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@joshua.apache.org by mj...@apache.org on 2017/01/31 01:43:50 UTC

[1/2] incubator-joshua git commit: removed unused argument

Repository: incubator-joshua
Updated Branches:
  refs/heads/master e079441a2 -> f92b1ee24


removed unused argument


Project: http://git-wip-us.apache.org/repos/asf/incubator-joshua/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-joshua/commit/f4c24414
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/f4c24414
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/f4c24414

Branch: refs/heads/master
Commit: f4c24414e68528deb2f1091946526c81773bff65
Parents: e079441
Author: Matt Post <po...@cs.jhu.edu>
Authored: Mon Jan 30 20:42:31 2017 -0500
Committer: Matt Post <po...@cs.jhu.edu>
Committed: Mon Jan 30 20:42:31 2017 -0500

----------------------------------------------------------------------
 scripts/training/run_thrax.py | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f4c24414/scripts/training/run_thrax.py
----------------------------------------------------------------------
diff --git a/scripts/training/run_thrax.py b/scripts/training/run_thrax.py
index 11eaa5f..810844a 100755
--- a/scripts/training/run_thrax.py
+++ b/scripts/training/run_thrax.py
@@ -51,7 +51,6 @@ parser.add_argument('-T', dest='tmp_dir', default='/tmp', help='Temporary direct
 parser.add_argument('-v', dest='verbose', default=False, action='store_true', help='Be verbose')
 parser.add_argument('-d', '--debug', dest='debug', default=False, action='store_true', help='Don\'t cleanup')
 parser.add_argument('corpora', nargs='+', help='Either (a) the Thrax input file or (b) the source, target, and aligned corpus files')
-parser.add_argument('alignment_file', help='The alignment between them')
 args = parser.parse_args()
 
 HADOOP   = os.environ['HADOOP']


[2/2] incubator-joshua git commit: added check to see if iso-639 module installed

Posted by mj...@apache.org.
added check to see if iso-639 module installed


Project: http://git-wip-us.apache.org/repos/asf/incubator-joshua/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-joshua/commit/f92b1ee2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/f92b1ee2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/f92b1ee2

Branch: refs/heads/master
Commit: f92b1ee246c51c02e2ca0a4de86ca8092306ed6c
Parents: f4c2441
Author: Matt Post <po...@cs.jhu.edu>
Authored: Mon Jan 30 20:43:41 2017 -0500
Committer: Matt Post <po...@cs.jhu.edu>
Committed: Mon Jan 30 20:43:41 2017 -0500

----------------------------------------------------------------------
 scripts/misc/iso639 | 59 ++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 47 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f92b1ee2/scripts/misc/iso639
----------------------------------------------------------------------
diff --git a/scripts/misc/iso639 b/scripts/misc/iso639
index 8625754..e80b31c 100755
--- a/scripts/misc/iso639
+++ b/scripts/misc/iso639
@@ -39,21 +39,56 @@ Here is some example usage of that module:
 """
 
 import sys
-import iso639
 
 if len(sys.argv) != 2:
-   print "Usage: iso639 LANG"
-   print "where LANG is a language name or abbreviation."
-   sys.exit(1)
+    print "Usage: iso639 LANG"
+    print "where LANG is a language name or abbreviation."
+    sys.exit(1)
+
+# Common manual mappings in order to avoid the potentially
+# not present iso639 module
+quickdict = {
+   'English': 'en',
+   'en': 'English',
+   'Spanish': 'es',
+   'es': 'Spanish',
+   'Hebrew': 'he',
+   'he': 'Hebrew',
+   'German': 'de',
+   'de': 'German',
+   'French': 'fr',
+   'fr': 'French',
+   'Arabic': 'ar',
+   'ar': 'Arabic',
+   'Czech': 'cs',
+   'cs': 'Czech',
+   'Romanian': 'ro',
+   'ro': 'Romanian',
+}
 
 input = sys.argv[1]
 
-if len(input) == 2:
-   lang = iso639.languages.get(part1 = input)
-   print lang.name
-elif len(input) == 3:
-   lang = iso639.languages.get(part3 = input)
-   print lang.name
+if quickdict.has_key(input):
+    print quickdict[input]
+
 else:
-   lang = iso639.languages.get(name = input)
-   print lang.part1
+    # Only load this if we have to
+
+    try:
+        import iso639
+
+        if len(input) == 2:
+            lang = iso639.languages.get(part1 = input)
+            print lang.name
+        elif len(input) == 3:
+            lang = iso639.languages.get(part3 = input)
+            print lang.name
+        else:
+            lang = iso639.languages.get(name = input)
+            print lang.part1
+
+    except ImportError:
+        sys.stderr.write('Can\'t load module iso639 ("pip install --user iso-639")\n')
+
+    except KeyError:
+        sys.stderr.write('Language not found: {}\n'.format(input))