|
from decimal import Decimal |
|
from utils import translate, sentiment_computation, get_db_connection |
|
from datetime import datetime |
|
import uuid |
|
|
|
|
|
article_titleCN = input("Enter the title of the article: ") |
|
article_contentCN = input("Paste the article content (CN version) here: ") |
|
article_content = input("Paste the content of the article (EN version) here: ") |
|
article_subtitle = input("Enter the subtitle of the article: ") |
|
article_publish_date = input("Enter the publish date of the article (YYYY-MM-DD): ") |
|
article_link = input("Enter the link to the article: ") |
|
article_siteCN = input("Enter the site of the article: ") |
|
|
|
|
|
|
|
sentiment_score, sentiment_label = sentiment_computation(article_contentCN) |
|
|
|
|
|
article= { |
|
'id': str(uuid.uuid5(uuid.NAMESPACE_OID, article_titleCN + article_publish_date)), |
|
'site': translate(article_siteCN), |
|
'title': translate(article_titleCN), |
|
'titleCN': article_titleCN, |
|
'contentCN': article_contentCN, |
|
'category': "Knowledge Center", |
|
'author': '', |
|
'content': article_content, |
|
'subtitle': article_subtitle, |
|
'publishDate': article_publish_date, |
|
'link': article_link, |
|
'attachment': '', |
|
|
|
|
|
'sentimentScore': Decimal(str(sentiment_score)).quantize(Decimal('0.01')), |
|
'sentimentLabel': sentiment_label, |
|
'LastModifiedDate': datetime.now().strftime("%Y-%m-%dT%H:%M:%S") |
|
} |
|
|
|
|
|
dynamodb = get_db_connection() |
|
table = dynamodb.Table('article_test') |
|
response = table.put_item(Item=article) |
|
print(article) |
|
print(response) |
|
|