bs-tureng-cli 1.0.0
BaysanSoft Tureng CLI for EN-TR translation
License: MIT
Requires Python: >=3.8
Keywords: mebaysan translation Turkish English Tureng CLI

- [Introduction](#introduction)
- [Installation](#installation)
  - [Install As a Bash Script](#install-as-a-bash-script)
    - [Commands as Bash script](#commands-as-bash-script)
- [Usage](#usage)
  - [translate](#translate)
  - [sentence](#sentence)
  - [synonym](#synonym)
  - [Error Handling](#error-handling)
  - [Help about parameters](#help-about-parameters)

# Introduction

I created this repo to easily translate English and Turkish words by using very good project, [Tureng](https://tureng.com/en/turkish-english).

This CLI basically scrapes [https://tureng.com/en/turkish-english](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.

```bash
pip install .
```

Or you can install it by using the command below

```bash
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](tureng-cli.sh) to `/usr/sbin/`.

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

```bash
>>> 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](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`

```bash
>>> 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.

```bash
>>> 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.

```bash
>>> 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

```bash
>>> 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

```bash
>>> 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

```bash
>>> 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.

```bash
>>> 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.

```bash
>>> 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.
```