Skip to content

Commit

Permalink
Add documentation about pluralization
Browse files Browse the repository at this point in the history
  • Loading branch information
filips123 committed Dec 16, 2020
1 parent 813a87c commit 8e1fc52
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
5 changes: 4 additions & 1 deletion project-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@
├─ internal.py
├─ time.py *
├─ parse.py *
├─ utils.py *
├─ lang/ (localized functions and basic language data)
│ ├─ common_data_<>.py (data structures related to language '<>')
│ ├─ format_<>.py (localized formatters)
│ ├─ parse_<>.py (localized parsers)
│ ├─ utils_<>.py (localized utilities)
├─ res/ (fully localized data, 'en-us' vs 'en-au' and etc.)
│ ├─ text/
│ │ ├─ <lang-code>/
│ │ │ ├─ date_time.json
│ │ │ ├─ common words
│ │ │ ├─ durations.json
│ │ │ ├─ connectors.json

----

Expand Down
33 changes: 33 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Lingua Franca (_noun_)<br>
- [Extract numbers](#extract-numbers)
- [Extract durations](#extract-durations)
- [Extract dates](#extract-dates)
- [Utils](#utils)
- [Get plural category](#get-plural-category)
- [Get plural form](#get-plural-form)
- [Contributing to this project](#contributing-to-this-project)
- [0. Sign a Contributor Licensing Agreement](#0-sign-a-contributor-licensing-agreement)
- [1. Setup a local copy of the project](#1-setup-a-local-copy-of-the-project)
Expand Down Expand Up @@ -211,6 +214,33 @@ testExtract("on the evening of june 5th 2017 remind me to call my mother",

```

## Utils

Common utils that can be used for formatting and parsing

### Get plural category

get one of [Unicode CLDR plural categories](http://cldr.unicode.org/index/cldr-spec/plural-rules) according
to the [pluralization rules](https://unicode-org.github.io/cldr-staging/charts/37/supplemental/language_plural_rules.html) of the language

```python
from lingua_franca.utils import get_plural_category

assert get_plural_category(1) == "one"
assert get_plural_category(2) == "other"

assert get_plural_category(1, type="ordinal") == "one"
assert get_plural_category(2, type="ordinal") == "two"
assert get_plural_category(3, type="ordinal") == "few"
assert get_plural_category(4, type="ordinal") == "other"
```

### Get plural form

pluralize the word

*Note:* Not implemented yet in any language.

## Getting Started

### Loading a language
Expand Down Expand Up @@ -329,6 +359,7 @@ Each language should have two test files:

- `test_format_lang.py`
- `test_parse_lang.py`
- `test_utils_lang.py`

### 4. Run tests to confirm they fail

Expand All @@ -348,6 +379,8 @@ Now we can add our new code. There are three main files for each language:
All formatting functions for this language.
- `parse_lang.py`
All parsing functions for this language.
- `utils_lang.py`
All util functions for this language.

Since we have already written our unit tests, we can run these regularly to see our progress.

Expand Down

0 comments on commit 8e1fc52

Please sign in to comment.