diff options
| author | Ada Isopods <me@bathynomus.xyz> | 2024-12-11 22:47:34 -0700 |
|---|---|---|
| committer | Ada Isopods <me@bathynomus.xyz> | 2026-10-21 23:26:26 -0600 |
| commit | d17c0d309eaad4f1269ba235ce95489e473457e6 (patch) | |
| tree | 7c4d8c09d26dc02256fa9d1c2690f4cc9540c1d7 /import-misskey.py | |
| parent | cff9bc052b4d959dac3810e9bdc74067b64b6269 (diff) | |
Fix emoji find+replace
Emojis will no longer be added where their names are part of a larger word, eg. category -> :cat:egory where :cat: is a valid emoji
If posts_log.json is invalid program will now overwrite it instead of exploding and dying and getting it all over you about it
Diffstat (limited to 'import-misskey.py')
| -rw-r--r-- | import-misskey.py | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/import-misskey.py b/import-misskey.py index 29b63bb..e5acfd3 100644 --- a/import-misskey.py +++ b/import-misskey.py @@ -43,27 +43,24 @@ for note in export_json: text = re.sub(HTML, '', text) text = re.sub(SPACE, ' ', text) text = re.sub(CONTRACTION, r'\1\2', text) - if(config__.emojis == False): - text = re.sub(EMOJI, '', text) text = text.strip() print(f" - {text}") corpus.append(text) - if(config__.emojis == True): - noteemojis = EMOJI.findall(text) - if(noteemojis): - emojis = emojis + noteemojis + noteemojis = EMOJI.findall(text) + if(noteemojis): + emojis = emojis + noteemojis -if(config__.emojis == True): - print('[+] preserving emojis:') - emojis = list(set(emojis)) - s_emo = [] - for emo in emojis: - s_emo.append(emo.replace(":", "")) - print(s_emo) - with open("emojis.json", "w") as f: - json.dump(s_emo, f) + +print('[+] preserving emojis:') +emojis = list(set(emojis)) +s_emo = [] +for emo in emojis: + s_emo.append(emo.replace(":", "")) +print(s_emo) +with open("emojis.json", "w") as f: + json.dump(s_emo, f) print('[+] building markov chain') model = chain.Text("@@note@@".join(corpus), well_formed=False) |
