diff --git a/signwriting/fingerspelling/data/en-us-ase-asl.txt b/signwriting/fingerspelling/data/en-us-ase-asl.txt index d62a977..3f8d519 100644 --- a/signwriting/fingerspelling/data/en-us-ase-asl.txt +++ b/signwriting/fingerspelling/data/en-us-ase-asl.txt @@ -36,4 +36,6 @@ Z,M528x507S10020492x477S2450a497x473 8,M511x514S1bb20492x486 9,M511x515S1ce20493x485 0,M508x508S17620493x492 -@,M510x524S1f720488x487S2f104492x507S21600496x475,M512x528S1f720488x481S2e308488x501S2f900495x473,M512x523S1f720488x478S2e300487x496 \ No newline at end of file +@,M510x524S1f720488x487S2f104492x507S21600496x475,M512x528S1f720488x481S2e308488x501S2f900495x473,M512x523S1f720488x478S2e300487x496 +.,M512x522S2f900498x479S26500497x488S1eb20488x503 +/,M522x522S15a41478x478S22b05498x498 \ No newline at end of file diff --git a/signwriting/fingerspelling/fingerspelling.py b/signwriting/fingerspelling/fingerspelling.py index e27e78e..4279b51 100644 --- a/signwriting/fingerspelling/fingerspelling.py +++ b/signwriting/fingerspelling/fingerspelling.py @@ -57,5 +57,6 @@ def spell(word: str, language=None, chars=None, vertical=True) -> Union[str, Non if __name__ == "__main__": - for _word in ["12345", "hello", "Amit"]: - print(_word, spell(_word, language='en-us-ase-asl', vertical=False)) + words = ["custom", "prited", "circuit", "board"] + spellings = [spell(word, language='en-us-ase-asl', vertical=True) for word in words] + print(" ".join(spellings)) diff --git a/signwriting/fingerspelling/test_fingerspelling.py b/signwriting/fingerspelling/test_fingerspelling.py new file mode 100644 index 0000000..626cd39 --- /dev/null +++ b/signwriting/fingerspelling/test_fingerspelling.py @@ -0,0 +1,19 @@ +import unittest + +from signwriting.fingerspelling.fingerspelling import spell + + +class FingerspellingCase(unittest.TestCase): + + def test_successful_spelling(self): + sign = spell("abc", language='en-us-ase-asl', vertical=True) + self.assertEqual(sign, "M510x533S1f720487x466S14720493x486S16d20491x513") + + def test_unsuccessful_spelling_throws(self): + long_word = "abcdefghijklmnopqrstuvwxyz" + with self.assertRaises(ValueError): + spell(long_word, language='en-us-ase-asl', vertical=True) + + +if __name__ == '__main__': + unittest.main() diff --git a/signwriting/formats/sign_to_fsw.py b/signwriting/formats/sign_to_fsw.py index f797368..147a2bc 100644 --- a/signwriting/formats/sign_to_fsw.py +++ b/signwriting/formats/sign_to_fsw.py @@ -1,7 +1,12 @@ +from itertools import chain + from signwriting.types import Sign def sign_to_fsw(sign: Sign) -> str: symbols = [sign["box"]] + sign["symbols"] + all_positions = list(chain.from_iterable([s["position"] for s in symbols])) + if min(all_positions) < 250 or max(all_positions) > 750: + raise ValueError("Positions must be between 250 and 750") symbols_str = [s["symbol"] + str(s["position"][0]) + 'x' + str(s["position"][1]) for s in symbols] return "".join(symbols_str)