-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathintent.py
70 lines (64 loc) · 2.39 KB
/
intent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import os.path
from os import path
import pandas as pd
from utils.functions import predictions, get_final_output, load_dataset, getTwitterData
def intentPrediction(hashTagSubject):
print('hashTagSubject',hashTagSubject)
filename = './data.csv'
intent, unique_intent, sentences = load_dataset(filename)
public_tweets_path = os.getcwd() + '/' + hashTagSubject + '.csv'
if path.exists(public_tweets_path):
print('hai')
public_tweets = pd.read_csv(os.path.realpath(public_tweets_path))
prediction = []
final_data = []
for text in public_tweets['tweet']:
predict = predictions(text)
prediction.append(predict)
for pred in prediction:
final_data.append(get_final_output(pred, unique_intent))
intentData = []
for i in range(len(public_tweets['tweet'])):
intentData.append({
'tweet' : public_tweets['tweet'][i],
'intent' : final_data[i]
})
return intentData
else:
print('nai hai')
public_tweets_file = getTwitterData(hashTagSubject)
public_tweets_path = public_tweets_file + '/' + hashTagSubject + '.csv'
public_tweets = pd.read_csv(os.path.realpath(public_tweets_path))
prediction = []
final_data = []
for text in public_tweets['tweet']:
predict = predictions(text)
prediction.append(predict)
for pred in prediction:
final_data.append(get_final_output(pred, unique_intent))
intentData = []
for i in range(len(public_tweets['tweet'])):
intentData.append({
'tweet' : public_tweets['tweet'][i],
'intent' : final_data[i]
})
return intentData
# public_tweets = getTwitterData(hashTagSubject)
# tweetText = []
# prediction = []
# final_data = []
# for tweet in public_tweets:
# tweetText.append(tweet.text)
# for text in tweetText:
# predict = predictions(text)
# prediction.append(predict)
# for pred in prediction:
# final_data.append(get_final_output(pred, unique_intent))
# # print('final_data', final_data)
# intentData = []
# for i in range(len(tweetText)):
# intentData.append({
# 'tweet' : tweetText[i],
# 'intent' : final_data[i]
# })
# return intentData