Giter Site home page Giter Site logo

rhaberkorn / openrussian-cli Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 2.0 103.52 MB

Offline Console Russian Dictionary (based on openrussian.org)

License: GNU General Public License v3.0

Makefile 5.58% Awk 21.20% Shell 2.71% Roff 8.82% Lua 61.70%
dictionary russian bash-completion terminal-based

openrussian-cli's Introduction

An Offline Console Russian Dictionary (based on openrussian.org)

This is an offline console and terminal-friendly Russian dictionary, based on the database of openrussian.org.

  • Works offline (without internet access) and is very fast. This really pays off if you browse Russian words a lot.
  • It integrates well into the console environment - browse dictionary entries like man pages. Internally, Troff code is generated which makes further processing of generated pages very easy possible.
  • Puts very low requirements on the runtime environment: a black and white terminal display is sufficient.
  • Auto completions supported for Bash and Zsh. Most of this is handled by the script's -C argument, so it is trivial to add support for other shells. Contributions are welcome!
  • Search terms can be: base forms (infinitives, nominative singular nouns...), inflections (all cases, conjugations, short forms, imperatives...) and translations.
  • Search terms are glob patterns, which is very useful for looking up words with uncertain spelling or finding related words.

Possible future features:

  • Limit the number of results (by default to 1000) - the sheer number of results can slow down auto-completions.
  • Not all terminals can display the accent correctly (linux console), so we should have a fallback. Ideally this can be detected, or we simply whitelist terminal emulators via $TERM.
  • Better internationalization when generating German pages (-Lde).
  • Lookups via popular ASCII-cyrillic transliterations - would be useful without a Russian/cyrillic keyboard layout.
  • Be tolerant to typing mistakes.
  • Accented characters are still broken in nroff tables (see https://lists.gnu.org/archive/html/groff/2018-08/msg00000.html). We could and probably should of translate most vowel-accent combinations to single precomposed codepoints, but that might cause problems when copying text from the terminal.

Installation

Ubuntu

Build-time dependencies:

sudo apt-get install make pkg-config lua5.2 bash-completion wget unzip gawk sqlite3

Run-time dependencies:

sudo apt-get install lua5.2 lua-sql-sqlite3 man-db bash-completion

Furthermore, you will need the luautf8 library. Using LuaRocks, it may be installed as follows:

sudo luarocks-5.2 install luautf8

Building is straight forward:

make
sudo make install

If you want to redownload the latest openrussian.org database:

make clean all check

Warning: While the database content might be newer, the database schema might also at any time become incompatible with the existing script. That is why a check is performed after building everything in the above example. If it returns lots of errors, you should probably stay with the original database. Otherwise, the error messages might help in fixing/upgrading the script. You are of course welcome to contribute patches. :-)

FreeBSD

Build-time dependencies:

pkg install gmake pkgconf groff lua52 lua52-luasql-sqlite3 lua52-luarocks wget sqlite3

Installing luautf8 using LuaRocks:

luarocks52 install luautf8

Building is straight forward:

gmake LUA=lua52 LUAC=luac52
gmake install

NixOS

openrussian-cli is part of the nixos-unstable (and soon nixos-21.05) channels.

To install openrussian-cli on NixOS:

  • Via configuration.nix:
    environment.systemPackages = [ pkgs.openrussian-cli ];
  • Via nix-env:
    nix-env -iA openrussian-cli

See https://nixos.org/manual/nixos/stable/index.html#sec-package-management for more information.

Bash Aliases

While the default command name openrussian was chosen to avoid cluttering the global command namespace, you may want to define more concise shortcuts. In order to do so, add something like the following to your ~/.bashrc:

alias ru='openrussian' ру='openrussian'
_completion_loader openrussian
complete -F _openrussian_completions ru ру

This adds the alias ru (latin) and ру (cyrillic). It would however be useful to add a few default options to the ru and ру aliases. Unfortunately, above method cannot take that into account. A more robust solution might be to install the complete-alias script and adding something like the following to your ~/.bash_completion:

alias ru='openrussian -Lde -Len' ру='openrussian -Lde -Len'
complete -F _complete_alias ru ру

Zsh Aliases

Autocompletion will automatically work with aliases in the Zsh, so it is sufficient to add the following to your ~/.zshrc:

alias ru='openrussian -Lde -Len' ру='openrussian -Lde -Len'

Examples

A simple lookup:

openrussian саморазрушение

Display the German translation:

openrussian -Lde саморазрушение

Display both German and English translations, giving precedence to German:

openrussian -Lde -Len саморазрушение

If you are unsure which consonants appear in this word:

openrussian самора[сз]ру[шщ]ение

Find more words derived from "разрушение":

openrussian *разрушение

Avoid ambiguous search results:

openrussian -V коса

Look up by translation:

openrussian catch a cold

Graphical display using groffer:

openrussian -p кошка | groffer -Kutf8 --mode pdf2

You may have to specify a non-default font supporting cyrillic characters via groffer's -f option.

License

The main program is licensed under the GNU General Public License Version 3 or later (see COPYING).

This repository contains database dumps from the openrussian.org website. The openrussian-sql.zip file is licensed under the CC BY-SA license.

This repository also contains code, imported from the mysql2sqlite repository. The file mysql2qlite is licensed under the following terms and conditions:

The MIT License (MIT)

Copyright (c) 2015 esperlu, 2016 dumblob

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Further documentation

man openrussian

openrussian-cli's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

openrussian-cli's Issues

Accent characters not displayed in st (simpleterm)

See also cog1to/st-ligatures#22.

There should be a whitelist of emulators that do or a blacklist of emulators that don't support it. For the rest we should fall back to underlines. There needs to be a separate map_cmdline() since underlines have to be produced differently on the command-line (ANSI escapes) compared to Troff code (\fI).

Unfortunately, underlines/italic also are not always displayed correctly. For instance the FreeBSD console does not highlight them at all.

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.