MK-316 commited on
Commit
5de2897
1 Parent(s): f2ea73e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -26,20 +26,19 @@ def process_text(text, sorting_option):
26
  top_5_words = sorted_words
27
 
28
  # Format the top 5 words and frequencies as an HTML table
29
- table_html = "<table style='width:100%'><tr><th>Word</th><th>Frequency</th></tr>"
30
- for word, freq in top_5_words:
31
- table_html += f"<tr><td>{word}</td><td>{freq}</td></tr>"
32
  table_html += "</table>"
33
 
34
  # Create a CSV file
35
- csv_data = []
36
- for word, freq in top_5_words:
37
- csv_data.append([word, freq])
38
 
39
  # Write CSV data to a string buffer
40
  csv_buffer = io.StringIO()
41
  csv_writer = csv.writer(csv_buffer)
42
- csv_writer.writerow(["Word", "Frequency"])
43
  csv_writer.writerows(csv_data)
44
  csv_buffer.seek(0)
45
 
 
26
  top_5_words = sorted_words
27
 
28
  # Format the top 5 words and frequencies as an HTML table
29
+ table_html = "<table style='width:100%'><tr><th>Index</th><th>Word</th><th>Frequency</th></tr>"
30
+ for index, (word, freq) in enumerate(top_5_words, start=1):
31
+ table_html += f"<tr><td>{index}</td><td>{word}</td><td>{freq}</td></tr>"
32
  table_html += "</table>"
33
 
34
  # Create a CSV file
35
+ csv_data = [["Index", "Word", "Frequency"]]
36
+ for index, (word, freq) in enumerate(top_5_words, start=1):
37
+ csv_data.append([index, word, freq])
38
 
39
  # Write CSV data to a string buffer
40
  csv_buffer = io.StringIO()
41
  csv_writer = csv.writer(csv_buffer)
 
42
  csv_writer.writerows(csv_data)
43
  csv_buffer.seek(0)
44