#nlp #english #text #grammar

in_definite

Get the indefinite article ('a' or 'an') to match the given word. For example: an umbrella, a user.

18 releases (1 stable)

1.0.0 Sep 4, 2023
0.2.5 Mar 12, 2022
0.2.4 Nov 14, 2020
0.2.3 Mar 18, 2020
0.1.10 Sep 21, 2019

#233 in Text processing

Download history 493/week @ 2024-06-20 1005/week @ 2024-06-27 611/week @ 2024-07-04 728/week @ 2024-07-11 722/week @ 2024-07-18 1597/week @ 2024-07-25 1152/week @ 2024-08-01 695/week @ 2024-08-08 1061/week @ 2024-08-15 876/week @ 2024-08-22 560/week @ 2024-08-29 834/week @ 2024-09-05 1366/week @ 2024-09-12 1007/week @ 2024-09-19 604/week @ 2024-09-26 860/week @ 2024-10-03

4,022 downloads per month
Used in 19 crates (3 directly)

MIT license

27KB
596 lines

in_definite

Rust port of indefinite on npm, for deciding which indefinite article to use ('a' or 'an').

Get the indefinite article ('a' or 'an') to match the given word. For example: an umbrella, a user.

Rust

Examples

use in_definite;

let result = in_definite::get_a_or_an("alien");
assert_eq!("an", result);
// Irregular word
let result = in_definite::get_a_or_an("unicorn");
assert_eq!("a", result);
// Title Case
let result = in_definite::get_a_or_an("Ugly");
assert_eq!("An", result);
let result = in_definite::is_an("alien");
assert_eq!(in_definite::Is::An, result);
let result = in_definite::is_an("unicorn");
assert_eq!(in_definite::Is::A, result);

Deviations from the original indefinite

Upper/lower/mixed case handling:

  • a word like THIS will be always considered to be an acronym.
  • normally the result is lower case ('a' or 'an')
  • title case is handled as: 'Ugly' -> 'An'
  • mixed case is handled as: 'uGly' -> 'an'

Adverbs:

  • Handles adverbs with '-ly' in a generic manner. Example: "a ubiquitously"

A big thanks to the original authors of indefinite!

Published @ crates.io

https://crates.io/crates/in_definite

licence = MIT

This project is licensed under the MIT License - see the LICENSE file for details

No runtime deps