# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

class W2VClusterDict():
    def __init__(file_path):
        self.word_to_cluster = dict()
        self.fill_from_file(file_path)
    
    def clear(self):
        self.word_to_cluster = dict()
    
    def fill_from_file(self, file_path):
        with open(file_path, "r") as f:
            for line in f:
                columns = line.strip().split("\t")
                if len(columns) == 2:
                    word, cluster_idx = columns
                    self.word_to_dict[word] = cluster_idx
    
    def get_cluster_of(self, word, default=-1):
        if word in self.word_dict:
            return self.word_dict[word]
        else:
            return default

@@ -142,16 +142,22 @@
 _init__(
+self, 
 file_pat
@@ -445,16 +445,32 @@
  = line.
+decode(%22utf-8%22).
 strip().
@@ -600,20 +600,23 @@
 word_to_
-dict
+cluster
 %5Bword%5D =
@@ -710,20 +710,26 @@
 lf.word_
-dict
+to_cluster
 :%0A      
@@ -751,20 +751,26 @@
 lf.word_
-dict
+to_cluster
 %5Bword%5D%0A 

Fix errors in w2v-cluster handler