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/09/18 00:14:02 UTC

[29/30] incubator-joshua git commit: now parses really old TM format

now parses really old TM format


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

Branch: refs/heads/7_confsystem
Commit: fbe6c5f38d281328e59a463aaba5da48eca2a708
Parents: a39c055
Author: Matt Post <po...@cs.jhu.edu>
Authored: Sat Sep 17 23:23:21 2016 +0200
Committer: Matt Post <po...@cs.jhu.edu>
Committed: Sat Sep 17 23:23:21 2016 +0200

----------------------------------------------------------------------
 scripts/compat/sevenize_my_conf_plz.py | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/fbe6c5f3/scripts/compat/sevenize_my_conf_plz.py
----------------------------------------------------------------------
diff --git a/scripts/compat/sevenize_my_conf_plz.py b/scripts/compat/sevenize_my_conf_plz.py
index 012456f..ccdf036 100755
--- a/scripts/compat/sevenize_my_conf_plz.py
+++ b/scripts/compat/sevenize_my_conf_plz.py
@@ -57,10 +57,29 @@ for line in sys.stdin:
         weights[name] = weight
 
     elif line.startswith('tm'):
+        """Two types of tm lines are supported. Ones that look like this:
+
+               tm = thrax pt 12 src/test/resources/decoder/constrained/grammar.gz
+
+            and ones that look like this:
+
+               tm = thrax -owner pt -maxlen 12 -path src/test/resources/decoder/constrained/grammar.gz
+        """
 
         _, tm = re.split(r'\s*=\s*', line, 1)
 
-        tms.append(parse_args_to_string(tm))
+        if tm.find("-path") == -1:
+            # first kind
+            classType, owner, maxlen, path = tm.split(' ')
+            className = 'TextGrammar'
+            if os.path.isdir(path):
+                className = 'PackedGrammar'
+
+            tms.append('class = %s, owner = %s, span_limit = %s, path = %s' % (className, owner, maxlen, path))
+
+        else:
+            # second kind
+            tms.append(parse_args_to_string(tm))
 
     elif line.startswith('lm'):
         """Backwards compatibility for old LM specification method"""