-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(fingerspelling): do not support invalid signs (too long)
- Loading branch information
Showing
4 changed files
with
30 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |