or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

cardinal-pluralization.mdcore-pluralization.mdexample-values.mdindex.mdordinal-pluralization.mdplural-categories.mdrange-pluralization.md

example-values.mddocs/

0

# Example Values

1

2

Sample numeric values that demonstrate each plural category for every supported language. This module provides concrete examples to understand how pluralization rules work in practice.

3

4

## Capabilities

5

6

### Example Objects

7

8

Each language provides sample numbers that fall into each plural category for both cardinal and ordinal pluralization.

9

10

```typescript { .api }

11

/**

12

* Language example values

13

*/

14

interface LanguageExamples {

15

cardinal: Record<PluralCategory, string[]>;

16

ordinal: Record<PluralCategory, string[]>;

17

}

18

19

type PluralCategory = "zero" | "one" | "two" | "few" | "many" | "other";

20

```

21

22

### Import Patterns

23

24

```javascript { .api }

25

import * as Examples from "make-plural/examples";

26

// Or import specific languages

27

import { en, ar, fr } from "make-plural/examples";

28

// Or import raw JSON data

29

import ExamplesJSON from "make-plural/examples.json";

30

```

31

32

### Language Example Objects

33

34

All 219 languages provide example values:

35

36

**English Examples:**

37

```javascript

38

Examples.en.cardinal.one // ["1"]

39

Examples.en.cardinal.other // ["0", "2~16", "100", "1000", "10000", "100000", "1000000", ...]

40

41

Examples.en.ordinal.one // ["1", "21", "31", "41", "51", "61", "71", "81", "91", ...]

42

Examples.en.ordinal.two // ["2", "22", "32", "42", "52", "62", "72", "82", "92", ...]

43

Examples.en.ordinal.few // ["3", "23", "33", "43", "53", "63", "73", "83", "93", ...]

44

Examples.en.ordinal.other // ["0", "4~18", "100", "1000", "10000", "100000", "1000000", ...]

45

```

46

47

**Arabic Examples (Complex 6-Category System):**

48

```javascript

49

Examples.ar.cardinal.zero // ["0"]

50

Examples.ar.cardinal.one // ["1"]

51

Examples.ar.cardinal.two // ["2"]

52

Examples.ar.cardinal.few // ["3~10", "103~110", "1003", ...]

53

Examples.ar.cardinal.many // ["11~26", "111", "1011", ...]

54

Examples.ar.cardinal.other // ["100~102", "200~202", "300~302", ...]

55

56

Examples.ar.ordinal.other // ["0~15", "100", "1000", "10000", ...]

57

```

58

59

**Polish Examples (4-Category System):**

60

```javascript

61

Examples.pl.cardinal.one // ["1"]

62

Examples.pl.cardinal.few // ["2~4", "22~24", "32~34", ...]

63

Examples.pl.cardinal.many // ["0", "5~19", "100", "1000", ...]

64

Examples.pl.cardinal.other // ["0.0~1.5", "10.0", "100.0", ...]

65

66

Examples.pl.ordinal.other // ["0~15", "100", "1000", "10000", ...]

67

```

68

69

**Chinese Examples (Single Category):**

70

```javascript

71

Examples.zh.cardinal.other // ["0~15", "100", "1000", "10000", ...]

72

Examples.zh.ordinal.other // ["0~15", "100", "1000", "10000", ...]

73

```

74

75

### Usage Examples

76

77

**Understanding Pluralization Rules:**

78

```javascript

79

import * as Examples from "make-plural/examples";

80

import { en, ar, pl } from "make-plural";

81

82

// Test English examples

83

Examples.en.cardinal.one.forEach(num => {

84

console.log(`${num}: ${en(parseFloat(num))}`);

85

});

86

// 1: one

87

88

Examples.en.ordinal.two.forEach(num => {

89

console.log(`${num}: ${en(parseFloat(num), true)}`);

90

});

91

// 2: two, 22: two, 32: two, etc.

92

93

// Test Arabic examples

94

Examples.ar.cardinal.few.forEach(num => {

95

if (!num.includes('~')) { // Skip ranges for clarity

96

console.log(`${num}: ${ar(parseFloat(num))}`);

97

}

98

});

99

// 3: few, 4: few, 5: few, etc.

100

```

101

102

**Testing Pluralization Functions:**

103

```javascript

104

import * as Examples from "make-plural/examples";

105

import { en, fr, ar } from "make-plural";

106

107

// Validate that examples match expected categories

108

function validateExamples(lang, pluralFn, examples) {

109

const errors = [];

110

111

for (const [expectedCategory, exampleValues] of Object.entries(examples.cardinal)) {

112

for (const value of exampleValues) {

113

if (value.includes('~')) continue; // Skip ranges

114

115

const actualCategory = pluralFn(parseFloat(value));

116

if (actualCategory !== expectedCategory) {

117

errors.push(`${lang}: ${value} expected ${expectedCategory}, got ${actualCategory}`);

118

}

119

}

120

}

121

122

return errors;

123

}

124

125

// Test English

126

const enErrors = validateExamples('en', en, Examples.en);

127

console.log(enErrors); // Should be empty

128

129

// Test French

130

const frErrors = validateExamples('fr', fr, Examples.fr);

131

console.log(frErrors); // Should be empty

132

```

133

134

**Building Test Suites:**

135

```javascript

136

import * as Examples from "make-plural/examples";

137

138

// Generate comprehensive test cases

139

function generatePluralTests(languages) {

140

const tests = [];

141

142

for (const lang of languages) {

143

const examples = Examples[lang];

144

145

// Test cardinal examples

146

for (const [category, values] of Object.entries(examples.cardinal)) {

147

for (const value of values) {

148

if (!value.includes('~')) { // Skip ranges

149

tests.push({

150

language: lang,

151

value: parseFloat(value),

152

type: 'cardinal',

153

expected: category

154

});

155

}

156

}

157

}

158

159

// Test ordinal examples

160

for (const [category, values] of Object.entries(examples.ordinal)) {

161

for (const value of values) {

162

if (!value.includes('~')) { // Skip ranges

163

tests.push({

164

language: lang,

165

value: parseFloat(value),

166

type: 'ordinal',

167

expected: category

168

});

169

}

170

}

171

}

172

}

173

174

return tests;

175

}

176

```

177

178

**Documentation Generation:**

179

```javascript

180

import * as Examples from "make-plural/examples";

181

182

// Generate human-readable documentation

183

function generatePluralDocs(language) {

184

const examples = Examples[language];

185

let docs = `# ${language.toUpperCase()} Pluralization Examples\n\n`;

186

187

docs += `## Cardinal Numbers\n\n`;

188

for (const [category, values] of Object.entries(examples.cardinal)) {

189

docs += `**${category}**: ${values.slice(0, 5).join(', ')}${values.length > 5 ? ', ...' : ''}\n\n`;

190

}

191

192

docs += `## Ordinal Numbers\n\n`;

193

for (const [category, values] of Object.entries(examples.ordinal)) {

194

docs += `**${category}**: ${values.slice(0, 5).join(', ')}${values.length > 5 ? ', ...' : ''}\n\n`;

195

}

196

197

return docs;

198

}

199

200

console.log(generatePluralDocs('en'));

201

```

202

203

### Example Value Formats

204

205

**Number Representations:**

206

- `"1"` - Single number

207

- `"2~4"` - Range (2, 3, 4)

208

- `"1.5"` - Decimal number

209

- `"0.0~1.5"` - Decimal range

210

211

**Range Interpretation:**

212

```javascript

213

// "2~4" represents the values: 2, 3, 4

214

// "103~110" represents: 103, 104, 105, 106, 107, 108, 109, 110

215

// "0.0~1.5" represents decimal values from 0.0 to 1.5 (typically step by 0.1)

216

```

217

218

### Language-Specific Example Patterns

219

220

**English Cardinal Patterns:**

221

- `one`: Just [1]

222

- `other`: Everything else [0, 2-16, 100, 1000, ...]

223

224

**English Ordinal Patterns:**

225

- `one`: [1, 21, 31, 41, 51, 61, 71, 81, 91, 101, 121, ...]

226

- `two`: [2, 22, 32, 42, 52, 62, 72, 82, 92, 102, 122, ...]

227

- `few`: [3, 23, 33, 43, 53, 63, 73, 83, 93, 103, 123, ...]

228

- `other`: [0, 4-20, 24-30, 34-40, ...]

229

230

**Arabic Cardinal Patterns:**

231

- `zero`: [0]

232

- `one`: [1]

233

- `two`: [2]

234

- `few`: [3-10, 103-110, 1003, ...]

235

- `many`: [11-26, 111, 1011, ...]

236

- `other`: [100-102, 200-202, 300-302, ...]

237

238

**Polish Cardinal Patterns:**

239

- `one`: [1]

240

- `few`: [2-4, 22-24, 32-34, 42-44, ...]

241

- `many`: [0, 5-21, 25-31, 35-41, 100, 1000, ...]

242

- `other`: [0.0-1.5, 10.0, 100.0, ...] (decimals)

243

244

### JSON Data Access

245

246

For applications needing raw data access:

247

248

```javascript

249

import ExamplesJSON from "make-plural/examples.json";

250

251

// Direct JSON access (same structure as Examples module)

252

console.log(ExamplesJSON.en.cardinal.one); // ["1"]

253

console.log(ExamplesJSON.ar.cardinal.few); // ["3~10", "103~110", ...]

254

255

// Useful for server-side processing or data analysis

256

const allLanguages = Object.keys(ExamplesJSON);

257

const complexLanguages = allLanguages.filter(lang =>

258

Object.keys(ExamplesJSON[lang].cardinal).length > 3

259

);

260

```

261

262

### Practical Applications

263

264

**Interactive Documentation:**

265

Use examples to create interactive pluralization demos where users can see how different numbers are categorized.

266

267

**Test Data Generation:**

268

Use examples as the basis for comprehensive test suites to validate pluralization implementations.

269

270

**Rule Understanding:**

271

Help developers understand complex pluralization rules by seeing concrete examples of each category.

272

273

**Translation Validation:**

274

Validate that translations cover all necessary plural forms by checking against example values.