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 2016/11/05 21:52:03 UTC
incubator-joshua git commit: added iso639
Repository: incubator-joshua
Updated Branches:
refs/heads/master f23cd0917 -> 2a43cecc5
added iso639
Project: http://git-wip-us.apache.org/repos/asf/incubator-joshua/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-joshua/commit/2a43cecc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/2a43cecc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/2a43cecc
Branch: refs/heads/master
Commit: 2a43cecc508101de9d4a21a1891f114c9333263e
Parents: f23cd09
Author: Matt Post <po...@cs.jhu.edu>
Authored: Sat Nov 5 17:51:20 2016 -0400
Committer: Matt Post <po...@cs.jhu.edu>
Committed: Sat Nov 5 17:51:20 2016 -0400
----------------------------------------------------------------------
scripts/language-pack/build_lp.sh | 5 ++--
scripts/misc/iso639 | 45 ++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/2a43cecc/scripts/language-pack/build_lp.sh
----------------------------------------------------------------------
diff --git a/scripts/language-pack/build_lp.sh b/scripts/language-pack/build_lp.sh
index 1426768..d61d67c 100755
--- a/scripts/language-pack/build_lp.sh
+++ b/scripts/language-pack/build_lp.sh
@@ -28,12 +28,13 @@ set -u
set -e
JOSHUA=$(dirname $0)/../..
+ISO=$JOSHUA/scripts/misc/iso639
date=$(date +%Y-%m-%d)
dest=releases/apache-joshua-$langpair-$date
source_abbr=$(echo $langpair | cut -d- -f1)
target_abbr=$(echo $langpair | cut -d- -f2)
-source=$(iso639 $source_abbr)
-target=$(iso639 $target_abbr)
+source=$($ISO $source_abbr)
+target=$($ISO $target_abbr)
# Create the jar file
(cd $JOSHUA && mvn clean compile assembly:single)
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/2a43cecc/scripts/misc/iso639
----------------------------------------------------------------------
diff --git a/scripts/misc/iso639 b/scripts/misc/iso639
new file mode 100755
index 0000000..c060707
--- /dev/null
+++ b/scripts/misc/iso639
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+"""
+Converts among language names and abbreviations using Python's ISO-639 module.
+https://pypi.python.org/pypi/iso-639/0.4.3
+
+You need to install the iso-639 module:
+
+ pip install [--user] iso-639
+
+Here is some example usage of that module:
+
+ > from iso639 import languages as l
+ > greek = l.get(part1 = 'el')
+ > pprint(vars(greek))
+ {'inverted': 'Greek, Modern (1453-)',
+ 'macro': '',
+ 'name': 'Modern Greek (1453-)',
+ 'names': [],
+ 'part1': 'el',
+ 'part2b': 'gre',
+ 'part2t': 'ell',
+ 'part3': 'ell',
+ 'part5': ''}
+"""
+
+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)
+
+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
+else:
+ lang = iso639.languages.get(name = input)
+ print lang.part1