Home > asr > isTradChinese.m

isTradChinese

PURPOSE ^

isTradChinese: Check if the given string is traditional Chinese

SYNOPSIS ^

function out=isTradChinese(string, chineseCharAll)

DESCRIPTION ^

 isTradChinese: Check if the given string is traditional Chinese
    Usage: out=isTradChinese(string, chineseAll)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function out=isTradChinese(string, chineseCharAll)
0002 % isTradChinese: Check if the given string is traditional Chinese
0003 %    Usage: out=isTradChinese(string, chineseAll)
0004 
0005 %    Roger Jang, 20081028
0006 
0007 if nargin<1, selfdemo; return; end
0008 if nargin<2, chineseCharAll=fileread('chineseChar.txt'); end
0009 
0010 strLen=length(string);
0011 out=zeros(strLen, 1);
0012 for i=1:strLen
0013     index=find(chineseCharAll==string(i));
0014     if length(index)>0
0015         out(i)=1;
0016     end
0017 end
0018 out=logical(out);
0019 
0020 % ====== Self demo
0021 function selfdemo
0022 string='Roger的年紀已經大於40歲';
0023 output=isTradChinese(string);
0024 fprintf('input = %s\n', string);
0025 fprintf('output = %s\n', mat2str(output));

Generated on Tue 01-Jun-2010 09:50:19 by m2html © 2003