#!/usr/bin/env python
#coding=utf-8

try :
    import cPickle as pickle
except :
    import pickle 
import sys
import os
import logging
import traceback
import math


import build_stop_words
build_stop_words.load_stop_words("stop_words")

POSITIVE_LABEL = "1"
NEGATIVE_LABEL = "-1"

class word_bag :
    docs = {}
    features = {}
    dtypes = {}
    CHI = {}
    N = 0
    top_k_feature = {}
    def add_word_bag(self,dtype , doc , feature) :
        # build dtypes
        if dtype not in self.dtypes :
            self.dtypes[dtype] = {doc:True} # for fast
Exemplo n.º 2
0
#!/usr/bin/env python
#coding=utf-8

try:
    import cPickle as pickle
except:
    import pickle
import sys
import os
import logging
import traceback
import math

import build_stop_words
build_stop_words.load_stop_words("stop_words")

POSITIVE_LABEL = "1"
NEGATIVE_LABEL = "-1"


class word_bag:
    docs = {}
    features = {}
    dtypes = {}
    CHI = {}
    N = 0
    top_k_feature = {}

    def add_word_bag(self, dtype, doc, feature):
        # build dtypes
        if dtype not in self.dtypes:
#coding=utf-8

try :
    import cPickle as pickle
except :
    import pickle 
import sys
import os
import logging
import traceback
import math

sys.path.append("../seg/")

import build_stop_words
build_stop_words.load_stop_words("../seg/stop_words")

POSITIVE_TYPE = "t1"


class word_bag :
    docs = {}
    features = {}
    dtypes = {}
    CHI = {}
    N = 0
    top_k_feature = {}
    def add_word_bag(self,dtype , doc , feature) :
        # build dtypes
        if dtype not in self.dtypes :
            self.dtypes[dtype] = {doc:True} # for fast