Difference between revisions of "Language/Multiple-languages/Culture/Numeration-Tutorial"

From Polyglot Club WIKI
Jump to navigation Jump to search
 
(146 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Finally, the first version of the Numeration tool is released! This version will allow you to practise Chinese, English, Esperanto, German and Japanese numerals! More languages to come...
[[File:Numeration20220514.png|thumb]]


An overhaul is underway. It will take some time. I know that the current public version has some mistakes like plural of “percent”. I just need some spare time.
<big>(update in progress; information here may be outdated)</big>
 
Finally, the first version of the Numeration tool is released! The current version will allow you to practise Chinese, English, Esperanto, French, German, Japanese, Spanish numerals! More languages to come...  


If you are interested in providing hard-to-find information, please leave a comment.
If you are interested in providing hard-to-find information, please leave a comment.
[[File:Numeration_20201106.png|frameless|1100x1100px]]


== What is the Numeration tool? ==
== What is the Numeration tool? ==
This tool will help you practise reading, writing (hopefully also listening and speaking) numbers, written in Python and YAML.
The Numeration project is for practising conversion of numbers from symbols to writing systems, written in Python and YAML.
 
The Numeration project is for practising conversion of numbers between symbols and writing systems.  


'''Address: <big>https://codeberg.org/GrimPixel/Numeration</big>'''


'''Address:''' [https://gitlab.com/GrimPixel/Numeration '''<big>https://gitlab.com/GrimPixel/Numeration</big>''']
== What are Python and YAML, and why choose them? ==
 
 
NB: It would be ridiculous to post this tutorial on GitLab, because this tutorial's target readers are non-programmers, so it is too detailed for programmers.
 
== What are Python and YAML and why choose them? ==


=== Python ===
=== Python ===
Python is [https://insights.stackoverflow.com/survey/2020#technology-most-loved-dreaded-and-wanted-languages-loved one of the most favoured languages].
Python is [https://insights.stackoverflow.com/survey/2020#technology-most-loved-dreaded-and-wanted-languages-loved one of the most favoured languages].


Why not Rust or TypeScript, but Python? Well, because Python codes are very easy to maintain, Python also has some unique useful features including [https://realpython.com/python-f-strings/ f-string] and [https://realpython.com/python-strings/#string-indexing negative indexing]. In addition, Python has a lot of scientific libraries, so it is more relevant to my main area of study.
Why not Rust or TypeScript, but Python? Because Python codes are very easy to maintain, Python also has some unique useful features including f-string and negative indexing. In addition, Python has a lot of scientific libraries and is more relevant to my main area of study.
 
<youtube>_uQrJ0TkZlc</youtube>


=== YAML ===
=== YAML ===
YAML is [https://www.zionandzion.com/json-vs-xml-vs-toml-vs-cson-vs-yaml/ one of the most useful data serialization formats].
YAML is [https://www.zionandzion.com/json-vs-xml-vs-toml-vs-cson-vs-yaml/ one of the most useful data serialisation formats].


And why not JSON or TOML, but YAML? Because YAML has a high readability and is very easy to maintain, at least no need to type soo many quotation marks.
And why not JSON or TOML, but YAML? Because YAML has a high readability and is very easy to maintain, at least no need to type soo many quotation marks.


By the way, XML is not that horrible as described in that linked page. That is a joke with escape characters.
By the way, XML is not that horrible, as described in that linked page. That is a joke with escape characters.
 
<youtube>cdLNKUoMc6c</youtube>
 
== How to get started with Numeration? ==
1. Download [https://www.python.org/downloads/ the latest Python] (or theoretically any Python 3 version) and install it, so you can run Python programs. For Linux users, the latest version can be installed following [https://opensource.com/article/20/4/install-python-linux this article].
 
2. Download [https://pypi.org/project/ruamel.yaml/ Python's YAML parser], so that Python interpreter of the default version can understand YAML. If you are using Windows, tap WinKey, input "cmd", tap Enter, so the command line is opened. Copy the line starting with "pip" in that webpage, paste into the command line window, tap Enter. For users of other operating systems, you should already have known how to open the command line of your system, I suppose.


(Optional) 3. Download [https://www.jetbrains.com/pycharm/download/ PyCharm], an integrated development environment (IDE), and install it, so you have a graphical user interface (GUI) to edit the code or run it with the font configuration. Alternative: [https://pyzo.org/index.html Pyzo].
== <b>How to get started with Numeration?</b> ==
# Download [https://www.python.org/downloads/ the latest Python] and install it, so you can run Python programs. For Linux users, the latest version can be installed following [https://opensource.com/article/20/4/install-python-linux this article].
# Download [https://pypi.org/project/ruamel.yaml/ Python's YAML parser], so that the Python interpreter can understand YAML. If you are using Windows, tap WinKey, input "cmd", tap Enter, so the command line is opened. Copy the line starting with "pip" in that webpage, paste into the command line window, tap Enter. For users of other operating systems, you should already have known how to open the command line of your system, I suppose.
# Install required packages in `requirements.txt`:


They are all open-source.
They are all open-source.


If a newer version of Python is available, and you want to use that version, you need to install packages like ruamel.yaml for the new version again. This is how Python works: users can have different versions with different packages and settings.


If a newer version of Python is available and you want to use that version, you need to install packages like ruamel.yaml for the new versions again. This is how Python works: users can have different versions with different packages and settings.
After doing this, go to that '''Address''' above (little punishment for those who don't read from the beginning). Download the source code and extract the compressed file.
 
After doing this, go to that '''Address''' above. Download the source code and extract the compressed file.
 
 
With step 3: Open PyCharm, open the project directory, open 'numerate.py'. You can go to “File -> Settings -> Editor -> Font” to change the font and its size. Tap "Ctrl + Shift + F10" to run the code in current tab. Tap "Shift + F10" to run the code in the file specified on the upper-right corner.
 
Without step 3: Use command line to open 'numerate.py': For Windows, there is [https://www.howtogeek.com/659411/how-to-change-directories-in-command-prompt-on-windows-10/#:~:text=If%20the%20folder%20you%20want,window%2C%20and%20then%20press%20Enter.&text=The%20directory%20you%20switched%20to%20will%20be%20reflected%20in%20the%20command%20line. an article about this]; for users of other operating systems, you should have known how to do this. Type 'python numerate.py', it will run in the command line.
 
You can go to 'rule/library/setting.yaml' and change the settings following the comment.


=== If you are using Linux and the latest Python is not available in the repository ===
Use command line to open 'numerate.py': For Windows, there is [https://www.geeksforgeeks.org/cd-cmd-command/ an article about this]; for users of other operating systems, you should have known how to do this. Type 'python numerate.py', it will run in the command line.
You need to manually download and install the latest Python as described in [https://opensource.com/article/20/4/install-python-linux this article]. The version needs to be specified like “pip3.9”, so the operating system won't call the default old one and install packages for the old version. When the project is opened in PyCharm, go to "File -> Settings -> Project: Numeration -> Python Interpreter -> Python Interpreter -> Show All -> + (Add)", select "Existing Environment", make sure it is the latest version.


== Why choose Apache 2.0? ==
There are two setting files:
I want to let people use this even commercially, e.g. in language-learning games like [https://playinfluent.com/ Influent]. Thus I need a [https://en.wikipedia.org/wiki/Permissive_free_software_license permissive license]. You may ask why not public domain. There are some countries where people cannot put their work in public domain, [https://en.wikipedia.org/wiki/Comparison_of_free_and_open-source_software_licences None of the current 3 public domain licenses is not friendly to commercial use].
* 'setting.yaml': details of the program, can be changed following the comment, including language selection.
* 'rule/setting/0.yaml': details of writings in languages, can be changed following the comment.


[https://en.wikipedia.org/wiki/MIT_license MIT] is good, but there is a problem: it doesn't explain how to deal with patents and trade marks. This allows patent trolls to sue those who use the code commercially without knowing that it contains patent. When the MIT license came into being, there were no many software patent issues, so the license can be called outdated.
[[File:Numeration20220514.png]]


A guy named Lawrence E. Rosen created the [https://en.wikipedia.org/wiki/Academic_Free_License Academic Free License] to deal with this issue and this idea was incorporated into Apache 2.0, a better alternative.
You can practise numbers with Google Translate TTS: in 'setting.yaml', change “mode” to “practising”, then run the program, select language setting, you will hear the TTS if supported; tap “Enter” to see the number in Western Arabic, tap “Enter” to see the writing.


== Explain the code? ==
== Explain the code? ==
The main program is “numerate.py”. It reads your selected language codes, read the language settings (rule/library/setting.yaml), then read your subject (mathematical numeral, ordinal number, nominal number, date and time) selection number, then read the notation, convert it to Western Arabic, then call the language's “.py” file and show the result, finally ask you what to do next (do again from a step or end).
The main program is “numerate.py”. It reads your selected language codes, read the language settings (rule/library/setting.yaml), then read your subject (mathematical numeral, ordinal number, nominal number) selection number, then read the notation, convert it to Western Arabic, then call the language's “.py” file and show the result, finally ask you what to do next (do again from a step or end). This is going to be changed: everything before inputting the numeral will be settled in 'setting.yaml' first.


In the language “.py” files, everything is in a function “do”, so it can be called from another file (numerate.py) easily. They read the notation and the language setting as part of the input of the function “do”, then read the corresponding lexicon YAML file. Then the notation will be processed according to different notation types.
In the language “.py” files, everything is in a function “do”, so it can be called from another file (numerate.py) easily. They read the notation and the language setting as part of the input of the function “do”, then read the corresponding lexicon YAML file. Then the notation will be processed according to different notation types.


=== Magnitude and Archmagnitude ===


There are something to be noticed like the magnitude and archmagnitude.
There are something to be noticed like the magnitude and archmagnitude.
Line 107: Line 88:
|1
|1
|1
|1
|0
|0
|0
|}
* digit grouping: 3 (European double digit group)
{| class="wikitable"
!
!9
!8
!7
!6
!5
!4
!3
!2
!1
|-
!magnitude
|2
|1
|0
|5
|4
|3
|2
|1
|0
|-
!archmagnitude
|1
|1
|1
|0
|0
|0
|0
|0
|0
|0
Line 184: Line 201:
|}
|}


== What means that mosaic? ==
=== Construction of a natural number ===
It's the ideograph 𠬞, meaning “two hands”. [https://humanum.arts.cuhk.edu.hk/Lexis/lexi-mf/bronzePiece.php?piece=%F0%A0%AC%9E Details at CUHK].
There are two ways:
* write the digit and magnitude for each place; write the archmagnitude
* write each place or a combination of two places separately; write the archmagnitude
 
The first one is for Esperanto, Chinese, Japanese in mixed script of Kanji and Kana, etc.
 
The second one is for English, French, German, Japanese in Kana, etc.
 
== If I want to add a language, what should I know? ==
There are several places you need to visit to make sure it works:
* 'numerate.py'
* 'setting.yaml'
* 'rule/setting/0.yaml'
* 'rule/library/language_decode.yaml'
* 'rule/library/language_encode.yaml'
* 'about/language.yaml'
 
Just pick a language that is similar to the language you want to add, copy and paste, do some modifications. This will suffice.


== What's the future plan? ==
== What's the future plan? ==
I need to  
I need to  
* add support to other languages mentioned in 'about/language.yaml'
* simplify the recognition of notation type (from manual to automatic)
* add notations mentioned in 'about/notation.yaml'
* add support for more numeral systems
* start supporting other languages covering as many language families as possible, [https://www.mosalingua.com/en/most-studied-languages-in-the-world/ languages being mostly learned] are given the priority
* add support for more languages, in which languages being [https://www.mosalingua.com/en/most-studied-languages-in-the-world/ mostly learned] and [https://en.wikipedia.org/wiki/List_of_languages_by_total_number_of_speakers mostly used] are given the priority, then [https://en.wikipedia.org/wiki/List_of_official_languages_by_country_and_territory official languages].
* add a guidance on adding a new language
 
* add the TTS support and maybe the SR support
The old feature of “date and time” is moved to an upcoming new project “DateTime converter”.
* create a GUI with [https://beeware.org/ BeeWare], but not for iOS because of its totalitarian regulations. If there were iOS versions later, they wouldn't be my work.
 
I had a debate with myself: should the large archmagnitude by Conway-Guy and long scale in Chinese be supported? I thought that there are written rules for them, they exist, so they should be supported. Then I thought that as nearly no one is using them, they are practically not existing. I chose the latter. Maybe I would add support for them later, when I couldn't support more languages due to lack of references.
 
Planned next languages to be supported: Russian, Italian, Standard Arabic.
 
*'''Reviews''': https://polyglotclub.com/language/multiple-languages/tool/14


I need to accumulate experience through this project, then I can create other ones.
==AUTHOR==
[https://polyglotclub.com/member/GrimPixel GrimPixel]


Planned next 3 langauges to be supported: Lojban, French, Spanish.
==Other Lessons==
* [[Language/Multiple-languages/Culture/Most-Popular-Sports|Most Popular Sports]]
* [[Language/Multiple-languages/Culture/Similar-Sayings|Similar Sayings]]
* [[Language/Multiple-languages/Culture/Productivity-tools-for-polyglots|Productivity tools for polyglots]]
* [[Language/Multiple-languages/Culture/Philosophical-and-Religious-Texts|Philosophical and Religious Texts]]
* [[Language/Multiple-languages/Culture/Astrology-in-different-Cultures-and-Languages|Astrology in different Cultures and Languages]]
* [[Language/Multiple-languages/Culture/IRFP-in-brief|IRFP in brief]]
* [[Language/Multiple-languages/Culture/How-to-locate-the-origin-of-a-video-or-a-photo|How to locate the origin of a video or a photo]]
* [[Language/Multiple-languages/Culture/What-are-the-differences-between-Ukrainian-and-Russian|What are the differences between Ukrainian and Russian]]
* [[Language/Multiple-languages/Culture/Language-comparisons|Language comparisons]]
<span links></span>

Latest revision as of 21:43, 1 August 2024

Numeration20220514.png

(update in progress; information here may be outdated)

Finally, the first version of the Numeration tool is released! The current version will allow you to practise Chinese, English, Esperanto, French, German, Japanese, Spanish numerals! More languages to come...

If you are interested in providing hard-to-find information, please leave a comment.

What is the Numeration tool?[edit | edit source]

The Numeration project is for practising conversion of numbers from symbols to writing systems, written in Python and YAML.

Address: https://codeberg.org/GrimPixel/Numeration

What are Python and YAML, and why choose them?[edit | edit source]

Python[edit | edit source]

Python is one of the most favoured languages.

Why not Rust or TypeScript, but Python? Because Python codes are very easy to maintain, Python also has some unique useful features including f-string and negative indexing. In addition, Python has a lot of scientific libraries and is more relevant to my main area of study.

YAML[edit | edit source]

YAML is one of the most useful data serialisation formats.

And why not JSON or TOML, but YAML? Because YAML has a high readability and is very easy to maintain, at least no need to type soo many quotation marks.

By the way, XML is not that horrible, as described in that linked page. That is a joke with escape characters.

How to get started with Numeration?[edit | edit source]

  1. Download the latest Python and install it, so you can run Python programs. For Linux users, the latest version can be installed following this article.
  2. Download Python's YAML parser, so that the Python interpreter can understand YAML. If you are using Windows, tap WinKey, input "cmd", tap Enter, so the command line is opened. Copy the line starting with "pip" in that webpage, paste into the command line window, tap Enter. For users of other operating systems, you should already have known how to open the command line of your system, I suppose.
  3. Install required packages in `requirements.txt`:

They are all open-source.

If a newer version of Python is available, and you want to use that version, you need to install packages like ruamel.yaml for the new version again. This is how Python works: users can have different versions with different packages and settings.

After doing this, go to that Address above (little punishment for those who don't read from the beginning). Download the source code and extract the compressed file.

Use command line to open 'numerate.py': For Windows, there is an article about this; for users of other operating systems, you should have known how to do this. Type 'python numerate.py', it will run in the command line.

There are two setting files:

  • 'setting.yaml': details of the program, can be changed following the comment, including language selection.
  • 'rule/setting/0.yaml': details of writings in languages, can be changed following the comment.

Numeration20220514.png

You can practise numbers with Google Translate TTS: in 'setting.yaml', change “mode” to “practising”, then run the program, select language setting, you will hear the TTS if supported; tap “Enter” to see the number in Western Arabic, tap “Enter” to see the writing.

Explain the code?[edit | edit source]

The main program is “numerate.py”. It reads your selected language codes, read the language settings (rule/library/setting.yaml), then read your subject (mathematical numeral, ordinal number, nominal number) selection number, then read the notation, convert it to Western Arabic, then call the language's “.py” file and show the result, finally ask you what to do next (do again from a step or end). This is going to be changed: everything before inputting the numeral will be settled in 'setting.yaml' first.

In the language “.py” files, everything is in a function “do”, so it can be called from another file (numerate.py) easily. They read the notation and the language setting as part of the input of the function “do”, then read the corresponding lexicon YAML file. Then the notation will be processed according to different notation types.

Magnitude and Archmagnitude[edit | edit source]

There are something to be noticed like the magnitude and archmagnitude.

Take the cardinal number 987654321 as an example:

  • digit grouping: 3 (European)
9 8 7 6 5 4 3 2 1
magnitude 2 1 0 2 1 0 2 1 0
archmagnitude 2 2 2 1 1 1 0 0 0
  • digit grouping: 3 (European double digit group)
9 8 7 6 5 4 3 2 1
magnitude 2 1 0 5 4 3 2 1 0
archmagnitude 1 1 1 0 0 0 0 0 0
  • digit grouping: 4 (East Asian)
9 8 7 6 5 4 3 2 1
magnitude 0 3 2 1 0 3 2 1 0
archmagnitude 2 1 1 1 1 0 0 0 0
  • digit grouping: [3, 2] (South Asian)
9 8 7 6 5 4 3 2 1
magnitude 1 0 1 0 1 0 2 1 0
archmagnitude 3 3 2 2 1 1 0 0 0

Construction of a natural number[edit | edit source]

There are two ways:

  • write the digit and magnitude for each place; write the archmagnitude
  • write each place or a combination of two places separately; write the archmagnitude

The first one is for Esperanto, Chinese, Japanese in mixed script of Kanji and Kana, etc.

The second one is for English, French, German, Japanese in Kana, etc.

If I want to add a language, what should I know?[edit | edit source]

There are several places you need to visit to make sure it works:

  • 'numerate.py'
  • 'setting.yaml'
  • 'rule/setting/0.yaml'
  • 'rule/library/language_decode.yaml'
  • 'rule/library/language_encode.yaml'
  • 'about/language.yaml'

Just pick a language that is similar to the language you want to add, copy and paste, do some modifications. This will suffice.

What's the future plan?[edit | edit source]

I need to

  • simplify the recognition of notation type (from manual to automatic)
  • add support for more numeral systems
  • add support for more languages, in which languages being mostly learned and mostly used are given the priority, then official languages.

The old feature of “date and time” is moved to an upcoming new project “DateTime converter”.

I had a debate with myself: should the large archmagnitude by Conway-Guy and long scale in Chinese be supported? I thought that there are written rules for them, they exist, so they should be supported. Then I thought that as nearly no one is using them, they are practically not existing. I chose the latter. Maybe I would add support for them later, when I couldn't support more languages due to lack of references.

Planned next languages to be supported: Russian, Italian, Standard Arabic.

AUTHOR[edit | edit source]

GrimPixel

Other Lessons[edit | edit source]