File tree Expand file tree Collapse file tree 3 files changed +34
-4
lines changed Expand file tree Collapse file tree 3 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import { determiner } from "./determiner.ts";
8
8
import { ExhaustedError , TranslationTodoError } from "./error.ts" ;
9
9
import { nanpa } from "./nanpa.ts" ;
10
10
import { noun } from "./noun.ts" ;
11
- import { number } from "./number.ts" ;
11
+ import { number , numberAsText } from "./number.ts" ;
12
12
import { phrase } from "./phrase.ts" ;
13
13
import { pronoun } from "./pronoun.ts" ;
14
14
import { noEmphasis , word } from "./word.ts" ;
@@ -53,7 +53,7 @@ function defaultModifier(wordUnit: TokiPona.WordUnit) {
53
53
type : "determiner" ,
54
54
determiner : {
55
55
determiner : word ( {
56
- word : ` ${ number } ` ,
56
+ word : numberAsText ( number ) ,
57
57
reduplicationCount : 1 ,
58
58
emphasis,
59
59
} ) ,
Original file line number Diff line number Diff line change @@ -4,6 +4,29 @@ import { IterableResult } from "../compound.ts";
4
4
import { dictionary } from "../dictionary.ts" ;
5
5
import { FilteredError } from "./error.ts" ;
6
6
7
+ const WORDS = [
8
+ "zero" ,
9
+ "one" ,
10
+ "two" ,
11
+ "three" ,
12
+ "four" ,
13
+ "five" ,
14
+ "six" ,
15
+ "seven" ,
16
+ "eight" ,
17
+ "nine" ,
18
+ "ten" ,
19
+ "eleven" ,
20
+ "twelve" ,
21
+ "thirteen" ,
22
+ "fourteen" ,
23
+ "fifteen" ,
24
+ "sixteen" ,
25
+ "seventeen" ,
26
+ "eighteen" ,
27
+ "nineteen" ,
28
+ "twenty" ,
29
+ ] ;
7
30
function singleNumber ( word : string ) {
8
31
return IterableResult . fromArray ( dictionary . get ( word ) ! . definitions )
9
32
. filterMap ( ( definition ) =>
@@ -81,3 +104,10 @@ export function number(numbers: ReadonlyArray<string>): IterableResult<number> {
81
104
return IterableResult . combine ( ...numbers . map ( singleNumber ) )
82
105
. flatMap ( combineNumbers ) ;
83
106
}
107
+ export function numberAsText ( number : number ) : string {
108
+ if ( number <= 20 ) {
109
+ return WORDS [ number ] ;
110
+ } else {
111
+ return `${ number } ` ;
112
+ }
113
+ }
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { adjective, compoundAdjective } from "./adjective.ts";
6
6
import * as English from "./ast.ts" ;
7
7
import { TranslationTodoError } from "./error.ts" ;
8
8
import { PartialNoun , partialNoun } from "./noun.ts" ;
9
- import { number } from "./number.ts" ;
9
+ import { number , numberAsText } from "./number.ts" ;
10
10
import { partialPronoun , Place } from "./pronoun.ts" ;
11
11
import { PartialVerb , partialVerb } from "./verb.ts" ;
12
12
import { word } from "./word.ts" ;
@@ -118,7 +118,7 @@ export function wordUnit(
118
118
type : "noun" ,
119
119
determiners : [ ] ,
120
120
adjectives : [ ] ,
121
- singular : ` ${ number } ` ,
121
+ singular : numberAsText ( number ) ,
122
122
plural : null ,
123
123
reduplicationCount : 1 ,
124
124
emphasis : wordUnit . emphasis != null ,
You can’t perform that action at this time.
0 commit comments