summaryrefslogtreecommitdiff
path: root/python/test.py
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2012-07-03 15:43:20 +0200
committerPatrick Simianer <p@simianer.de>2012-07-03 15:43:20 +0200
commit96bb9719858dd1600d70a3affee42d0e0c5cd862 (patch)
treef762a5f84b1b72aa4cbb84ae87b2697daef7c727 /python/test.py
parenta2422421fbbaf20ad5dbe44a7ef84df53e0a3e76 (diff)
parent2153329ff36f50fd8e23e57cb0fae7bfbe207bda (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'python/test.py')
-rw-r--r--python/test.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/python/test.py b/python/test.py
index 92403298..8069aa0a 100644
--- a/python/test.py
+++ b/python/test.py
@@ -31,9 +31,11 @@ print ' FTree[0]:', forest.viterbi_source_tree().encode('utf8')
print 'LgProb[0]:', forest.viterbi_features().dot(decoder.weights)
# Get k-best translations
-for i, (sentence, tree) in enumerate(zip(forest.kbest(5), forest.kbest_tree(5)), 1):
+kbest = zip(forest.kbest(5), forest.kbest_tree(5), forest.kbest_features(5))
+for i, (sentence, tree, features) in enumerate(kbest, 1):
print 'Output[%d]:' % i, sentence.encode('utf8')
print ' Tree[%d]:' % i, tree.encode('utf8')
+ print ' FVect[%d]:' % i, dict(features)
# Sample translations from the forest
for sentence in forest.sample(5):
@@ -58,3 +60,6 @@ print forest.viterbi_source_tree()
# Compare 1best and reference feature vectors
fref = forest.viterbi_features()
print dict(fsrc - fref)
+
+# Prune hypergraph
+forest.prune(density=100)