Exemplo n.º 1
0
vocabulary = [word for [word] in vocabulary]

count = 0
reviewCount = 0
for restaurant in restaurants:
    try:
        resId = restaurant['resId']
        count = count + 1
        print("count " + str(count))
        print('Doing for '+resId)
        for review in restaurant['userReviews']:
            text = review['reviewText']
            reviewCount +=1
            print('Review number' + str(reviewCount))
            adjectives = chunker.getAdjectives(text)
            print('Restaurants done' + str(count))
            if adjectives:
                for (adj,tag) in adjectives:
                    # print(adj.lower())
                    if adj.lower() not in vocabulary:
                        vocabulary.append(adj.lower())
    except:
        pass


print(time.time()-start)
print(len(vocabulary))
with open('../data/vocabulary.csv', 'a', newline='') as csvfile:
    spamwriter = csv.writer(csvfile, delimiter='\n',
                            quotechar='|', quoting=csv.QUOTE_MINIMAL)