<filename>lda_cf/preprocessing.py<gh_stars>0
# DO NOT RUN
# for extracting topic from user and business


import nltk
import string
from nltk.corpus import stopwords
from nltk.stem.porter import PorterStemmer


def textProcessing(text):
    # lower words  
    text = text.lower()
    # remove punctuation
    for c in string.punctuation:
        text = text.replace(c, ' ')
    # tokenize
    wordLst = nltk.word_tokenize(text)
    # stop word
    filtered = [w for w in wordLst if w not in stopwords.words('english')]
    # keep noun  
    refiltered =nltk.pos_tag(filtered)
    filtered = [w for w, pos in refiltered if pos.startswith('NN')]
    # xtract the stem
    ps = PorterStemmer()
    filtered = [ps.stem(w) for w in filtered]

    return " ".join(filtered) 

def rating_proportion(text,rate):
    return text * int(rate)
<filename>lda_cf/preprocessing.py<gh_stars>0
# DO NOT RUN
# for extracting topic from user and business


import nltk
import string
from nltk.corpus import stopwords
from nltk.stem.porter import PorterStemmer


def textProcessing(text):
    # lower words  
    text = text.lower()
    # remove punctuation
    for c in string.punctuation:
        text = text.replace(c, ' ')
    # tokenize
    wordLst = nltk.word_tokenize(text)
    # stop word
    filtered = [w for w in wordLst if w not in stopwords.words('english')]
    # keep noun  
    refiltered =nltk.pos_tag(filtered)
    filtered = [w for w, pos in refiltered if pos.startswith('NN')]
    # xtract the stem
    ps = PorterStemmer()
    filtered = [ps.stem(w) for w in filtered]

    return " ".join(filtered) 

def rating_proportion(text,rate):
    return text * int(rate)
# DO NOT RUN # for extracting topic from user and business # lower words # remove punctuation # tokenize # stop word # keep noun # xtract the stem