Description Usage Arguments Value Functions Details References See Also Examples
Functions to detect and extract Chinese numerals in character object and string.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | is_cnum(
x,
lang = default_cnum_lang(),
mode = "casual",
financial = FALSE,
literal = FALSE,
strict = FALSE,
...
)
has_cnum(
x,
lang = default_cnum_lang(),
mode = "casual",
financial = FALSE,
...
)
extract_cnum(
x,
lang = default_cnum_lang(),
mode = "casual",
financial = FALSE,
prefix = NULL,
suffix = NULL,
...
)
|
x |
the character object or string to be tested or to extract from. |
lang |
the language of the Chinese numerals. |
mode |
the scale naming system to be enforced. See the ‘Details’ section for the list of supported modes. |
financial |
logical: should the financial numerals be used (daxie shuzi)? |
literal |
logical: should the numerals be converted literally? (e.g. 721 to be converted to "qi er yi" instead of "qibai ershiyi" and vice versa) |
strict |
logical: Should the Chinese numerals format be strictly
enforced? A casual test only checks if |
... |
optional arguments to be passed to |
prefix |
the prefix of the Chinese numerals. Only numerals with the designated prefix are extracted. Supports regular expression(s). |
suffix |
the suffix of the Chinese numerals. Only numerals with the designated suffix are extracted. Supports regular expression(s). |
is_cnum
returns a logical vector indicating is Chinese
numerals or not for each element of x
).
has_cnum
returns a logical vector indicating contains Chinese
numerals or not for each element of x
.
extract_cnum
returns a list of character vectors containing
the extracted Chinese numerals.
is_cnum
: Test if character object is Chinese numerals. A wrapper
around grepl
.
has_cnum
: Test if string contains Chinese numerals. A wrapper around
grepl
.
extract_cnum
: Extracts Chinese numerals from string. A wrapper around
str_extract_all
from stringr
.
The following scale naming systems are supported:
"casual"
: the casual naming system used outside of mainland
China, i.e. 1e+09 is referred to as "yi zhao".
"casualPRC"
: the casual naming system used in mainland China,
i.e. 1e+9 is referred to as "yi wanyi".
"SIprefix"
:
the SI prefix system used in Taiwan as stipulated in the document
Names, Definitions and Symbols of the Legal Units of Measurement and
the Decimal Multiples and Submultiples.
"SIprefixPRC"
: the
SI prefix system used in mainland China as stipulated in the document
China Statutory Measurement Units.
"SIprefixPRClong"
:
a variant of "SIprefixPRC"
with long prefixes, e.g. 1e+09 is
referred to as "yi jika" instead of "yi ji".
The standard for mode "SIprefix"
Names, Definitions
and Symbols of the Legal Units of Measurement and the Decimal Multiples and
Submultiples is available from
https://gazette.nat.gov.tw/egFront/detail.do?metaid=108965 (in
Traditional Chinese).
The standard for mode "SIprefixPRC"
China Statutory
Measurement Units is available from
http://gkml.samr.gov.cn/nsjg/jls/201902/t20190225_291134.html (in
Simplified Chinese).
Functions for conversion
1 2 3 4 5 | is_cnum("yibai ershiyi")
has_cnum("yibai bashi yuan")
extract_cnum("shisiyi ren")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.