Code Monkey home page Code Monkey logo

grascii's Introduction

Grascii

About the Project

Grascii is a language used to represent Gregg Shorthand forms using the ASCII character set (characters found on a standard keyboard). The Grascii Project, also referred to as Grascii, encompasses the set of tools and resources accompanying the language that facilitate the reading, writing, and study of Gregg Shorthand at all levels.

Made With

  • Python 3

Getting Started

Prerequisites

  • Python 3.7+

Installation

Install the package:

$ python -m pip install grascii[interactive]

Note: We recommend the interactive extra for the majority of users. You may omit the interactive extra when using the package as a library to reduce dependencies. Also see grascii-gui for a graphical interface for Grascii Search.

Verify the installation:

$ grascii --help

If the command fails, your PATH may not contain the location of Python scripts.

You can also try:

$ python -m grascii --help

Grascii Language

The Grascii Language aims to be straightforward for those who are familiar with Gregg Shorthand. That is, Grascii represents most strokes with the letters that match their sounds. For example, the word Cross is written as KROS.

For a more detailed overview of the language, see language.

Grascii Search is the headline tool of the Grascii Project. It provides many useful options for searching Grascii Dictionaries (reverse Gregg Shorthand dictionaries).

Motivation

The existence of shorthand dictionaries have aided the conversion of longhand to shorthand. However, the reverse has remained a challenge since the inception of Gregg Shorthand. Grascii Search solves this problem by allowing users to identify the longhand corresponding to a shorthand form by performing a search based on its Grascii representation.

Basic Usage

Ex.:

$ grascii search -g AB
AB About
A|B Agreeable
Results: 2

Uncertainty

Occassionally, a stroke is mistaken for one of similar form. Thus, Grascii Search provides levels of uncertainty.

Ex.:

$ grascii search -g FND -u1
FND Found
FND Fund
FTH Forth
FTH Further
SND Sound
Results: 5

The ND stroke could also be an under TH or an MT/MD. The search accounts for these possibilities with Forth and Further. F is also close to S or V, resulting in Sound.

Interactive Mode

For repeated usage, we recommend running Grascii Search in interactive mode. For more complex queries, interactive mode removes the need of using escape sequences on the command line.

$ grascii search -i

Note: Requires the interactive extra

More Options

For more options, see search.

Grascii Dictionary

Grascii comes with a dictionary based on the 1916 Gregg Shorthand Dictionary.

More dictionaries for other versions of Gregg and dictionaries including phrases are available for installation at the Grascii Dictionaries repository.

You can also write, build, and install your own custom dictionaries.

For more information, see dictionary.

Grascii Dephrase (Experimental)

Grascii includes an experimental phrase parsing module.

It attempts to give the phrase for the most common phrase constructions in Gregg Shorthand and provide suggestions for never before seen phrases:

$ python -m grascii.dephrase AVNBA
I HAVE NOT BEEN ABLE

Documentation

Documentation is available on Read the Docs.

Contributing

Contributions of any kind are welcome and appreciated. You can contribute by:

  • Reporting bugs or unexpected behavior
  • Fixing bugs and solving issues
  • Helping implement new features
  • Editing documentation for correctness, completeness, and clarity
  • Sharing thoughts and suggestions to improve the Grascii Language

Dictionary

If you find an error in any of the dictionaries, please open an issue or pull request at the dictionaries repository.

Contributions to the dictionaries repository are also welcome to correct errors and create more dictionaries.

License

This project is under the MIT License.

Acknowledgements

Many thanks to the developers of Lark, Questionary, appdirs and Qwertigraphy.

Maintainer's Note

Grascii is not completely stable, but I hope others find the project useful. I try to open draft pull requests with task lists to keep the community informed of upcoming features and the direction of the project. If you notice that there has not been any activity for a couple of weeks, feel free to leave a comment requesting a status update.

-- chanicpanic

grascii's People

Contributors

chanicpanic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

grascii's Issues

Interactive mode crashes when Ctrl-C is pressed during interpretation selection

Steps to reproduce:

  1. Start interactive mode: $ grascii search -i
  2. Press ENTER to start a new search.
  3. Type tnt and press ENTER.
  4. Press Ctrl+C.

Result:

? What would you like to do? New Search
? Enter Search: tnt
? Choose an interpretation to use in the search: (Use arrow keys)                                                                                                                                                  

Cancelled by user

Traceback (most recent call last):
  File "bin/grascii", line 8, in <module>
    sys.exit(main())
  File "lib/python3.9/site-packages/grascii/__main__.py", line 37, in main
    args.func(args)
  File "lib/python3.9/site-packages/grascii/search.py", line 105, in cli_search
    results = search(**{k: v for k, v in vars(args).items() if v is not None})
  File "lib/python3.9/site-packages/grascii/search.py", line 97, in search
    return searcher.search(**kwargs)
  File "lib/python3.9/site-packages/grascii/interactive.py", line 57, in search
    self.run_interactive()
  File "lib/python3.9/site-packages/grascii/interactive.py", line 89, in run_interactive
    previous_search = self.interactive_search()
  File "lib/python3.9/site-packages/grascii/interactive.py", line 179, in interactive_search
    interps = interpretations[index - 1: index]
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'

Expected behavior:

The interrupt is gracefully handled and returns the user to the main menu or the new search input.

Words ending in -ing do not appear in search results

To Reproduce:

Run grascii search -g "th'".

Output:

TH The
TH) Their
TH) There
Results: 3

The results do not include the word "Thing". However, "Thing" is in the dictionary.

grascii search -r thing

Output:

.*\sThing
TH' Thing
Results: 1

"Thing" should appear in the results of the first search.

FileNotFoundError when building dictionary with spell check

When running grascii dictionary build with the --spell option, a FileNotFoundError occurs because words.txt does not exist.

Output:

Traceback (most recent call last):
  File "bin/grascii", line 8, in <module>
    sys.exit(main())
  File "lib/python3.9/site-packages/grascii/__main__.py", line 37, in main
    args.func(args)
  File "lib/python3.9/site-packages/grascii/dictionary/build.py", line 334, in cli_build
    build(**{k: v for k, v in vars(args).items() if v is not None})
  File "lib/python3.9/site-packages/grascii/dictionary/build.py", line 326, in build
    builder.build()
  File "lib/python3.9/site-packages/grascii/dictionary/build.py", line 282, in build
    self.load_word_set()
  File "lib/python3.9/site-packages/grascii/dictionary/build.py", line 170, in load_word_set
    with get_words_file("words.txt") as words:
  File "lib/python3.9/site-packages/grascii/utils.py", line 22, in get_words_file
    return io.TextIOWrapper(resource_stream("grascii.words", name),
  File "lib/python3.9/site-packages/pkg_resources/__init__.py", line 1136, in resource_stream
    return get_provider(package_or_requirement).get_resource_stream(
  File "lib/python3.9/site-packages/pkg_resources/__init__.py", line 1608, in get_resource_stream
    return open(self._fn(self.module_path, resource_name), 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'lib/python3.9/site-packages/grascii/words/words.txt'

Dynamic Earley doesn't support weights on terminals

I've cloned the repo, run git submodule init and git submodule update, followed by pip install ., but after that when I run the example grascii search -g AB I get the following error about how "Dynamic Earley doesn't support weights on terminals":

Traceback (most recent call last):
  File "/opt/homebrew/bin/grascii", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.10/site-packages/grascii/__main__.py", line 54, in main
    args.func(args)
  File "/opt/homebrew/lib/python3.10/site-packages/grascii/search.py", line 151, in cli_search
    results = search(**{k: v for k, v in vars(args).items() if v is not None})
  File "/opt/homebrew/lib/python3.10/site-packages/grascii/search.py", line 129, in search
    searcher = GrasciiSearcher(**kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/grascii/searchers.py", line 131, in __init__
    self._parser = GrasciiParser()
  File "/opt/homebrew/lib/python3.10/site-packages/grascii/parser.py", line 132, in __init__
    self._parser: Lark = Lark.open(grammar, parser="earley", ambiguity="explicit")
  File "/opt/homebrew/lib/python3.10/site-packages/lark/lark.py", line 504, in open
    return cls(f, **options)
  File "/opt/homebrew/lib/python3.10/site-packages/lark/lark.py", line 380, in __init__
    self.parser = self._build_parser()
  File "/opt/homebrew/lib/python3.10/site-packages/lark/lark.py", line 422, in _build_parser
    return parser_class(self.lexer_conf, parser_conf, options=self.options)
  File "/opt/homebrew/lib/python3.10/site-packages/lark/parser_frontends.py", line 40, in __call__
    return ParsingFrontend(lexer_conf, parser_conf, options)
  File "/opt/homebrew/lib/python3.10/site-packages/lark/parser_frontends.py", line 68, in __init__
    self.parser = create_parser(lexer_conf, parser_conf, options)
  File "/opt/homebrew/lib/python3.10/site-packages/lark/parser_frontends.py", line 215, in create_earley_parser
    return f(lexer_conf, parser_conf, options, resolve_ambiguity=resolve_ambiguity, debug=debug, tree_class=tree_class, **extra)
  File "/opt/homebrew/lib/python3.10/site-packages/lark/parser_frontends.py", line 192, in create_earley_parser__dynamic
    earley_matcher = EarleyRegexpMatcher(lexer_conf)
  File "/opt/homebrew/lib/python3.10/site-packages/lark/parser_frontends.py", line 173, in __init__
    raise GrammarError("Dynamic Earley doesn't support weights on terminals", t, t.priority)
lark.exceptions.GrammarError: ("Dynamic Earley doesn't support weights on terminals", TerminalDef('N', 'N'), 2)

Contain search for only one character produces some incorrect results

Example:

$ grascii search -s contain -u 0 -g x

Output:

AMNES^REX Administratrix
AMEXTR Admixture
AFEX Affix
AFLUX Afflux
AMBDEX^R Ambidexterity
AMBDEX Ambidextrous
ANGSAX Anglo-saxon
ANEX Annex
ANEXSH Annexation
...
VEXN Vixen
VEXNSH Vixenish
VOTEX Vortex
ZANTHA&'N Xanthian
ZANTHEK Xanthic
ZANTHEN Xanthine
ZANTHPE Xanthippe
ZANTHUS Xanthous
ZEBK Xebec
ZILEN Xylene
ZIL^A Xyletic
ZILEK Xylic
ZIL^O Xylograph
ZIL^OK Xylographic
ZIL^OE Xylography
ZIRES Xyris

Xanthian-Xyris are printed as results, but their Grascii forms do not contain X. They should not be included.

AssertionError in metrics.py when searching

The following search causes an AssertionError.

$ grascii search -g n-dv

Output:

(Token('DV', 'DV'), set())
Traceback (most recent call last):
  File "bin/grascii", line 8, in <module>
    sys.exit(main())
  File "lib/python3.9/site-packages/grascii/__main__.py", line 37, in main
    args.func(args)
  File "lib/python3.9/site-packages/grascii/search.py", line 105, in cli_search
    results = search(**{k: v for k, v in vars(args).items() if v is not None})
  File "lib/python3.9/site-packages/grascii/search.py", line 97, in search
    return searcher.search(**kwargs)
  File "lib/python3.9/site-packages/grascii/searchers.py", line 154, in search
    return list(results)
  File "lib/python3.9/site-packages/grascii/searchers.py", line 54, in perform_search
    diff = min(diff, metric(interp, match))
  File "lib/python3.9/site-packages/grascii/metrics.py", line 204, in standard
    return match_distance(g1, g2)
  File "lib/python3.9/site-packages/grascii/metrics.py", line 180, in match_distance
    v1[0] = v0[0] + compute_ins_del_cost(g1[i])
  File "lib/python3.9/site-packages/grascii/metrics.py", line 118, in compute_ins_del_cost
    assert cost > 0
AssertionError

Grascii words ending in a disjoiner do not appear in search results

To Reproduce:

Run grascii search -g "u^".

Output:

U You
U Your
'U Who
Results: 3

The results do not include the word "Under". However, "Under" is in the dictionary.

grascii search -r under

Output:

.*\sUnder
U^ Under
U^BD Underbid
U^BRED Underbred
U^BRSH Underbrush
...

"Under" should appear in the results of the first search.

Make the minimum Python version 3.7

Python 3.6 reached its end of life in December 2021.
Increasing the minimum Python version to 3.7 would make features such as the annotations future and dataclasses available.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.