Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pharo-contributions/singularizepluralize
Transforming singular nouns to their plural form and vice versa.
https://github.com/pharo-contributions/singularizepluralize
language natural-language-processing nlp pharo pharo-smalltalk smalltalk
Last synced: about 1 month ago
JSON representation
Transforming singular nouns to their plural form and vice versa.
- Host: GitHub
- URL: https://github.com/pharo-contributions/singularizepluralize
- Owner: pharo-contributions
- License: mit
- Created: 2019-07-19T15:17:08.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-06-08T13:03:35.000Z (over 1 year ago)
- Last Synced: 2024-10-09T13:22:14.203Z (about 1 month ago)
- Topics: language, natural-language-processing, nlp, pharo, pharo-smalltalk, smalltalk
- Language: Smalltalk
- Size: 41 KB
- Stars: 10
- Watchers: 4
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SingularizePluralize
[![Build status](https://github.com/pharo-contributions/SingularizePluralize/workflows/CI/badge.svg)](https://github.com/pharo-contributions/SingularizePluralize/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/pharo-contributions/SingularizePluralize/badge.svg?branch=master)](https://coveralls.io/github/pharo-contributions/SingularizePluralize?branch=master)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/pharo-contributions/SingularizePluralize/master/LICENSE)A simple [Pharo](http://pharo.org/) library for transforming singular nouns to their plural form and vice versa. The implementation is based on the [inflection](https://inflection.readthedocs.io/en/latest/_modules/inflection.html) library in Python.
## Installation
To install the packages of SingularizePluralize, go to the Playground (Ctrl+OW) in your Pharo image and execute the following Metacello script (select it and press Do-it button or Ctrl+D):```Smalltalk
Metacello new
baseline: 'SingularizePluralize';
repository: 'github://pharo-contributions/SingularizePluralize/src';
load.
```## How to use it?
The package simply extends class `String` with two messages: `asSingular` and `asPlural`. Here are some examples of converting singular nouns to their plural forms:
```Smalltalk
'banana' asPlural. "bananas"
'man' asPlural. "men"
'woman' asPlural. "women"
'matrix' asPlural. "matrices"
'child' asPlural. "children"
'knife' asPlural. "knives"
'thesis' asPlural. "theses"
'auditorium' asPlural. "auditoria"
```Similarly, we can convert plural nouns to their singular forms:
```Smalltalk
'bananas' asSingular. "banana"
'men' asSingular. "man"
'women' asSingular. "woman"
'matrices' asSingular. "matrix"
'children' asSingular. "child"
'knives' asSingular. "knife"
'theses' asSingular. "thesis"
'auditoria' asSingular. "auditorium"
```## If you find a mistake
Natural languages including English are very complex and irregular. It is hard to capture all rules and exceptions of pluralization with one algorithm. If you try to convert a noun to its singular/plural form and encounter a mistake, please report it by creating an issue with the title **Singular (Plural) of "X" should be "Y" not "Z"**. I will create a rule or add an exception to cover that case.