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/17 18:29:06 UTC
[2/9] incubator-joshua git commit: custom phrase table now saved on
deletion
custom phrase table now saved on deletion
Project: http://git-wip-us.apache.org/repos/asf/incubator-joshua/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-joshua/commit/d142c1f0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/d142c1f0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/d142c1f0
Branch: refs/heads/master
Commit: d142c1f0a951fd3c3a564d05c99b8a72c5579e7f
Parents: 9fcbfa1
Author: Matt Post <po...@cs.jhu.edu>
Authored: Thu Nov 17 13:23:32 2016 -0500
Committer: Matt Post <po...@cs.jhu.edu>
Committed: Thu Nov 17 13:24:07 2016 -0500
----------------------------------------------------------------------
.../java/org/apache/joshua/decoder/Decoder.java | 22 +++++++++++++-------
.../org/apache/joshua/server/ServerThread.java | 3 +++
2 files changed, 17 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/d142c1f0/src/main/java/org/apache/joshua/decoder/Decoder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/Decoder.java b/src/main/java/org/apache/joshua/decoder/Decoder.java
index 1df1568..7b202b9 100644
--- a/src/main/java/org/apache/joshua/decoder/Decoder.java
+++ b/src/main/java/org/apache/joshua/decoder/Decoder.java
@@ -674,20 +674,26 @@ public class Decoder {
* @param rule the rule to add
*/
public void addCustomRule(Rule rule) {
+ if (getCustomPhraseTable() != null) {
+ getCustomPhraseTable().addRule(rule);
+ rule.estimateRuleCost(featureFunctions);
+ getCustomPhraseTable().save();
+ }
+ }
+
+ public Grammar getCustomPhraseTable() {
if (customPhraseTable == null) {
- LOG.warn("No custom grammar was found in the config file; can't add rule");
+ LOG.warn("No custom grammar was found in the config file, so none was instantiated");
LOG.warn("Add the following line to your config and restart Joshua to enable it:");
LOG.warn(" tm = phrase -owner custom -maxspan 20 -path /path/to/custom.grammar");
LOG.warn("The owner must be 'custom'");
}
-
- customPhraseTable.addRule(rule);
- rule.estimateRuleCost(featureFunctions);
-
- customPhraseTable.save();
- }
- public Grammar getCustomPhraseTable() {
return customPhraseTable;
}
+
+ public void saveCustomPhraseTable() {
+ if (getCustomPhraseTable() != null)
+ getCustomPhraseTable().save();
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/d142c1f0/src/main/java/org/apache/joshua/server/ServerThread.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/server/ServerThread.java b/src/main/java/org/apache/joshua/server/ServerThread.java
index 6cb4bf1..0eb8109 100644
--- a/src/main/java/org/apache/joshua/server/ServerThread.java
+++ b/src/main/java/org/apache/joshua/server/ServerThread.java
@@ -305,6 +305,9 @@ public class ServerThread extends Thread implements HttpHandler {
}
}
}
+
+ decoder.saveCustomPhraseTable();
+
break;
}
default: {