图像缩略图

字数转换

版本2.1.0 (35.3 KB) 斯蒂芬。
将字符串中的英文数字名称/s转换为数字值/s (GB/US)。

560次下载

更新2020年7月9日

查看许可协议

WORDS2NUM将一个带有英文单词给出的数字值/s的字符串转换为一个数字向量:例如字符串' 1024 '作为标量数字1024返回。WORDS2NUM接受包含零个或多个数字子字符串的字符串,并为每个检测到的数字子字符串返回一个元素的数字向量。选项允许用户选择:

*输出数字向量的类:double, single, uintX或intX。
*大写/小写/标题/句子。
*单词之间空格的使用。
数量级组之间使用逗号。
在十和一之间使用连字符。
在十位/ 1之前使用and(英式和英联邦英语要求)。
*空格字符/s
*编号规模:短/长/ peltier / Rowlett / Knuth (-yllion)。

###奖励函数/脚本###

*WORDS2NUM_测试包含数千个测试用例。
*WORDS2NUM_演示将WORDS2NUM的输出与实际示例进行比较。

###反向转换###

//www.tianjin-qmedu.com/matlabcentral/fileexchange/47221-number-to-words

###例子###

> > words2num(“0”)
ans = 0

>> words2num('一千零二十四')
ans = 1024
> > words2num(“One_Thousand_and_TWENTY-four”,“白色”,“_”)
ans = 1024
>> words2num('One Thousand and 24 ',' case','lower')
ans = 4
>> words2num('One Thousand and 24 ',' case','upper')
ans=20
>>words2num('壹仟零贰拾肆'、'case'、'title')
ans=1000
>> words2num('One Thousand and TWENTY-four', '连字符',false)
ans = (1020 4)
>>words2num('壹仟零贰拾肆','and','false)
ans=[1000,24]
>> words2num('One and 24 ',' suffix','-')
ans = 1020

>>[num,spl]=words2num('负三十二平方等于一千零二十四')
num =(-32、1024)
spl={'','平方是','.}

>>[num,spl]=words2num('一百二十三磅四十五便士')
num=[123,45]
SPL = {",' pound and ',' pence'}

>> [num,spl] = words2num('pi= threepointonefouronefiveninetwo65,35,588 ')
num = 3.14159265358
spl ={’π= '}

>>[num,spl]=words2num(“一百零一只达尔马提亚狗”)
num=101
spl ={",'斑点狗'}

>>words2num(‘一百七十九个百万’)
ans=1.79e+308
>> words2num(' 180 unentillion ') % >realmax . >> words2num(' 180 unentillion ') % >realmax . >
ans =正
>>words2num('一百八十亿,'class','int64')
ans=+9223372036854775807
> > words2num (num2words (intmin (int64)),“类”,“int64”)
ans=-9223372036854775808

>> words2num('one point zero zero two zero zero three trillion')注释:
ans=100200300000000
>>words2num('1万亿,20亿,300万')
ans=100200300000000
>>words2num('1万亿,20亿,300万,'逗号',true,'和',true)
ans = (1002000000000, 1002000000000)
>> words2num('one trillion, twenty billion three million', 'comma',false)注释:
ans=[100000000002003000000]
>>words2num('一百万,'mag','component')
ans = 1000000000000

>> words2num(' 10 billion', 'scale','short',' 10亿')
ans = 1000000000
>>words2num('1000000','scale','long')
ans = 1000000000
>>words2num('1毫安,'scale','peletier')
ans = 1000000000
>>words2num('one gillion'、'scale'、'rowlett')
ans = 1000000000
>> words2num(' 10,000,000 ',' scale','knuth')
ans = 1000000000

>>words2num('负无穷大')
ans=-Inf
> > words2num(不是一个数字)
ans=NaN

引用作为

斯蒂芬(2021)。字数转换(//www.tianjin-qmedu.com/matlabcentral/fileexchange/52925-words-to-number),MATLAB中心文件交换