示例#1
0
import food
food_data = food.get_reports()
print(len(food_data))
#print(list_of_report[0]["Data"]["Beta Crytoxanthin"]
for food in food_data:
    print(food["Description"])
示例#2
0
from nltk.tokenize import word_tokenize
from nltk.corpus import wordnet as wn
from nltk import pos_tag
from nltk.tokenize import MWETokenizer
from itertools import permutations
from prettytable import PrettyTable

import re
import food
import inflect

file = open("twitter_text2.txt", "r", encoding="utf-8")
#print(file.read())

text = file.read()
list_of_report = food.get_reports()

#make set of joined word permutations - changed from list to set to ensure only one instance per food
list_join_wd_permutations = set()

#make list of mwe tokenizers joined by space
mwe_tokenizer = MWETokenizer(separator=' ')

#dictionary to count the food words
counter = dict()

#total food count
total = 0

#smallword_list = ['of', 'the', 'and', 'out', 'na', 'vit', 'n']
stopwords = set(stopwords.words('english'))
import food

list_of_food = food.get_reports(test=False)
'''
for item in list_of_food[5]:
    print("----KEY ", item, " ----")
    print(list_of_food[5][item])
    print('\n')
'''
x = 0
num_cheese = 0
for item in list_of_food:
    if "CHEESE" in item["Description"]:
        print("--- ", item["Category"], " ---")
        print(item['Description'])
        '''
        for item in list_of_food[x]:
            print("----KEY ", item, " ----")
            print(list_of_food[x][item])
            print('\n')
        '''
        num_cheese += 1
    #else:
        #print("No Cheese Found")
    x += 1

print("There are ", num_cheese, " different kinds of cheese!")