signwriting 1.4.0 copy "signwriting: ^1.4.0" to clipboard
signwriting: ^1.4.0 copied to clipboard

Dart utilities for SignWriting - formats, tokenizer, mirror, fingerspelling, mouthing, joins and metrics.

SignWriting #

pub package

This is dart implementation of its python counterpart. Dart utilities for SignWriting formats, tokenizer, visualizer and utils.

Features #

  • ✔️ Formats
  • ✔️ Tokenizer
  • ❌ Visualizer (implemented here)
  • ✔️ Utils (join, metrics, mirror, canonicalize)
  • ✔️ Fingerspelling
  • ✔️ Mouthing (IPA → SignWriting)

Usage #

Formats #

This module provides utilities for converting between different formats of SignWriting. We include a few examples:

  1. To parse an FSW string into a Sign object, representing the sign as a dictionary:
print(fswToSign("M123x456S1f720487x492"));
// Sign { box: SignSymbol { symbol: 'M', position: [123, 456] }, symbols: [SignSymbol { symbol: 'S1f720', position: [487, 492] }] }
  1. To convert a SignWriting string between SWU and FSW formats (both directions):
print(swu2fsw('𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭'));
// M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475

print(fsw2swu('M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475'));
// 𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭

Tokenizer #

This module provides utilities for tokenizing SignWriting strings for use in NLP tasks1. We include a few usage non-exhaustive examples:

  1. To tokenize a SignWriting string into a list of tokens:
SignWritingTokenizer tokenizer = SignWritingTokenizer();
String fsw = 'M123x456S1f720487x492S1f720487x492';
List<String> tokens = tokenizer.textToTokens(fsw, boxPosition: true);
print(tokens);
// [M, p123, p456, S1f7, c2, r0, p487, p492, S1f7, c2, r0, p487, p492]
  1. To convert a list of tokens back to a SignWriting string:
print(tokenizer.tokensToText(tokens));
// M123x456S1f720487x492S1f720487x492
  1. For machine learning purposes, we can convert the tokens to a list of integers:
print(tokenizer.tokenize(fsw, bos: false, eos: false));
// [6, 932, 932, 255, 678, 660, 919, 924, 255, 678, 660, 919, 924]
  1. Or to remove 'A' information, and separate signs by spaces, we can use:
print(normalizeSignWriting(fsw));
// M123x456S1f720487x492S1f720487x492

Visualizer #

(implemented here)

This module is used to visualize SignWriting strings as images. Unlike sutton-signwriting/font-db which it is based on, this module does not support custom styling. Benchmarks show that this module is ~5000x faster than the original implementation.

String fsw = "AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S20544510x500S10019476x475";
signwritingToImage(fsw);

Utils #

This module includes general utilities that were not covered in the other modules.

  1. joinSignsVertical / joinSignsHorizontal join a list of signs into a single sign. This is useful for example for fingerspelling words out of individual character signs.
String charA = 'M507x507S1f720487x492';
String charB = 'M507x507S14720493x485';

print(joinSignsVertical([charA, charB]));
// M510x518S1f720487x481S14720493x496

print(joinSignsHorizontal([charA, charB]));
// M517x511S1f720483x492S14720503x485
  1. signFromSymbols builds a tightly-boxed sign (centered on 500x500) from a list of symbols.

  2. getSymbolSize returns the rendered size of a symbol, and signwritingBox recomputes a sign's tight bounding box — both without needing a font renderer.

print(getSymbolSize('S2e748'));
// [16, 26]

Mirror #

mirrorSymbol and mirrorSign produce the horizontal mirror of a symbol or a full FSW sign.

print(mirrorSymbol('S10000'));
// S10008

print(mirrorSign('M507x507S1f720487x492'));
// M513x507S1f728493x492

Canonicalize #

canonicalize rewrites each sign with its symbols in a canonical order, centered on 500x500, with a tight box.

print(canonicalize('M518x529S14c20480x471S27106503x489'));
// M519x529S14c20481x471S27106504x489

Note: the relative draw order of overlapping symbols is not preserved (that needs a font renderer); for non-overlapping signs the output matches the Python package exactly.

Fingerspelling #

Spell words letter-by-letter as SignWriting, for 23 signed languages. spell handles a single word; spellText handles full text (returns null if any character is unmappable).

print(spell('abc', language: 'ase'));
// M510x533S1f720487x466S14720493x486S16d20491x513

print(spellText('a b', language: 'ase'));
// M510x507S1f720487x492 M507x511S14720493x489

Mouthing #

Convert IPA (mouth shapes / Mundbildschrift) to SignWriting.

print(mouthIpa('ɑː ɛ'));
// M541x518S34c00459x482S34a00505x482

To mouth a written word, supply your own grapheme-to-IPA function (Python's epitran has no Dart port)

final result = mouth('hello', g2p: (word) => myG2p(word));
print(result.fsw);
2
likes
160
points
180
downloads

Documentation

API reference

Publisher

verified publisherbipin.app

Weekly Downloads

Dart utilities for SignWriting - formats, tokenizer, mirror, fingerspelling, mouthing, joins and metrics.

Repository (GitHub)
View/report issues

Topics

#sign #signwriting

License

BSD-3-Clause (license)

Dependencies

tuple

More

Packages that depend on signwriting