Skip to main content

BaysanSoft Tureng CLI for EN-TR translation

Project description

Introduction

I created this repo to easily translate English and Turkish words by using very good project, Tureng.

This CLI basically scrapes https://tureng.com/en/turkish-english link to parse translation results. You can just pass the word as a parameter to translate.

Installation

You can easily start using the CLI by installing it as a package on your Python environment.

pip install .

Or you can install it by using the command below

pip install git+https://github.com/BaysanSoft/Tureng-Translation-CLI.git

Or you can just use sudo make install.

Install As a Bash Script

If you want to use it from bash, you can just move tureng-cli.sh to /usr/sbin/.

!With this kind of installation, you can use translate command for default.

>>> sudo mv tureng-cli.sh /usr/sbin/
>>> turenh-cli.sh "hurricane"

Meanings of "hurricane" in Turkish English Dictionary : 15 result(s)
#       Category        English         Turkish
1       + Common Usage  + hurricane     + kasırga
2       + General       + hurricane     + fırtına
3       + General       + hurricane     + urağan
4       + General       + hurricane     + kasırga
5       + General       + hurricane     + (güç veya hız bakımından) kasırgaya benzeyen şey
6       + Technical     + hurricane     + bora
7       + Technical     + hurricane     + kasırga
8       + Environment   + hurricane     + tropik siklon
9       + Geography     + hurricane     + kasırga
10      + Geography     + hurricane     + batı virginia eyaletinde şehir
11      + Geography     + hurricane     + utah eyaletinde şehir
12      + Meteorology   + hurricane     + bora
13      + Meteorology   + hurricane     + hortum
14      + Meteorology   + hurricane     + kasırga
15      + Military      + hurricane     + ikinci dünya savaşı'nda ingilizler tarafından kullanılan bir savaş uçağı

Commands as Bash script

tureng.sh file helps us to execute commands from Bash.

Syntax:

tureng.sh {command} "{word}" {n_result: default 15}

Example of usage:

tureng.sh synonym "hurricane" 15

>>> sudo mv tureng.sh /usr/sbin/
>>> tureng.sh synonym "hurricane" 2

Hurricane synonyms
#       Synonym         Defination
1       + cyclone       +  (Meteorol.) A system of rotating winds over a vast area, spinning inward to a low pressure center (counterclockwise in the N Hemisphere) and generally causing stormy weather: commonly called a low, since it coexists with low barometric pressure
2       + typhoon       +  A violent cyclonic storm occurring in the western Pacific Ocean.

Usage

translate

This command is using for translating words.

There are basically 2 parameters by using the CLI:

  • -w or --word for words to translate in both language Turkish or English
  • -n or --n-results to limit the result of the translation rows

The example below is for Turkish -> English.

>>> tureng-cli translate -w Kasırga -n 10

Meanings of "kasırga" in English Turkish Dictionary : 33 result(s)
#       Category        Turkish         English
1       + Common Usage  + kasırga       + hurricane
2       + Common Usage  + kasırga       + whirlwind
3       + General       + kasırga       + wind
4       + General       + kasırga       + cyclone
5       + General       + kasırga       + twist
6       + General       + kasırga       + squall
7       + General       + kasırga       + windstorm
8       + General       + kasırga       + whirlwind
9       + General       + kasırga       + twister
10      + General       + kasırga       + tourbillion

The example below is for English -> Turkish.

>>> tureng-cli translate -w Hurricane -n 10

Meanings of "hurricane" in Turkish English Dictionary : 15 result(s)
#       Category        English         Turkish
1       + Common Usage  + hurricane     + kasırga
2       + General       + hurricane     + fırtına
3       + General       + hurricane     + urağan
4       + General       + hurricane     + kasırga
5       + General       + hurricane     + (güç veya hız bakımından) kasırgaya benzeyen şey
6       + Technical     + hurricane     + bora
7       + Technical     + hurricane     + kasırga
8       + Environment   + hurricane     + tropik siklon
9       + Geography     + hurricane     + kasırga
10      + Geography     + hurricane     + batı virginia eyaletinde şehir

sentence

This command is using for showing sentence examples.

There are basically 2 parameters by using the CLI:

  • -w or --word for words to get the related sentences with it
  • -n or --n-results to limit the result of the translation rows
>>> tureng-cli sentence -w "Hurricane" -n 10

Hurricane sentence example
#       Sentence
1       + Oh, and the tropical storm will become a hurricane late Saturday night.
2       + The town was considerably damaged by the great hurricane of the 8th of August 1899.
3       + He'd managed to miss the hurricane, though the waters were still rough and the waves high.
4       + Everything needs to be ready, especially if the hurricane shifts to make landfall.
5       + In 1907 a hurricane destroyed the greater part of the laurels of the Prado and the royal palms of the Parque de Colon.
6       + He felt like he'd been hit by a hurricane.
7       + In 1090 a tremendous hurricane passed over London, and blew down six hundred houses and many churches.
8       + An open space forming the heart of the square in which the church stands separates the solitary western tower (14th century) from the choir and transept, the nave having been blown down by a violent hurricane in 1674 and never rebuilt.
9       + In July, on the approach of the dangerous hurricane season, Rodney sailed for North America, reaching New York on the 14th of September.
10      + The hurricane, too, was followed by repeated droughts, and the inhabitants of the out-islands were reduced to indigence and want, a condition which is still, in some measure, in evidence.

synonym

This command is using for showing synonyms of the word.

There are basically 2 parameters by using the CLI:

  • -w or --word for words to get related synonyms
  • -n or --n-results to limit the result of the translation rows
>>> tureng-cli synonym -w "Hurricane" -n 3

Hurricane synonyms
#       Synonym         Defination
1       + cyclone       +  (Meteorol.) A system of rotating winds over a vast area, spinning inward to a low pressure center (counterclockwise in the N Hemisphere) and generally causing stormy weather: commonly called a low, since it coexists with low barometric pressure
2       + typhoon       +  A violent cyclonic storm occurring in the western Pacific Ocean.
3       + wind          +  The wind instruments of an orchestra, or the players of these instruments

Error Handling

>>> tureng-cli translate -w "excissment" -n 10

Maybe the correct one is
excitement
exciseman
excipient
excise
excised
excipients
excising
excimer
excision
excitant

Help about parameters

You can use --help flag to get help.

>>> tureng-cli --help

Usage: cli.py [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  translate  Command to translate a Turkish word to English

Or you can get help for specific commands.

>>> tureng-cli translate --help

Usage: cli.py translate [OPTIONS]

  Command to translate a Turkish word to English

  Args:     word (str): Turkish word     n (int): The range of the list of
  translated results

Options:
  -w, --word TEXT         A word to translate from Turkish.
  -n, --n-result INTEGER  N rows to show.
  --help                  Show this message and exit.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

bs_tureng_cli-1.0.0-py3-none-any.whl (11.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page