cointeleporting commited on
Commit
5ac4fa3
·
1 Parent(s): 5268ae5

tackle directory bug

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import json
 
2
  import gradio as gr
3
  from textblob import TextBlob
4
  from snownlp import SnowNLP
@@ -67,7 +68,9 @@ def batch_sentiment_analysis(file_path: str) -> str:
67
  analysis_result = json.loads( sentiment_analysis(key) )
68
  data[key] = analysis_result
69
 
70
- output_path = f'processed_{file_path}'
 
 
71
  with open(output_path, 'w', encoding = 'utf-8') as f:
72
  json.dump(data, f, ensure_ascii = False, indent = 2)
73
 
@@ -91,7 +94,9 @@ def batch_chinese_sentiment_analysis(file_path: str) -> str:
91
  analysis_result = json.loads( chinese_sentiment_analysis(key) )
92
  data[key] = analysis_result
93
 
94
- output_path = f'processed_{file_path}'
 
 
95
  with open(output_path, 'w', encoding = 'utf-8') as f:
96
  json.dump(data, f, ensure_ascii = False, indent = 2)
97
 
 
1
  import json
2
+ import os
3
  import gradio as gr
4
  from textblob import TextBlob
5
  from snownlp import SnowNLP
 
68
  analysis_result = json.loads( sentiment_analysis(key) )
69
  data[key] = analysis_result
70
 
71
+ dir_name = os.path.dirname(file_path)
72
+ base_name = os.path.basename(file_path)
73
+ output_path = os.path.join(dir_name, f'processed_{base_name}')
74
  with open(output_path, 'w', encoding = 'utf-8') as f:
75
  json.dump(data, f, ensure_ascii = False, indent = 2)
76
 
 
94
  analysis_result = json.loads( chinese_sentiment_analysis(key) )
95
  data[key] = analysis_result
96
 
97
+ dir_name = os.path.dirname(file_path)
98
+ base_name = os.path.basename(file_path)
99
+ output_path = os.path.join(dir_name, f'processed_{base_name}')
100
  with open(output_path, 'w', encoding = 'utf-8') as f:
101
  json.dump(data, f, ensure_ascii = False, indent = 2)
102