diff options
author | trevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-20 19:35:20 +0000 |
---|---|---|
committer | trevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-20 19:35:20 +0000 |
commit | 0b566e7d99e1fa536bf918bd16069c8e93e2caa9 (patch) | |
tree | 86f94b284f6508c164346a8e01d782805df12eb5 /gi/posterior-regularisation/prjava/src/phrase | |
parent | 68b05cdc63d49dbe26bfb2a99a2dd680ab70c209 (diff) |
Allow fractional counts.
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@337 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'gi/posterior-regularisation/prjava/src/phrase')
5 files changed, 12 insertions, 12 deletions
diff --git a/gi/posterior-regularisation/prjava/src/phrase/Agree.java b/gi/posterior-regularisation/prjava/src/phrase/Agree.java index d61e6eef..f3dc5c36 100644 --- a/gi/posterior-regularisation/prjava/src/phrase/Agree.java +++ b/gi/posterior-regularisation/prjava/src/phrase/Agree.java @@ -112,7 +112,7 @@ public class Agree { bdist += edge.getCount() * Math.log(z);
arr.F.l1normalize(p);
- int count = edge.getCount();
+ double count = edge.getCount();
//increment expected count
TIntArrayList phraseToks = edge.getPhrase();
TIntArrayList contextToks = edge.getContext();
diff --git a/gi/posterior-regularisation/prjava/src/phrase/Agree2Sides.java b/gi/posterior-regularisation/prjava/src/phrase/Agree2Sides.java index 7bc28a40..8bf0b93e 100644 --- a/gi/posterior-regularisation/prjava/src/phrase/Agree2Sides.java +++ b/gi/posterior-regularisation/prjava/src/phrase/Agree2Sides.java @@ -106,7 +106,7 @@ public class Agree2Sides { assert z > 0;
bdist += edge1.getCount() * Math.log(z);
arr.F.l1normalize(p);
- int count = edge1.getCount();
+ double count = edge1.getCount();
//increment expected count
TIntArrayList contextToks1 = edge1.getContext();
TIntArrayList contextToks2 = edge2.getContext();
diff --git a/gi/posterior-regularisation/prjava/src/phrase/C2F.java b/gi/posterior-regularisation/prjava/src/phrase/C2F.java index 31fd4fda..e8783950 100644 --- a/gi/posterior-regularisation/prjava/src/phrase/C2F.java +++ b/gi/posterior-regularisation/prjava/src/phrase/C2F.java @@ -118,7 +118,7 @@ public class C2F { loglikelihood += edge.getCount() * Math.log(z);
arr.F.l1normalize(p);
- int count = edge.getCount();
+ double count = edge.getCount();
//increment expected count
TIntArrayList phrase= edge.getPhrase();
for(int tag=0;tag<K;tag++){
diff --git a/gi/posterior-regularisation/prjava/src/phrase/Corpus.java b/gi/posterior-regularisation/prjava/src/phrase/Corpus.java index ad092cc6..6936b28b 100644 --- a/gi/posterior-regularisation/prjava/src/phrase/Corpus.java +++ b/gi/posterior-regularisation/prjava/src/phrase/Corpus.java @@ -28,7 +28,7 @@ public class Corpus public class Edge { - Edge(int phraseId, int contextId, int count) + Edge(int phraseId, int contextId, double count) { this.phraseId = phraseId; this.contextId = contextId; @@ -58,7 +58,7 @@ public class Corpus { return Corpus.this.getContextString(contextId, insertPhraseSentinel); } - public int getCount() + public double getCount() { return count; } @@ -84,7 +84,7 @@ public class Corpus private int phraseId; private int contextId; - private int count; + private double count; } List<Edge> getEdges() @@ -207,7 +207,7 @@ public class Corpus String countString = parts[i + 1]; assert (countString.startsWith("C=")); - int count = Integer.parseInt(countString.substring(2).trim()); + double count = Double.parseDouble(countString.substring(2).trim()); TIntArrayList ctx = new TIntArrayList(); StringTokenizer ctxStrtok = new StringTokenizer(ctxString, " "); diff --git a/gi/posterior-regularisation/prjava/src/phrase/PhraseCluster.java b/gi/posterior-regularisation/prjava/src/phrase/PhraseCluster.java index e7e4af32..560100d4 100644 --- a/gi/posterior-regularisation/prjava/src/phrase/PhraseCluster.java +++ b/gi/posterior-regularisation/prjava/src/phrase/PhraseCluster.java @@ -109,7 +109,7 @@ public class PhraseCluster { loglikelihood += edge.getCount() * Math.log(z);
arr.F.l1normalize(p);
- int count = edge.getCount();
+ double count = edge.getCount();
//increment expected count
TIntArrayList context = edge.getContext();
for(int tag=0;tag<K;tag++)
@@ -158,7 +158,7 @@ public class PhraseCluster { loglikelihood += edge.getCount() * Math.log(z);
arr.F.l1normalize(p);
- int count = edge.getCount();
+ double count = edge.getCount();
//increment expected count
TIntArrayList context = edge.getContext();
for(int tag=0;tag<K;tag++)
@@ -292,7 +292,7 @@ public class PhraseCluster { for(int edge=0;edge<q.length;edge++){
Edge e = edges.get(edge);
TIntArrayList context = e.getContext();
- int contextCnt = e.getCount();
+ double contextCnt = e.getCount();
//increment expected count
for(int tag=0;tag<K;tag++){
for(int pos=0;pos<n_positions;pos++){
@@ -404,7 +404,7 @@ public class PhraseCluster { for(int edge=0;edge<q.length;edge++){
Edge e = edges.get(edge);
TIntArrayList context = e.getContext();
- int contextCnt = e.getCount();
+ double contextCnt = e.getCount();
//increment expected count
for(int tag=0;tag<K;tag++){
for(int pos=0;pos<n_positions;pos++){
@@ -460,7 +460,7 @@ public class PhraseCluster { Corpus.Edge edge = edges.get(e);
TIntArrayList context = edge.getContext();
- int contextCnt = edge.getCount();
+ double contextCnt = edge.getCount();
//increment expected count
for(int tag=0;tag<K;tag++)
{
|