# Path: vsmlib/misc/formathelper.py
# def countof_fmt(num, suffix=''):
#     for unit in ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z']:
#         if abs(num) < 1000.0:
#             return "%3.1f%s%s" % (num, unit, suffix)
#         num /= 1000.0
#     return "%.1f%s%s" % (num, 'Y', suffix)
# 
# def sizeof_fmt(num, suffix='B'):
#     for unit in ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi']:
#         if abs(num) < 1024.0:
#             return "%3.1f%s%s" % (num, unit, suffix)
#         num /= 1024.0
#     return "%.1f%s%s" % (num, 'Yi', suffix)


import numpy as np
import scipy
import os
import time
from vsmlib.misc.formathelper import countof_fmt, sizeof_fmt
    cooccurrence = sparse.dok_matrix(
        (cnt_unique_words, cnt_unique_words), dtype=np.float32)
    file_in = open(os.path.join(dir_root, "bigrams_list"))
    for line in file_in:
        tokens = line.split()
        cooccurrence[int(tokens[0]), int(tokens[1])] = float(tokens[2])
    file_in.close()
    return cooccurrence


def get_sparsity(x):
    if scipy.sparse.issparse(x):
        sparsity = (x.nnz) / (x.shape[0] * x.shape[1])
    else:
        sparsity = np.count_nonzero(ut) / (x.shape[0] * x.shape[1])
    return sparsity


def print_stats(m):
    print(
        "Matrix dimentions : {} ({} unique words in the corpus )".format(
            m.shape,
            countof_fmt(
                m.shape[0])))
    size_float = 4
    print("Would take {} if stored in dense format".format(
        sizeof_fmt(size_float * m.shape[0] * m.shape[1])))
    print(
        "Cnt nonzero elements = {} (should take about {} of memory space".format(
            m.nnz,

# Path: vsmlib/misc/formathelper.py
# def countof_fmt(num, suffix=''):
#     for unit in ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z']:
#         if abs(num) < 1000.0:
#             return "%3.1f%s%s" % (num, unit, suffix)
#         num /= 1000.0
#     return "%.1f%s%s" % (num, 'Y', suffix)
# 
# def sizeof_fmt(num, suffix='B'):
#     for unit in ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi']:
#         if abs(num) < 1024.0:
#             return "%3.1f%s%s" % (num, unit, suffix)
#         num /= 1024.0
#     return "%.1f%s%s" % (num, 'Yi', suffix)


# Path: vsmlib/blas/sparse.py
import numpy as np
import scipy
import os
import time
from vsmlib.misc.formathelper import countof_fmt, sizeof_fmt

    cooccurrence = sparse.dok_matrix(
        (cnt_unique_words, cnt_unique_words), dtype=np.float32)
    file_in = open(os.path.join(dir_root, "bigrams_list"))
    for line in file_in:
        tokens = line.split()
        cooccurrence[int(tokens[0]), int(tokens[1])] = float(tokens[2])
    file_in.close()
    return cooccurrence


def get_sparsity(x):
    if scipy.sparse.issparse(x):
        sparsity = (x.nnz) / (x.shape[0] * x.shape[1])
    else:
        sparsity = np.count_nonzero(ut) / (x.shape[0] * x.shape[1])
    return sparsity


def print_stats(m):
    print(
        "Matrix dimentions : {} ({} unique words in the corpus )".format(
            m.shape,
            countof_fmt(
                m.shape[0])))
    size_float = 4
    print("Would take {} if stored in dense format".format(
        sizeof_fmt(size_float * m.shape[0] * m.shape[1])))
    print(
        "Cnt nonzero elements = {} (should take about {} of memory space".format(
            m.nnz,

            sizeof_fmt(