#path_to_json = 'C:/Users/Αναστασία/Desktop/json/'
#for file_name in [file for file in os.listdir(path_to_json) if file.endswith('.json')]:
#  with open(path_to_json + file_name) as json_file:
#    data=json.load(json_file)
# read list inside dict
#_list = data['Reviews']
# read listvalue and load dict
#for v in _list:
#   reviews.append(v['Content'])
#predictions = model.predict_classes(reviews)
#probabilities = model.predict_probabilities(reviews)
#embeddings = model.embed(reviews)

#forOneJsonFile
with open('C:/Users/Αναστασία/Desktop/json/72572.json', 'r') as f:
    data = json.load(f)

# read list inside dict
_list = data['Reviews']
# read listvalue and load dict
for v in _list:
    reviews.append(v['Content'])

predictions = model.predict_classes(reviews)
print(predictions, '\n')

probabilities = model.predict_probabilities(reviews)
print(probabilities, '\n')

embeddings = model.embed(reviews)
print(embeddings, '\n')
Beispiel #2
0
print("Loaded Model")
'''
tweets = [
    "Watching the sopranos again from start to finish!",
    #"Finding out i have to go to the  dentist tomorrow",
    #"Sun in my eyes but I don't mind, what a beautiful day we've had in New York today!",
    "Feels like someone's stabbed me in my hope",
    "Do people have no Respect for themselves or you know others peoples homes",
    "I want to go outside and chalk but I have no chalk",
    "I hate coming to the doctors when I feel as if I might have a big problem",
    "My mom wasn't mad",
    "You don't indicate once I'm already in the road THEN rev and honk at me you stupid bitch #learnhowtodrive #bitch",
    "Come home from work and this is on my doorstep. I guess he has a secret admirer",
    "The 'egyption hot models' facebook page is pathetic... simply photos of obese horny women.",
    "I HATE PAPERS AH #AH #HATE",
]
'''

tweets = ["Watching the sopranos again from start to finish!"]

print(tweets)

predictions = model.predict_classes(tweets)
print(predictions, '\n')

probabilities = model.predict_probabilities(tweets)
print(probabilities, '\n')

embeddings = model.embed(tweets)
print(embeddings, '\n')
Beispiel #3
0
#pathOfJsonFiles
path_to_json = 'json/'
for file_name in [file for file in os.listdir(path_to_json) if file.endswith('.json')]:
  with open(path_to_json + file_name) as json_file:
    data= []
    data=json.load(json_file)
    # read list inside dict
    _list = data['Reviews']
    # read listvalue and load dict
    for v in _list:
        if ('Title' in v):
            fullContent = v['Title']
        else:
            fullContent = ''

        fullContent = fullContent + ' ' + v['Content']
        reviews.append(fullContent)

        ratings.append(v['Ratings'])
        authors.append(v['Author'])
        hotels.append(data['HotelInfo']['HotelID'])

predictions = model.predict_classes(reviews, ratings, authors, hotels)
print(predictions, '\n')

probabilities = model.predict_probabilities(reviews, ratings, authors, hotels)
print(probabilities, '\n')

embeddings = model.embed(reviews, ratings, authors, hotels)
print(embeddings, '\n')