lalithadevi
commited on
Commit
•
68c3650
1
Parent(s):
b8405af
Update news_category_similar_news_prediction.py
Browse files
news_category_similar_news_prediction.py
CHANGED
@@ -165,7 +165,7 @@ def predict_news_category_similar_news(old_news: pd.DataFrame, new_news: pd.Data
|
|
165 |
# final_df.loc[(final_df['title'].str.contains('Zodiac Sign', case=False)) | (final_df['title'].str.contains('Horoscope', case=False)), 'category'] = 'SCIENCE'
|
166 |
# logger.warning('Updated category of articles having Zodiac Sign in title to SCIENCE')
|
167 |
|
168 |
-
final_df = process_prediction_df(final_df, df_type="production &
|
169 |
prediction_df = final_df.copy()
|
170 |
|
171 |
else:
|
@@ -192,8 +192,8 @@ def predict_news_category_similar_news(old_news: pd.DataFrame, new_news: pd.Data
|
|
192 |
final_df = pd.concat([old_news, new_news], axis=0, ignore_index=True)
|
193 |
|
194 |
final_df = process_prediction_df(final_df, df_type="production")
|
195 |
-
|
196 |
-
|
197 |
|
198 |
# final_df.drop_duplicates(subset='url', keep='first', inplace=True)
|
199 |
# final_df.reset_index(drop=True, inplace=True)
|
@@ -206,7 +206,7 @@ def predict_news_category_similar_news(old_news: pd.DataFrame, new_news: pd.Data
|
|
206 |
logger.warning('INFO: Old & New Articles are the same. There is no requirement of updating them in the database. Database is not updated.')
|
207 |
db_updation_required = 0
|
208 |
final_df = old_news.copy()
|
209 |
-
|
210 |
|
211 |
|
212 |
if len(final_df) == 0:
|
@@ -216,7 +216,7 @@ def predict_news_category_similar_news(old_news: pd.DataFrame, new_news: pd.Data
|
|
216 |
except Exception as e:
|
217 |
logger.warning(f'Unexcpected error in predict_news_category()\n{e}')
|
218 |
final_df = None
|
219 |
-
|
220 |
db_updation_required = 0
|
221 |
-
return final_df,
|
222 |
|
|
|
165 |
# final_df.loc[(final_df['title'].str.contains('Zodiac Sign', case=False)) | (final_df['title'].str.contains('Horoscope', case=False)), 'category'] = 'SCIENCE'
|
166 |
# logger.warning('Updated category of articles having Zodiac Sign in title to SCIENCE')
|
167 |
|
168 |
+
final_df = process_prediction_df(final_df, df_type="production & prediction")
|
169 |
prediction_df = final_df.copy()
|
170 |
|
171 |
else:
|
|
|
192 |
final_df = pd.concat([old_news, new_news], axis=0, ignore_index=True)
|
193 |
|
194 |
final_df = process_prediction_df(final_df, df_type="production")
|
195 |
+
prediction_df = new_news.copy()
|
196 |
+
prediction_df = process_prediction_df(prediction_df, df_type="prediction")
|
197 |
|
198 |
# final_df.drop_duplicates(subset='url', keep='first', inplace=True)
|
199 |
# final_df.reset_index(drop=True, inplace=True)
|
|
|
206 |
logger.warning('INFO: Old & New Articles are the same. There is no requirement of updating them in the database. Database is not updated.')
|
207 |
db_updation_required = 0
|
208 |
final_df = old_news.copy()
|
209 |
+
prediction_df = final_df.copy()
|
210 |
|
211 |
|
212 |
if len(final_df) == 0:
|
|
|
216 |
except Exception as e:
|
217 |
logger.warning(f'Unexcpected error in predict_news_category()\n{e}')
|
218 |
final_df = None
|
219 |
+
prediction_df = final_df.copy()
|
220 |
db_updation_required = 0
|
221 |
+
return final_df, prediction_df, db_updation_required
|
222 |
|