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/05/27 00:34:21 UTC
[15/32] incubator-joshua git commit: escaping left curly braces
escaping left curly braces
Project: http://git-wip-us.apache.org/repos/asf/incubator-joshua/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-joshua/commit/f85b68ea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/f85b68ea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/f85b68ea
Branch: refs/heads/JOSHUA-252
Commit: f85b68ea30d5d7a809168c137d751a9698bd575c
Parents: 9b39660
Author: Matt Post <po...@cs.jhu.edu>
Authored: Wed May 25 09:15:28 2016 +0200
Committer: Matt Post <po...@cs.jhu.edu>
Committed: Wed May 25 09:15:28 2016 +0200
----------------------------------------------------------------------
scripts/support/moses2joshua_grammar.pl | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/f85b68ea/scripts/support/moses2joshua_grammar.pl
----------------------------------------------------------------------
diff --git a/scripts/support/moses2joshua_grammar.pl b/scripts/support/moses2joshua_grammar.pl
index ab10a23..4ab2f33 100755
--- a/scripts/support/moses2joshua_grammar.pl
+++ b/scripts/support/moses2joshua_grammar.pl
@@ -1,7 +1,9 @@
#!/usr/bin/env perl
# Matt Post <po...@cs.jhu.edu>
-# Converts a Moses grammars and phrase tables to a Joshua grammar.
+# Converts Moses grammars to a Joshua grammar. This script does not work for phrase tables;
+# Joshua can read Moses phrase tables directly, both via the grammar packer or the memory
+# based grammar loader.
#
# Usage: cat grammar.moses | moses2joshua_grammar.pl > grammar.joshua
#
@@ -17,9 +19,10 @@
#
# (This doesn't apply to phrase tables, of course).
#
-# (2) Phrase table values. Moses takes the log of each feature, whereas Joshua takes just
-# negates the values when it reads them in. To make the conversion correct, this script
-# computes the negative log of each of the feature values.
+# (2) Feautre values. The Moses decoder expects these features to be probabilities, whereas
+# Joshua expects them to be negative logprobs (which it then negates when reading in;
+# I know, this is crazy). To compute the conversion, this script computes the negative
+# log of each of the feature values.
use strict;
use warnings;
@@ -156,7 +159,7 @@ while (my $rule = <>) {
print "$new_rule\n";
if ($opts{m} and defined $tree) {
- $tree =~ s/.*{{Tree\s+(.*)}}.*/$1/;
+ $tree =~ s/.*\{\{Tree\s+(.*)}}.*/$1/;
# Remove brackets around substitution points
$tree =~ s/\[([^\[\]\s]+)\]/$1/g;
# Add quotes around terminals