Skip to content

Instantly share code, notes, and snippets.

import gzip
import json
import unicodedata
from collections import Counter
def validate_diaeresis_mark(word):
diaeresis_chars = 'ϊϋΐΰ'
vowels_with_accent = 'άέήίόύώ'
diphthongs = {'αι', 'ει', 'οι', 'υι', 'αυ', 'ευ', 'ου'}
diaeresis_found = False
Understand the Task: Grasp the main objective, goals, requirements, constraints, and expected output.
- Minimal Changes: If an existing prompt is provided, improve it only if it's simple. For complex prompts, enhance clarity and add missing elements without altering the original structure.
- Reasoning Before Conclusions: Encourage reasoning steps before any conclusions are reached. ATTENTION! If the user provides examples where the reasoning happens afterward, REVERSE the order! NEVER START EXAMPLES WITH CONCLUSIONS!
- Reasoning Order: Call out reasoning portions of the prompt and conclusion parts (specific fields by name). For each, determine the ORDER in which this is done, and whether it needs to be reversed.
- Conclusion, classifications, or results should ALWAYS appear last.
- Examples: Include high-quality examples if helpful, using placeholders [in brackets] for complex elements.
- What kinds of examples may need to be included, how many, and whether they are complex enough to benefit from p
def greek_vowels_iterator(word):
vowels = 'αάεέηήιίοόυύωώϊϋΐΰ'
diphthongs = {
'αι', 'ει', 'οι', 'υι', 'αυ', 'ευ', 'ου',
'αί', 'εί', 'οί', 'υί', 'αύ', 'εύ', 'ού',
'αη', 'αϊ', 'οη', 'όη', 'οϊ', 'άι', 'όι', 'εϊ'
}
spurious_diphthongs = 'ιυ'
spurious_diphthongs_long = {'οι', 'ει'}
def greek_vowels_iterator(word):
vowels = 'αάεέηήιίοόυύωώϊϋΐΰ'
diphthongs = {
'αι', 'ει', 'οι', 'υι', 'αυ', 'ευ', 'ου',
'αί', 'εί', 'οί', 'υί', 'αύ', 'εύ', 'ού',
'αη', 'αϊ', 'οη', 'όη', 'οϊ', 'άι', 'όι', 'εϊ'
}
spurious_diphthongs = 'ιυ'
spurious_diphthongs_long = {'οι', 'ει'}
def lower_first_if_title(word):
if word.isupper():
return word
elif word.istitle():
return word[0].lower() + word[1:]
else:
return word
def count_greek_syllables(word):
vowels = 'αάεέηήιίοόυύωώϊϋΐΰ'
def is_diacritics_correct(word):
diaeresis_chars = 'ϊϋΐΰ'
vowels_with_accent = 'άέήίόύώ'
diphthongs = ['αι', 'ει', 'οι', 'υι', 'αυ', 'ευ', 'ου']
once = False
for i, char in enumerate(word):
if char in diaeresis_chars:
if once:
return False
from spellchecker import SpellChecker
from prompt_toolkit import PromptSession
from prompt_toolkit.completion import Completer, Completion
from prompt_toolkit.document import Document
from prompt_toolkit.formatted_text import FormattedText
from prompt_toolkit.layout.processors import Processor, Transformation, TransformationInput, ConditionalProcessor
from prompt_toolkit.application.current import get_app
from prompt_toolkit.filters import Condition
from functools import lru_cache
import hashlib
import random
import os
import string
import polib
# import tempfile
# import subprocess
from termcolor import colored
from difflib import SequenceMatcher
# Letter Frequencies of the Greek language
import os
def process_file(file_path, pattern_length=100):
try:
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
if len(content) <= pattern_length:
print(f"Skipping {file_path}: File is too short.")
return
import re
def process_line(line):
if not line.startswith('+msgstr'):
return line
# Extract the content within quotes
content = re.search(r'\+msgstr "(.*)"', line)
if not content:
return line