Using Joshua-generated grammar in Moses

Skip to first unread message

Jeremy Gwinnup

Jul 24, 2015, 10:11:40 AM7/24/15
to Joshua Technical Support
Apologies if this isn't quite the right place to ask

Is there a way to convert a joshua-generated hiero grammar (built with v6.0.4) for use with Moses? I've found the scripts to go from Moses to Joshua in support but am interested in the other direction.


Matt Post

Jul 24, 2015, 10:41:15 AM7/24/15
Yes, this shouldn't be too hard. I don't have an existing script to do it, though.

Here is the script that converts Moses to Joshua:

Here is the example from the top of that script:


[PP] ||| der [NN,1] ||| of the [NN,1] ||| .301 .6989


der [X][NN] [X] ||| of the [X][NN] [PP] ||| 0-0 0-1 1-2 ||| 0.5 0.2 ||| |||

It shouldn't be hard to invert this. The differences in the formats are:

- Moses does not have an extra field for the lefthand side. Instead, it uses the last token on both the source and target sides to list the left-hand side symbols

- Joshua adopts a convention that requires synchronous nonterminals on the source and target sides to have the same symbol, and then uses a shortcut where you only have to list it once. Moses does not require symbols to match, but instead permits different symbols (note that this doesn't add any formal power). Usually, the source side is all Xs, and the target side reflects any actual syntax.

- Moses takes the log of all dense features; Joshua assumes you have handed it negative log values, and inverts them so that they are regular logs. Joshua also permits labeled features, which it won't convert. I don't know if Moses permits labeled features in the grammar file.

If you write a script, please send it our way so I can include it!


You received this message because you are subscribed to the Google Groups "Joshua Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

Reply all
Reply to author
0 new messages