|
| 1 | +package org.statmt.ghgd; |
| 2 | + |
| 3 | +import java.util.ArrayList; |
| 4 | + |
| 5 | +public class TestHyperGraph { |
| 6 | + |
| 7 | + /** |
| 8 | + * @param args |
| 9 | + */ |
| 10 | + public static void main(String[] args) { |
| 11 | + PhrasePairRule p1 = new PhrasePairRule("guten", "good", new FWeight(0.7f)); |
| 12 | + PhrasePairRule p2 = new PhrasePairRule("guten", "well", new FWeight(0.3f)); |
| 13 | + PhrasePairRule p3 = new PhrasePairRule("tag", "day", new FWeight(0.6f)); |
| 14 | + PhrasePairRule p4 = new PhrasePairRule("tag", "hi", new FWeight(0.4f)); |
| 15 | + PhrasePairRule p5 = new PhrasePairRule("guten tag", "hello", new FWeight(0.2f)); |
| 16 | + PhrasePairRule p6 = new PhrasePairRule("guten tag", "good day", new FWeight(0.8f)); |
| 17 | + And d1 = new And(p1, null, p1.w); |
| 18 | + And d2 = new And(p2, null, p2.w); |
| 19 | + ArrayList<And> a1 = new ArrayList<And>(2); |
| 20 | + a1.add(d1); a1.add(d2); |
| 21 | + Weight w1 = d1.getWeight(); |
| 22 | + Weight w2 = d2.getWeight(); |
| 23 | + Weight best = null; |
| 24 | + if (w1.compareTo(w2) < 0) best = w2; else best = w1; |
| 25 | + Or c1 = new Or(a1, best); |
| 26 | + |
| 27 | + ArrayList<Or> ants1 = new ArrayList<Or>(1); ants1.add(c1); |
| 28 | + And d3 = new And(p3, ants1, p3.w); |
| 29 | + And d4 = new And(p4, ants1, p4.w); |
| 30 | + ArrayList<And> a2 = new ArrayList<And>(2); |
| 31 | + a2.add(d3); a2.add(d4); |
| 32 | + w1 = d3.getWeight(); |
| 33 | + w2 = d4.getWeight(); |
| 34 | + best = null; |
| 35 | + if (w1.compareTo(w2) < 0) best = w2; else best = w1; |
| 36 | + Or c2 = new Or(a2, best); |
| 37 | + |
| 38 | + And d5 = new And(p5, null, p5.w); |
| 39 | + And d6 = new And(p6, null, p6.w); |
| 40 | + ArrayList<And> a3 = new ArrayList<And>(2); |
| 41 | + a3.add(d5); a3.add(d6); |
| 42 | + w1 = d5.getWeight(); |
| 43 | + w2 = d6.getWeight(); |
| 44 | + best = null; |
| 45 | + if (w1.compareTo(w2) < 0) best = w2; else best = w1; |
| 46 | + Or c3 = new Or(a3, best); |
| 47 | + |
| 48 | + } |
| 49 | + |
| 50 | +} |
0 commit comments