This Rust project provides both a library and a CLI binary for working with multiple numeral systems. The library includes a set of modules for converting Arabic numerals to various numeral systems and vice versa. Each module contains two functions, one for converting Arabic numerals to the corresponding numeral system and another for converting back from the system to Arabic numerals.
In addition, this project includes a CLI binary which can be used to convert numbers from the command line. The name of this library is an abbreviation of 数字コンバーター, which literally translates to "number converter".
To use the CLI binary, simply run the following command:
bash
suukon -i <INPUT> -t <TARGET> <NUM>
where <NUM>
is the number you want to convert, <INPUT>
is the numeral system that <NUM>
is in, and <TARGET>
is the numeral system you want to convert <NUM>
to.
For example, to convert the number "123" from Arabic numerals to Japanese kanji numerals, you would run the following command:
bash
suukon -t japanese 123
The CLI binary supports all the same input and target numeral systems as the library. If the conversion is successful, the CLI binary will print the converted number to the console. If the conversion fails or the input or target systems are unknown, the CLI binary will print an error message to the console.
To see a full list of the supported numeral systems and their abbreviations, run the following command:
bash
suukon --help
To use this library in your Rust project, simply add the following line to your Cargo.toml
file:
toml
[dependencies]
suukon = { version = "0.1.0", default-features = false }
To install the suukon
binary locally, simply run the following command:
bash
cargo install suukon
This will download the latest version of the suukon
crate from crates.io and compile the suukon
binary, which will be installed in your system's binary directory.
After installation, you can use the suukon
command from the command line to convert numbers between numeral systems, as described in the Command-Line Interface section.
First, import the desired module for the numeral system you wish to work with. For example, to work with japanese numbers, import the japanese module as follows:
rust
use suukon::japanese::*;
Once imported, you could use the num_to_kanji
function to convert an Arabic numeral to the corresponding japanese representation, and the kanji_to_num
function to convert back from japanese to an Arabic numeral. For example:
```rust let numstr = "1234".tostring(); let kanjistr = "千二百三十四".tostring();
// Convert Arabic numeral to Japanese kanji numeral. asserteq!(numtokanji(numstr.clone(), Kanji::Normal).unwrap(), kanji_str.clone());
// Convert Japanese kanji numeral to Arabic numeral. asserteq!(kanjitonum(kanjistr, None).unwrap(), num_str); ```
The following numeral systems are supported by this library:
Each system has two functions: one to convert Arabic numerals to the system, and one to convert from the system back to Arabic numerals.
This library could be particularly useful for language translation programs that need to work with different numeral systems in different languages. For example, if a translation program is translating text from English to Japanese, it may need to convert English numbers to the corresponding Japanese kanji representations.
By using this library to perform these conversions, translation programs can ensure that the resulting translations are accurate and culturally appropriate. Additionally, by generating training data from this library, language models can learn to recognize and work with different numeral systems, which can improve the accuracy of translations.
Overall, this library could be a valuable tool for language translation programs that need to work with multiple numeral systems in different languages.
If you encounter any bugs or issues with this library, please open an issue on the GitLab repository.
Merge requests are also welcome! If you would like to contribute to the development of Suukon, you can submit a merge request on the GitLab repository. Contributions that add support for new numeral systems and expand the functionality of the library are particularly encouraged. Please ensure that your merge requests include relevant tests.
Please check CONTRIBUTING.md for more info on how to contribute.
This library is licensed under the MIT license. See the LICENSE file for details.