??xml version="1.0" encoding="utf-8" standalone="yes"?>www.在线视频,性网站在线看,一本到av在线http://www.aygfsteel.com/calvinlau/category/39837.html技术储备,从这里开?/description>zh-cnSun, 27 Sep 2009 21:04:12 GMTSun, 27 Sep 2009 21:04:12 GMT60整数转字W串http://www.aygfsteel.com/calvinlau/articles/296554.htmlcalvinlaucalvinlauSat, 26 Sep 2009 07:41:00 GMThttp://www.aygfsteel.com/calvinlau/articles/296554.htmlhttp://www.aygfsteel.com/calvinlau/comments/296554.htmlhttp://www.aygfsteel.com/calvinlau/articles/296554.html#Feedback0http://www.aygfsteel.com/calvinlau/comments/commentRss/296554.htmlhttp://www.aygfsteel.com/calvinlau/services/trackbacks/296554.html     if(a==0){
        *str='0';
        *(str+1)='\0';
        return;
    }
       
    char* p = str;
    if(a<0){
        a=a*(-1);
        *p++ = '-';
    }
    int len = 0;
    while(a){
        *p++ = a%10+'0';
        a/=10;
        ++len;
    }
    int start = *str=='-'?1:0;
    int tmp;
    for(int i=0;i<len/2;++i){
        tmp = str[start+i];
        str[start+i]=str[len+start-1-i];
        str[len+start-1-i]=tmp;
    }
    str[len+start]='\0';
}
void main(){
   
    char* str = new char[12];
    //IntToStr(0,str);
    IntToStr(-12340,str);
    //IntToStr(214748367,str);
    printf("%s\n",str);
}


calvinlau 2009-09-26 15:41 发表评论
]]>
QzzQ?x&(x-1)表达式的意义http://www.aygfsteel.com/calvinlau/articles/287331.htmlcalvinlaucalvinlauSun, 19 Jul 2009 07:27:00 GMThttp://www.aygfsteel.com/calvinlau/articles/287331.htmlhttp://www.aygfsteel.com/calvinlau/comments/287331.htmlhttp://www.aygfsteel.com/calvinlau/articles/287331.html#Feedback0http://www.aygfsteel.com/calvinlau/comments/commentRss/287331.htmlhttp://www.aygfsteel.com/calvinlau/services/trackbacks/287331.html
x&(x-1)表达式的意义

求下面函数的q回?微Y) -- l计1的个?/strong>
-------------------------------------
int func(int x)
{
    int countx = 0;
    while(x)
    {
        countx++;
        x = x&(x-1);
    }
    return countx;
}

假定x = 9999
10011100001111
{案: 8

思\: x转化?q制Q看含有?的个数?br /> ? 每执行一ơx = x&(x-1)Q会x用二q制表示时最双的一?变ؓ0Q因为x-1会该?x用二q制表示时最双的一?)变ؓ0?br />



判断一个数(x)是否?的nơ方
-------------------------------------
#include <stdio.h>

int func(int x)
{
    if( (x&(x-1)) == 0 )
        return 1;
    else
        return 0;
}

int main()
{
    int x = 8;
    printf("%d\n", func(x));
}


?
(1) 如果一个数?的nơ方Q那么这个数用二q制表示时其最高位?Q其余位??br />
(2) == 优先U高?&


calvinlau 2009-07-19 15:27 发表评论
]]>
计算整数的二q制表示有多个1http://www.aygfsteel.com/calvinlau/articles/287327.htmlcalvinlaucalvinlauSun, 19 Jul 2009 06:38:00 GMThttp://www.aygfsteel.com/calvinlau/articles/287327.htmlhttp://www.aygfsteel.com/calvinlau/comments/287327.htmlhttp://www.aygfsteel.com/calvinlau/articles/287327.html#Feedback0http://www.aygfsteel.com/calvinlau/comments/commentRss/287327.htmlhttp://www.aygfsteel.com/calvinlau/services/trackbacks/287327.html
#include
<stdio.h>
#include
<stdlib.h>

unsigned 
long count_one(unsigned long data)
{
    unsigned 
long count = 0;
    unsigned 
long x = data;
    
while(x)
    {
        count
++;
        x 
= x & (x-1);
    }
    
return count;
}

int main(){
    unsigned 
long data[] = {13,16,25,31,76};
    
int i = 0;
    
int size = sizeof(data)/sizeof(unsigned long);
    
for(i=0;i<size;i++){
        printf(
"%d has %d 1s\n",data[i],count_one(data[i]));
    }
    
return 0;
}


calvinlau 2009-07-19 14:38 发表评论
]]>
数组循环位移http://www.aygfsteel.com/calvinlau/articles/280414.htmlcalvinlaucalvinlauSun, 07 Jun 2009 04:00:00 GMThttp://www.aygfsteel.com/calvinlau/articles/280414.htmlhttp://www.aygfsteel.com/calvinlau/comments/280414.htmlhttp://www.aygfsteel.com/calvinlau/articles/280414.html#Feedback0http://www.aygfsteel.com/calvinlau/comments/commentRss/280414.htmlhttp://www.aygfsteel.com/calvinlau/services/trackbacks/280414.html
解法1Q?br /> 思\Q?br /> Q?Q?整个数组倒序
Q?Q? - K位倒序
Q?QK - (N-1)位倒序

代码Q?br />
void printArray(int a[],int n){
    
    
for(int i=0;i<n;i++){
        printf(
"%d\t",a[i]);
    }
    printf(
"\n");
}

void reverse(int a[], int begin, int end){
    
int n = (end-begin+1)/2;
    
for(int i=0;i<n;i++){
        
int t = a[begin+i];
        a[begin
+i] = a[end-i-1];
        a[end
-i-1= t;
    }
}

void shift(int a[], int n, int k){
    k 
= (n+k%n)%n;
    reverse(a,
0,n);
    reverse(a,
0,k);
    reverse(a,k,n);
}

void main(){
    
int a[] = {1,2,3,4,5,6,7,8};
        
int n = sizeof(a)/sizeof(int);
    printArray(a,n);
    
//shift(a,n,-1);
        shift(a,n,4);
    printArray(a,
8);
}


解法2Q?br />
void Output(int *pBuffer, int nCount)
{
    
if(!pBuffer || !nCount) return;

    
for (size_t i = 0; i < nCount; i++)
    {
        printf(
" %d ", pBuffer[i]);
    }

    printf(
"\n");

}

void ShiftN(int *pBuffer, int nCount, int nShiftN)
{
    
if(!pBuffer || !nCount || !nShiftN) return;

    nShiftN 
%= nCount;

    
int nIndex = 0;
    
int nStart  = nIndex;

    
int nTemp  = pBuffer[nIndex];

    
for (size_t i = 0; i < nCount; i++)
    {
        nIndex 
= (nIndex + nShiftN) % nCount;

        pBuffer[nIndex] 
^= nTemp ^=
        pBuffer[nIndex] 
^= nTemp ;

        
if(nIndex == nStart)
        {
            nStart 
++;
            nIndex 
= nStart;
            nTemp 
= pBuffer[nIndex];
        }
    }
}

int main(int argc, char* argv[])
{
    
int buffer[] = {123456789101112};

    
int nCount = sizeof(buffer) / sizeof(int);

    Output(buffer, nCount);

    ShiftN(buffer, nCount, 
8);

    Output(buffer, nCount);
   
    
return 0;
}



calvinlau 2009-06-07 12:00 发表评论
]]>
单链表反?/title><link>http://www.aygfsteel.com/calvinlau/articles/279908.html</link><dc:creator>calvinlau</dc:creator><author>calvinlau</author><pubDate>Wed, 03 Jun 2009 14:47:00 GMT</pubDate><guid>http://www.aygfsteel.com/calvinlau/articles/279908.html</guid><wfw:comment>http://www.aygfsteel.com/calvinlau/comments/279908.html</wfw:comment><comments>http://www.aygfsteel.com/calvinlau/articles/279908.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/calvinlau/comments/commentRss/279908.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/calvinlau/services/trackbacks/279908.html</trackback:ping><description><![CDATA[相关定义Q?br /> <br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --> <span style="color: #0000ff;">struct</span><span style="color: #000000;"> LNode{<br /> </span> <span style="color: #000000;">    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> e;<br /> </span> <span style="color: #000000;">    LNode</span><span style="color: #000000;">*</span><span style="color: #000000;"> next;<br /> </span><span style="color: #000000;">};<br />   </span><span style="color: #000000;"><br /> </span><span style="color: #000000;">typedef </span><span style="color: #0000ff;">struct</span><span style="color: #000000;"> LNode</span><span style="color: #000000;">*</span><span style="color: #000000;"> LinkList;</span></div> <br /> 非递归ҎQ?br /> <br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #0000ff;">//l 是带头结点的单链?br /> void</span><span style="color: #000000;"> ReverseList(LinkList l){<br /> </span> <span style="color: #000000;">    </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(l</span><span style="color: #000000;">==</span><span style="color: #000000;">NULL </span><span style="color: #000000;">||</span><span style="color: #000000;"> l</span><span style="color: #000000;">-></span><span style="color: #000000;">next </span><span style="color: #000000;">==</span><span style="color: #000000;"> NULL)<br /> </span> <span style="color: #000000;">        </span><span style="color: #0000ff;">return</span><span style="color: #000000;">;<br /> </span> <span style="color: #000000;">    LNode </span><span style="color: #000000;">*</span><span style="color: #000000;">p, </span><span style="color: #000000;">*</span><span style="color: #000000;">q, </span><span style="color: #000000;">*</span><span style="color: #000000;">r;<br /> </span> <span style="color: #000000;">    p </span><span style="color: #000000;">=</span><span style="color: #000000;"> l</span><span style="color: #000000;">-></span><span style="color: #000000;">next;<br /> </span> <span style="color: #000000;">    q </span><span style="color: #000000;">=</span><span style="color: #000000;"> p</span><span style="color: #000000;">-></span><span style="color: #000000;">next;<br /> </span> <span style="color: #000000;">    </span><span style="color: #0000ff;">while</span><span style="color: #000000;">( q </span><span style="color: #000000;">!=</span><span style="color: #000000;"> NULL){<br /> </span> <span style="color: #000000;">        r </span><span style="color: #000000;">=</span><span style="color: #000000;"> q</span><span style="color: #000000;">-></span><span style="color: #000000;">next;<br /> </span> <span style="color: #000000;">        q</span><span style="color: #000000;">-></span><span style="color: #000000;">next </span><span style="color: #000000;">=</span><span style="color: #000000;"> p;<br /> </span> <span style="color: #000000;">        p </span><span style="color: #000000;">=</span><span style="color: #000000;"> q;<br /> </span> <span style="color: #000000;">        q </span><span style="color: #000000;">=</span><span style="color: #000000;"> r;<br /> </span> <span style="color: #000000;">    }<br />   </span><span style="color: #000000;"><br /> </span> <span style="color: #000000;">    l</span><span style="color: #000000;">-></span><span style="color: #000000;">next</span><span style="color: #000000;">-></span><span style="color: #000000;">next </span><span style="color: #000000;">=</span><span style="color: #000000;"> NULL;<br /> </span> <span style="color: #000000;">    l</span><span style="color: #000000;">-></span><span style="color: #000000;">next </span><span style="color: #000000;">=</span><span style="color: #000000;"> p;<br /> </span><span style="color: #000000;">}</span></div> <br /> 递归ҎQ?br /> <br /> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #000000;">LNode</span><span style="color: #000000;">*</span><span style="color: #000000;"> ReverseList_Recursive(LNode</span><span style="color: #000000;">*</span><span style="color: #000000;"> pNode,LinkList</span><span style="color: #000000;">&</span><span style="color: #000000;"> l){<br />   </span><span style="color: #000000;"><br /> </span> <span style="color: #000000;">    </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> ( (pNode </span><span style="color: #000000;">==</span><span style="color: #000000;"> </span><span style="color: #000000;">NULL</span><span style="color: #000000;">) </span><span style="color: #000000;">||</span><span style="color: #000000;"> (pNode</span><span style="color: #000000;">-></span><span style="color: #000000;">next </span><span style="color: #000000;">==</span><span style="color: #000000;"> </span><span style="color: #000000;">NULL</span><span style="color: #000000;">) ){<br /> </span> <span style="color: #000000;">        l</span><span style="color: #000000;">-></span><span style="color: #000000;">next</span><span style="color: #000000;">-></span><span style="color: #000000;">next </span><span style="color: #000000;">=</span><span style="color: #000000;"> NULL;<br /> </span> <span style="color: #000000;">        l</span><span style="color: #000000;">-></span><span style="color: #000000;">next </span><span style="color: #000000;">=</span><span style="color: #000000;"> pNode; <br /> </span> <span style="color: #000000;">        </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> pNode;<br /> </span> <span style="color: #000000;">    }<br /> </span><span style="color: #000000;"><br /> </span> <span style="color: #000000;">    LNode</span><span style="color: #000000;">*</span><span style="color: #000000;"> temp </span><span style="color: #000000;">=</span><span style="color: #000000;"> ReverseList_Recursive(pNode</span><span style="color: #000000;">-></span><span style="color: #000000;">next, l);<br /> </span> <span style="color: #000000;">    temp</span><span style="color: #000000;">-></span><span style="color: #000000;">next </span><span style="color: #000000;">=</span><span style="color: #000000;"> pNode;<br /> </span> <span style="color: #000000;">    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> pNode;<br /> </span><span style="color: #000000;">}</span></div> <br /> <br /> <img src ="http://www.aygfsteel.com/calvinlau/aggbug/279908.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/calvinlau/" target="_blank">calvinlau</a> 2009-06-03 22:47 <a href="http://www.aygfsteel.com/calvinlau/articles/279908.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>判断数组中的重复元素http://www.aygfsteel.com/calvinlau/articles/279490.htmlcalvinlaucalvinlauMon, 01 Jun 2009 17:00:00 GMThttp://www.aygfsteel.com/calvinlau/articles/279490.htmlhttp://www.aygfsteel.com/calvinlau/comments/279490.htmlhttp://www.aygfsteel.com/calvinlau/articles/279490.html#Feedback0http://www.aygfsteel.com/calvinlau/comments/commentRss/279490.htmlhttp://www.aygfsteel.com/calvinlau/services/trackbacks/279490.html
 1 void Find_Duplicate(int a[],int n){
 2 
 3     unsigned char* bitmap = new unsigned char[n];
 4     memset(bitmap,0,n);
 5     int count = 0;
 6     for(int i=0; i<n; i++){
 7         if(a[i]>|| a[i]<0)
 8             continue;
 9         else if( bitmap[a[i]] != 1)
10             bitmap[a[i]] = 1;
11         else
12             count++;
13     }
14     delete[] bitmap;
15     printf("Duplicate count: %d\n",count);
16 }



calvinlau 2009-06-02 01:00 发表评论
]]>
Q{Q数学之?pd?-- 谈谈中文分词http://www.aygfsteel.com/calvinlau/articles/278119.htmlcalvinlaucalvinlauTue, 26 May 2009 16:04:00 GMThttp://www.aygfsteel.com/calvinlau/articles/278119.htmlhttp://www.aygfsteel.com/calvinlau/comments/278119.htmlhttp://www.aygfsteel.com/calvinlau/articles/278119.html#Feedback0http://www.aygfsteel.com/calvinlau/comments/commentRss/278119.htmlhttp://www.aygfsteel.com/calvinlau/services/trackbacks/278119.html数学之美 pd?-- 谈谈中文分词 http://googlechinablog.com/2006/04/blog-post_10.html

2006q??0?上午 08:10:00

发表? 吴军Q?Google 研究?

谈谈中文分词
----- l计语言模型在中文处理中的一个应?br />
上回我们谈到利用l计语言模型q行语言处理Q由于模型是建立在词的基上的Q对于中日韩{语aQ首先需要进行分词。例如把句子 “中国航天官员应邀到美国与太空ȝv官员开会?#8221;

分成一串词Q?br /> 中国 / 航天 / 官员 / 应邀 / ?/ 国 / ?/ 太空 / ȝv / 官员 / 开会?br />
最Ҏ惛_的,也是最单的分词办法是查字典。这U方法最早是由北京航天航I大学的梁南元教授提出的?br />
?“查字?#8221; 法,其实是我们把一个句子从左向x描一遍,遇到字典里有的词标识出来,遇到复合词(比如 “上v大学”Q就找最长的词匹配,遇到不认识的字串分割成单字词,于是单的分词完成了。这U简单的分词Ҏ完全能处理上面例子中的句子。八十年代,哈工大的王晓龙博?/a>? 它理论化Q发展成最词数的分词理论Q即一句话应该分成数量最的词串。这U方法一个明昄不是当遇到有二义? Q有双重理解意思)的分割时无能ؓ力了。比如,对短?“发展中国?#8221; 正确的分割是“发展-?国家”Q而从左向x字典的办法会它分割?#8220;发展-中国-?#8221;Q显然是错了。另外,q所有的最长匹配都一定是正确的。比?#8220; 上v大学城书?#8221;的正分词应该是 “上v-大学?书店Q?#8221; 而不?“上v大学-?书店”?br />
九十q代以前Qv内外不少学者试囄一些文法规则来解决分词的二义性问题,都不是很成功?0q前后,清华大学的郭q博士用l计语言模型成功解决分词二义性问题,汉语分词的错误率降低了一个数量?br />
利用l计语言模型分词的方法,可以用几个数学公式简单概括如下:
我们假定一个句子S可以有几U分词方法,Z单v见我们假定有以下三种Q?br /> A1, A2, A3, ..., Ak,
B1, B2, B3, ..., Bm
C1, C2, C3, ..., Cn

其中QA1, A2, B1, B2, C1, C2 {等都是汉语的词。那么最好的一U分词方法应该保证分完词后这个句子出现的概率最大。也是说如?A1,A2,..., Ak 是最好的分法Q那?QP 表示概率Q:
P (A1, A2, A3, ..., AkQ??P (B1, B2, B3, ..., Bm), q且
P (A1, A2, A3, ..., AkQ??P(C1, C2, C3, ..., Cn)
因此Q只要我们利用上回提到的l计语言模型计算出每U分词后句子出现的概率,q找出其中概率最大的Q我们就能够扑ֈ最好的分词Ҏ?br />
当然Q这里面有一个实现的技巧。如果我们穷举所有可能的分词Ҏq计出每种可能性下句子的概率,那么计算量是相当大的。因此,我们可以把它看成是一?a target="_blank" >动态规?/a>QDynamic Programming) 的问题,q利?“l特?#8221;Q?a target="_blank" >Viterbi
Q?法快速地扑ֈ最佛_词?br />
在清华大学的郭进博士以后Qv内外不少学者利用统计的ҎQ进一步完善中文分词。其中值得一提的是清华大学孙茂松教授和香港科技大学吴d凯教授的工作?br />
需 要指出的是,语言学家对词语的定义不完全相同。比如说 “北京大学”Q有为是一个词Q而有分成两个词。一个折中的解决办法是在分词的同Ӟ扑ֈ复合词的嵌套l构。在上面的例子中Q如果一句话包含“ 北京大学”四个字,那么先把它当成一个四字词Q然后再q一步找出细分词 “北京” ?“大学”。这U方法是最早是郭进? “Computational Linguistics” Q《计机语言学》)杂志上发表的Q以后不系l采用这U方法?br />
一般来Ԍ? 据不同应用,汉语分词的颗_度大小应该不同。比如,在机器翻译中Q颗_度应该大一些,“北京大学”׃能被分成两个词。而在语音识别中,“北京大学”一? 是被分成两个词。因此,不同的应用,应该有不同的分词pȝ。Google 的葛昑^博士和朱安博士,专门为搜索设计和实现了自q分词pȝ?br />
? 怽想不刎ͼ中文分词的方法也被应用到p处理Q主要是手写体识别中。因为在识别手写体时Q单词之间的I格׃很清楚了。中文分词方法可以帮助判别英语单 词的边界。其实,语言处理的许多数学方法通用的和具体的语a无关。在 Google 内,我们在设计语a处理的算法时Q都会考虑它是否能很容易地适用于各U自然语a。这P我们才能有效地支持上癄语言的搜索?br />
对中文分词有兴趣的读者,可以阅读以下文献Q?br />
1. 梁南?
书面汉语自动分词pȝ
http://www.touchwrite.com/demo/LiangNanyuan-JCIP-1987.pdf

2. 郭进
l计语言模型和汉语音字{换的一些新l果
http://www.touchwrite.com/demo/GuoJin-JCIP-1993.pdf

3. 郭进
Critical Tokenization and its Properties
http://acl.ldc.upenn.edu/J/J97/J97-4004.pdf

4. 孙茂?br /> Chinese word segmentation without using lexicon and hand-crafted training data
http://portal.acm.org/citation.cfm?coll=GUIDE&dl=GUIDE&id=980775

calvinlau 2009-05-27 00:04 发表评论
]]>
Q{Q数学之?pd一 -- l计语言模型http://www.aygfsteel.com/calvinlau/articles/278118.htmlcalvinlaucalvinlauTue, 26 May 2009 16:03:00 GMThttp://www.aygfsteel.com/calvinlau/articles/278118.htmlhttp://www.aygfsteel.com/calvinlau/comments/278118.htmlhttp://www.aygfsteel.com/calvinlau/articles/278118.html#Feedback0http://www.aygfsteel.com/calvinlau/comments/commentRss/278118.htmlhttp://www.aygfsteel.com/calvinlau/services/trackbacks/278118.html数学之美 pd一 -- l计语言模型

http://googlechinablog.com/2006/04/blog-post.html


2006q???上午 08:15:00

从本周开始,我们定期刊?Google U学家吴军写的《数学之》系列文章,介绍数学在信息检索和自然语言处理中的d作用和奇妙应用?/span>

发表? 吴军, Google 研究?

前言

? 许大家不怿Q数学是解决信息索和自然语言处理的最好工兗它能非常清晰地描述q些领域的实际问题ƈ且给出漂亮的解决办法。每当h们应用数学工兯决一 个语a问题ӞM感叹数学之美。我们希望利?Google 中文黑板报这块园圎ͼ介绍一些数学工P以及我们是如何利用这些工h开? Google 产品的?br />
pd一Q?l计语言模型 (Statistical Language Models)

Google 的命是整合全球的信息,所以我们一直致力于研究如何让机器对信息、语a做最好的理解和处理。长期以来,人类一直梦想着能让机器代替人来译语言、识别语 韟뀁认识文字(不论是印刷体或手写体Q和q行量文献的自动检索,q就需要让机器理解语言。但是hcȝ语言可以说是信息里最复杂最动态的一部分。ؓ了解? q个问题Qh们容易想到的办法是让机器模拟hc进行学?- 学习人类的语法、分析语句等{。尤其是在乔姆斯基(Noam Chomsky 有史以来最伟大的语a学家Q提?“形式语言” 以后Qh们更坚定了利用语法规则的办法q行文字处理的信c遗憄是,几十q过MQ在计算机处理语a领域Q基于这个语法规则的Ҏ几乎毫无H破?

其实早在几十q前Q数学家g息论的祖师爷 香农 (Claude Shannon)提Z用数学的办法处理自然语言的想法。遗憄是当时的计算机条件根本无法满_量信息处理的需要,所以他q个x当时q没有被Z重视。七十年代初Q有了大规模集成电\的快速计机后,香农的梦x得以实现?br />
首先成功利用数学Ҏ解决自然语言处理问题的是语音和语a处理大师N克 (Fred Jelinek)。当时贾里尼克在 IBM 公司做学术休?(Sabbatical Leave)Q领g一Ҏ出的U学家利用大型计机来处理hc语a问题。统计语a模型是在那个时候提出的?br />
l大家D个例子:在很多涉及到自然语言处理的领域,如机器翻译、语韌别、印刷体或手写体识别、拼写纠错、汉字输入和文献查询中,我们都需要知道一个文字序列是否能构成一个大家能理解的句子,昄l用者。对q个问题Q我们可以用一个简单的l计模型来解册个问题?br />
? ?S 表示一q串特定序排列的词 w1Q?w2Q?#8230;Q?wn Q换句话_S 可以表示某一个由一q串特定序排练的词而组成的一个有意义的句子。现在,机器对语a的识别从某种角度来说Q就是想知道S在文本中出现的可能性,也就是数 学上所说的S 的概率用 P(S) 来表C。利用条件概率的公式QS q个序列出现的概率等于每一个词出现的概率相乘,于是P(S) 可展开为:

P(S) = P(w1)P(w2|w1)P(w3| w1 w2)…P(wn|w1 w2…wn-1)

? ?P (w1) 表示W一个词w1 出现的概率;P (w2|w1) 是在已知W一个词的前提下Q第二个词出现的概率Q以ơ类推。不隄出,C词wnQ它的出现概率取决于它前面所有词。从计算上来看,各种可能性太多,无法 实现。因此我们假定Q意一个词wi的出现概率只同它前面的词 wi-1 有关(即马可夫假设)Q于是问题就变得很简单了。现在,S 出现的概率就变ؓQ?br />
P(S) = P(w1)P(w2|w1)P(w3|w2)…P(wi|wi-1)…
(当然Q也可以假设一个词又前面N-1个词军_Q模型稍微复杂些。)

? 下来的问题就是如何估?P (wi|wi-1)。现在有了大量机L本后Q这个问题变得很单,只要C数这对词Qwi-1,wi) 在统计的文本中出C多少ơ,以及 wi-1 本n在同L文本中前后相dC多少ơ,然后用两个数一除就可以?P(wi|wi-1) = P(wi-1,wi)/ P (wi-1)?br />
也许很多Z怿用这么简单的数学模型能解军_杂的语音识别、机器翻译等问题。其实不光是思hQ就q很多语a学家都曾质疑q这U方法的有效性,但事实证明,l计语言模型比Q何已知的借助某种规则的解x法都有效。比如在 Google ?a target="_blank" >中英文自动翻?/a>中,用的最重要的就是这个统计语a模型。去q美国标准局(NIST) Ҏ有的机器译pȝq行了评,Google 的系l是不仅是全世界最好的Q而且高出所有基于规则的pȝ很多?br />
? 在,读者也许已l能感受到数学的妙之处了,它把一些复杂的问题变得如此的简单。当Ӟ真正实现一个好的统计语a模型q有许多l节问题需要解冟뀂贾里尼? 和他的同事的贡献在于提出了统计语a模型Q而且很漂亮地解决了所有的l节问题。十几年后,李开复用l计语言模型?997 词语韌别的问题化成了一?20 词的识别问题Q实C有史以来W一ơ大词汇量非特定l语音的识别?br />
我是一名科学研Ih?Q我在工作中l常惊叹于数学语a应用于解军_际问题上时的奇。我也希望把q种奇讲解l大家听。当Ӟ归根l底Q不什莫样的科学方法、无论多莫奇妙的解决手段都是Zh服务的。我希望 Google 多努力一分,用户多一分搜索的喜悦?

calvinlau 2009-05-27 00:03 发表评论
]]>
վ֩ģ壺 | | ½| ޳| ɽ| | ǫ| ϻ| | | º| | ʲ| | | ɽ| ɽ| ij| ͨ| | ɽ| ʱ| | ƽ| ɽ| ·| | | Ȫ| | | | Ϫ| | | | | | | ̨| ƾ|