Permalink
Browse files

Added cycle checking to unary rule application, removed unary rule dr…

…op from grammar reader.
  • Loading branch information...
jganitkevitch committed Nov 29, 2010
1 parent f654aa1 commit 48a7806ec56875d3a57d40d33c3f51e5a5ad14b9
View
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="lib" path="lib/asm-3.1.jar"/>
+ <classpathentry kind="lib" path="lib/collections-generic-4.01.jar"/>
+ <classpathentry kind="lib" path="lib/commons-cli-2.0-SNAPSHOT.jar"/>
+ <classpathentry kind="lib" path="lib/jaxen-1.1.1.jar"/>
+ <classpathentry kind="lib" path="lib/jung-algorithms-2.0.jar"/>
+ <classpathentry kind="lib" path="lib/jung-api-2.0.jar"/>
+ <classpathentry kind="lib" path="lib/jung-graph-impl-2.0.jar"/>
+ <classpathentry kind="lib" path="lib/jung-visualization-2.0.jar"/>
+ <classpathentry kind="lib" path="lib/pmd-4.2.5.jar"/>
+ <classpathentry kind="lib" path="lib/testng-5.8-jdk15.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
View
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>joshua_juri</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,12 @@
+#Mon Nov 29 14:57:08 EST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
@@ -18,6 +18,7 @@
package joshua.decoder.chart_parser;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -390,9 +391,12 @@ private int addUnaryNodes(Grammar[] grs, int i, int j) {
}
int qtyAdditionsToQueue = 0;
ArrayList<HGNode> queue = new ArrayList<HGNode>( chartBin.getSortedNodes() );
+ HashSet<Integer> seen_lhs = new HashSet<Integer>();
while (queue.size() > 0) {
HGNode node = queue.remove(0);
+ seen_lhs.add(node.lhs);
+
for(Grammar gr : grs){
if (! gr.hasRuleForSpan(i, j, foreignSentenceLength))
continue;
@@ -409,7 +413,7 @@ private int addUnaryNodes(Grammar[] grs, int i, int j) {
for (Rule rule : rules) { // for each unary rules
ComputeNodeResult states = new ComputeNodeResult(this.featureFunctions, rule, antecedents, i, j, new SourcePath(), stateComputers, this.segmentID);
HGNode resNode = chartBin.addHyperEdgeInCell(states, rule, i, j, antecedents, new SourcePath(), true);
- if (null != resNode) {
+ if (null != resNode && !seen_lhs.contains(resNode.lhs)) {
queue.add(resNode);
qtyAdditionsToQueue++;
}
@@ -55,11 +55,11 @@ protected BilingualRule parseLine(String line) {
// HACK: avoid source-side loop rules
// TODO: global lookup for goal symbol id would really help here
- if ((french.length == 1) && (arity == 1)
- && lhs != GOAL_ID)
- {
- return null;
- }
+// if ((french.length == 1) && (arity == 1)
+// && lhs != GOAL_ID)
+// {
+// return null;
+// }
// english side
String[] englishWords = fields[2].split("\\s+");

0 comments on commit 48a7806

Please sign in to comment.