islomov's picture
Gapiring v2: v1 code runs as it is (mapped, with warnings); Android library; browser runtime reads texts of any length
fb98fc7 verified
Raw History Blame Contribute Delete
850 Bytes
"""The dictionary of English words of Gapiring v1, kept as a name so that v1 code runs. Gapiring v2 reads English words,
brands and abbreviations from their ordinary spelling, so this dictionary changes nothing: load() warns once, apply()
returns the text as it is."""
from __future__ import annotations
import warnings
class Held:
def __init__(self, text: str):
self.text, self.readings = text, []
def restore(self, said: str) -> str:
return said
class Lexicon:
@classmethod
def load(cls, path=None) -> "Lexicon":
warnings.warn("the dictionary (Lexicon) does nothing in Gapiring v2: English words are read as they are written", UserWarning, stacklevel=2)
return cls()
def apply(self, text: str) -> str:
return text
def hold(self, text: str) -> Held:
return Held(text)