Modified:
/branches/thefuture-modules/thebeast-apps/src/main/scala/org/riedelcastro/thebeast/apps/DependencyParsing.scala
/branches/thefuture-modules/thebeast-core/src/main/scala/org/riedelcastro/thebeast/env/combinatorics/SpanningTreeConstraint.scala
=======================================
---
/branches/thefuture-modules/thebeast-apps/src/main/scala/org/riedelcastro/thebeast/apps/DependencyParsing.scala
Fri Mar 26 20:58:54 2010
+++
/branches/thefuture-modules/thebeast-apps/src/main/scala/org/riedelcastro/thebeast/apps/DependencyParsing.scala
Fri Mar 26 21:54:48 2010
@@ -24,6 +24,7 @@
val word = Predicate("word", Tokens x Words)
val pos = Predicate("pos", Tokens x Tags)
val token = Predicate("token", Tokens)
+ val candidate = Predicate("cand", Tokens x Tokens)
val ROOT = "Root"
@@ -46,7 +47,10 @@
env.atoms(word) ++= asTokenProperties(ROOT,rows.map(row => row(1)))
env.atoms(pos) ++= asTokenProperties(ROOT,rows.map(row => row(3)))
env.atoms(link) ++= rows.map(row => row(6).toInt->row(0).toInt)
- env.close(Set(token,word,pos,link),true)
+ for (i <- 0 until rows.size + 1; j <- 1 until rows.size+1; if
(i != j)){
+ env.atoms(candidate) ++= Seq(i->j)
+ }
+ env.close(Set(token,word,pos,link,candidate),true)
result += env
if (result.size == to) return result.drop(from)
} else {
@@ -68,7 +72,7 @@
edgeCounts(headTag->childTag) =
edgeCounts.getOrElse(headTag->childTag,0) + 1
}
}
- Map() ++ (for (edge <- edgeCounts.keys) yield edge ->
edgeCounts(edge).toDouble / childCounts(edge._2))
+ Map() ++ (for (edge <- edgeCounts.keys) yield edge ->
Math.log(edgeCounts(edge).toDouble / childCounts(edge._2)))
}
@@ -162,7 +166,7 @@
val posPair = vectorSum(Tokens, Tokens, Tags, Tags) {
(h, m, h_pos, m_pos) =>
- $(pos(h, h_pos) && pos(m, m_pos) && link(h, m)) * unit("Pos",
h_pos, m_pos)
+ $(pos(h, h_pos) && pos(m, m_pos) && candidate(h,m) && link(h, m))
* unit("Pos", h_pos, m_pos)
}
val treeConstraint = SpanningTreeConstraint(link, token, 0,
LessThan(Tokens))
=======================================
---
/branches/thefuture-modules/thebeast-core/src/main/scala/org/riedelcastro/thebeast/env/combinatorics/SpanningTreeConstraint.scala
Fri Mar 26 20:58:54 2010
+++
/branches/thefuture-modules/thebeast-core/src/main/scala/org/riedelcastro/thebeast/env/combinatorics/SpanningTreeConstraint.scala
Fri Mar 26 21:54:48 2010
@@ -181,17 +181,6 @@
beliefs.increaseBelief(atom, true, trueBelief)
beliefs.increaseBelief(atom, false, b - trueBelief)
}
- //set self loops and links to root to be impossible
- for (i <- 0 until sorted.size) {
- val self = FunAppVar(pred, (sorted(i), sorted(i)))
- beliefs.increaseBelief(self, true, 0.0)
- beliefs.increaseBelief(self, false, 1.0)
- if (i > 0) {
- val toRoot = FunAppVar(pred, (sorted(i), sorted(0)))
- beliefs.increaseBelief(toRoot, true, 0.0)
- beliefs.increaseBelief(toRoot, false, 1.0)
- }
- }
beliefs
} else
super.marginalize(incoming)