From f6e8ee0c77e4d1952ad92c7dc62706981c73b109 Mon Sep 17 00:00:00 2001 From: brian Date: Sun, 18 Dec 2022 14:56:43 +0000 Subject: [PATCH] updated code to avoid translating already translated content --- code/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/main.py b/code/main.py index d054187..f85ff63 100644 --- a/code/main.py +++ b/code/main.py @@ -14,7 +14,7 @@ import pandas as pd from database import get_all from clean_data import clean_content_df -from translate import translate +from translate import translate, get_untranslated from database import Data_table # def update(): @@ -74,6 +74,8 @@ def translate_content(): # load all content from database print('loading data from database...') df = get_all() + # remove already translated content + df = df[df['content_en'].isna()] # clean content print('cleaning content...') content_clean_list, id_list = clean_content_df(df) @@ -101,9 +103,7 @@ def translate_content(): dt.execute(query, val_dict) except Exception as e: print(f'error when sending translated content to database: id={id}') - - - + time.sleep(2) if __name__ == '__main__':