changeset 531:90a76a8238e8

Added function length()
author Joseph Turian <turian@iro.umontreal.ca>
date Tue, 18 Nov 2008 00:32:39 -0500
parents 844bad76459c
children 34ee3aff3e8f
files embeddings/process.py
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/embeddings/process.py	Mon Nov 17 14:18:28 2008 -0500
+++ b/embeddings/process.py	Tue Nov 18 00:32:39 2008 -0500
@@ -11,6 +11,12 @@
 __word_to_embedding = None
 __read = False
 
+def length():
+    """
+    @return: The length of embeddings
+    """
+    len(__word_to_embedding[0])
+
 def word_to_embedding(w):
     read_embeddings()
     return __word_to_embedding[w]
@@ -39,6 +45,7 @@
         w = __words[i]
         __word_to_embedding[w] = l
     __read = True
+    for w in __word_to_embedding: assert len(__word_to_embedding[__words[0]]) == len(__word_to_embedding[w])
     sys.stderr.write("...done reading %s\n" % WEIGHTSFILE)
 
 import re