Thugs_Of_AI / src /fetch.py
“vchandraiitk”
v
d2be14d
Raw History Blame Contribute Delete
1.02 kB
import os
import pandas as pd
import sys
sent_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "data", "generated_sentiments.csv")
transaction_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "data", "transaction_Data.csv")
def get_customer_sentiments_transaction(customer_id):
df_sentiment = pd.read_csv(sent_path)
df_transaction = pd.read_csv(transaction_path)
sentiment_row = df_sentiment[df_sentiment["Customer_Id"] == customer_id]
transaction_row = df_transaction[df_transaction["Customer_Id"] == customer_id]
sentiment_dict = sentiment_row.iloc[0].to_dict()
transaction_dict = transaction_row.iloc[0].to_dict()
return sentiment_row, sentiment_dict, transaction_row, transaction_dict
if __name__ == "__main__":
if len(sys.argv) > 1:
input_text = sys.argv[1]
score = get_customer_sentiments_transaction(input_text)
print(score) # <-- print this so the shell can capture it
else:
print("No input text provided.")