summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Yin <fkfd@fkfd.me>2022-04-18 14:33:25 +0800
committerFrederick Yin <fkfd@fkfd.me>2022-04-18 14:33:25 +0800
commit904b8d766a51b01d667e5faf75b8c7a084fb74ed (patch)
tree86b257cdfd34a2c89f1b8730fa7064e72bd90a82
parente9eb48d7e57d30c7d84d99fa1383714f8575b092 (diff)
mkhtml scripts
-rw-r--r--data/mkhtml_all.py21
-rw-r--r--data/mkhtml_freq.py21
2 files changed, 42 insertions, 0 deletions
diff --git a/data/mkhtml_all.py b/data/mkhtml_all.py
new file mode 100644
index 0000000..6d9d662
--- /dev/null
+++ b/data/mkhtml_all.py
@@ -0,0 +1,21 @@
+import json
+
+f = open("words.json")
+words = json.load(f)
+f.close()
+
+html = ""
+track = ""
+
+for word in words:
+ html += "<tr>"
+ if word["track"] != track:
+ track = word["track"]
+ words_from_track = len([w for w in words if w["track"] == track])
+ html += f"<td rowspan={words_from_track}>{track}</td>"
+
+ html += f"<td>{word['word']}</td><td>{'<br/>'.join(word['lines'])}</td></tr>\n"
+
+htmlf = open("all_words.html", "w")
+htmlf.write(html)
+htmlf.close()
diff --git a/data/mkhtml_freq.py b/data/mkhtml_freq.py
new file mode 100644
index 0000000..8e7a7d9
--- /dev/null
+++ b/data/mkhtml_freq.py
@@ -0,0 +1,21 @@
+import json
+
+f = open("words.json")
+words = json.load(f)
+f.close()
+
+freqf = open("most_frequent")
+freq_words = freqf.read().splitlines()
+freqf.close()
+
+html = ""
+
+for idx, fw in enumerate(freq_words):
+ for word in words:
+ if word["word"] == fw:
+ html += f"<tr><td>{fw}</td><td>{word['track']}</td></tr>\n"
+
+
+htmlf = open("frequent_words.html", "w")
+htmlf.write(html)
+htmlf.close()