用C语言将搜狗输入法词库转换成QQ拼音输入法词库

搜狗输入法词库格式:

'ni'kan'xia 你看下
'ni'kan'xia'gai'hou 你看下改后
'ni'kan'xing'ma 你看行吗
'ni'kan'zen'me'yang 你看怎么样
'ni'kan'zhe 你看着
'ni'kan'zhe'ban 你看着办
'ni'kan'zhe'jiu'xing 你看着就行
'ni'kao'bu'kao 你考不考
'ni'kao'de 你考得
'ni'kao'wan 你考完
'ni'kao'yan 你考研
'ni'kao'yan'ma 你考研吗

QQ拼音输入法词库格式:

nong'hao'le'fa'gei'ni 弄好了发给你 1, nong'hao'le'fa'gei'ni 1
nong'huai'le 弄坏了 1, nong'huai'le 1
nong'hui'lai'le 弄回来了 1, nong'hui'lai'le 1
nong'lai 弄来 1, nong'lai 1
nong'le 弄了 1, nong'le 1
nong'le'yi'tian 弄了一天 1, nong'le'yi'tian 1
nong'le'yi'xia 弄了一下 1, nong'le'yi'xia 1
nong'mei 浓眉 1, nong'mei 1
nong'mi 浓密 1, nong'mi 1
nong'min 农民 1, nong'min 1
nong'ming'bai 弄明白 1, nong'ming'bai 1

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXLINE 100000
#define BUFLEN 10240
int main()
{
FILE *file,*fw;
fw = fopen("b.txt","a");//以追加方式写入
char buf[BUFLEN];
int len=,i=,j;
char *array[MAXLINE]; file=fopen("a.txt","r");
if(!file)
return -;
while(fgets(buf,BUFLEN,file))
{
len=strlen(buf);
array[i]=(char*)malloc(len+);
if(!array[i])
break;
strcpy(array[i++],buf);
putchar('\n');
}
int first=;
fclose(file);
i--;
while(i>=&&array[i])
{
first=;
printf("%s\n",array[i]);
for(j=;array[i][j+]!='\0';j++)
{
if(first==&&array[i][j]=='\'')
{
first=;
}
else
{
fprintf(fw,"%c",array[i][j]);
}
}
first=;
fprintf(fw," 1, ");
for(j=;array[i][j+]!='\0';j++)
{
if(first==&&array[i][j]=='\'')
{
first=;
}
else
{ if (array[i][j]==||(array[i][j]>=&&array[i][j]<=))
{
fprintf(fw,"%c",array[i][j]);
}
}
}
fprintf(fw," 1\n");
free(array[i--]);
first=;
}
}

本文出自 “阿凡达” 博客,请务必保留此出处http://shamrock.blog.51cto.com/2079212/702510

上一篇:Index Generation


下一篇:PHPNG (next generation)