def from_file(cls, f):
        """Load vocab from a file.

        :param (file) f: a file object, e.g. as returned by calling `open`
        :return: a vocab object. The 0th line of the file is assigned to index 0, and so on...
        """
        word2index = {}
        counts = Counter()
        for i, line in enumerate(f):
            word, count_str = line.split('\t')
            word = word.decode('utf-8')
            word2index[word] = i
            counts[word] = float(count_str)
            if i == 0:
                unk = word
        return cls.from_dict(word2index, unk, counts)