Skip to content

Chinese: parse numerals #95

Description

@scossu

This can be done by reverse-engineering @tventimi 's processNumbers() Parallelogram function:

https://github.com/pulibrary/parallelogram/blob/main/cloudapp/src/app/pinyin.service.ts#L160

From earlier correspondence:

The number conversion depends on the table only in the sense that certain entries are marked with a # if they represent > numbers or are part of the context in which a number would appear. This is a fairly short list, which I paste below:

〇,ling#0
零,ling#0
一,yi#1
二,er#2
兩,liang#2
两,liang#2
三,san#3
四,si#4
五,wu#5
六,liu#6
七,qi#7
八,ba#8
九,jiu#9
十,shi#10
廾,gong#20
廿,nian#20
卅,sa#30
卌,xi#40
百,bai#100
千,qian#1000
万,wan#10000
萬,wan#10000
亿,yi#100000000
億,yi#100000000
及,ji#
至,zhi#
年,nian#
月,yue#
日,ri#
第,di#

When the "#" is followed by a number, that represents the numeric value of the character. The other entries are: 及 and 至 ("to" when used in a date range), 年 (year), 月(month), 日 (day), and 第 (ordinal marker, used before a number to indicate 1st, 2nd, 3rd, etc).

As far as the format for date ranges, the code looks for any sequence of characters containing only numbers and/or the 5 date-related characters 及至 年 月 日. As long as that sequence contains both (年 and 月) or (月 and 日), then it considered a date and any numerical characters in that entire sequence are converted to numbers. This covers a variety of different formats that a date range could be in.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions