资源简介
世界上最全的英文本体字典,通过语义扩展和英文联想,能够查到相关词汇。类似于英英翻译。
代码片段和文件信息
/*
binsearch.c - general binary search functions
*/
#include
#include
static char *Id = “$Id: binsrch.cv 1.15 2005/02/01 16:46:43 wn Rel $“;
/* Binary search - looks for the key passed at the start of a line
in the file associated with open file descriptor fp and returns
a buffer containing the line in the file. */
#define KEY_LEN (1024)
#define LINE_LEN (1024*25)
static char line[LINE_LEN];
long last_bin_search_offset = 0;
/* General purpose binary search function to search for key as first
item on line in open file. Item is delimited by space. */
#undef getc
char *read_index(long offset FILE *fp) {
char *linep;
linep = line;
line[0] = ‘0‘;
fseek( fp offset SEEK_SET );
fgets(linep LINE_LEN fp);
return(line);
}
char *bin_search(char *searchkey FILE *fp)
{
int c;
long top mid bot diff;
char *linep key[KEY_LEN];
int length;
diff=666;
linep = line;
line[0] = ‘\0‘;
fseek(fp 0L 2);
top = 0;
bot = ftell(fp);
mid = (bot - top) / 2;
do {
fseek(fp mid - 1 0);
if(mid != 1)
while((c = getc(fp)) != ‘\n‘ && c != EOF);
last_bin_search_offset = ftell( fp );
fgets(linep LINE_LEN fp);
length = (int)(strchr(linep ‘ ‘) - linep);
strncpy(key linep length);
key[length] = ‘\0‘;
if(strcmp(key searchkey) < 0) {
top = mid;
diff = (bot - top) / 2;
mid = top + diff;
}
if(strcmp(key searchkey) > 0) {
bot = mid;
diff = (bot - top) / 2;
mid = top + diff;
}
} while((strcmp(key searchkey)) && (diff != 0));
if(!strcmp(key searchkey))
return(line);
else
return(NULL);
}
static long offset;
static int bin_search_key(char *searchkey FILE *fp)
{
int c;
long top mid bot diff;
char *linep key[KEY_LEN];
int length offset1 offset2;
/* do binary search to find correct place in file to insert line */
diff=666;
linep = line;
line[0] = ‘\0‘;
fseek(fp 0L 2);
top = 0;
bot = ftell(fp);
if (bot == 0) {
offset = 0;
return(0); /* empty file */
}
mid = (bot - top) / 2;
/* If only one line in file don‘t work through loop */
length = 0;
rewind(fp);
while((c = getc(fp)) != ‘\n‘ && c != EOF)
line[length++] = c;
if (getc(fp) == EOF) { /* only 1 line in file */
length = (int)(strchr(linep ‘ ‘) - linep);
strncpy(key linep length);
key[length] = ‘\0‘;
if(strcmp(key searchkey) > 0) {
offset = 0;
return(0); /* line with key is not found */
} else if (strcmp(key searchkey) < 0) {
offset = ftell(fp);
return(0); /* line with key is not found */
} else {
offset = 0;
return(1); /* line with key is found */
}
}
do {
fseek(fp mid - 1 0);
if(mid != 1)
while((c = getc(fp)) != ‘\n‘ && c != EOF);
offset1 = ftell(fp); /* offset at start of line */
if (fgets(linep LINE_LEN fp) != NULL) {
offset2 = ftell(fp); /* offset at start of next
- 上一篇:杭州市echarts地图显示
- 下一篇:ucguibuilder4.1
相关资源
- 赋值语句词法语法语义分析程序
- Protege 5.0.0 for mac
- BSD500数据集
- 编译原理第2版test语言 词法语法语义
- 编译原理程序小集正则表达式 NFA DF
- 编译原理词法语法语义分析程序设计
- 百度自然语言处理项目VS2017
- 编译原理课程设计布尔表达式的语法
- 语义分割源代码
- 知识图谱概念与技术.PPT 老师自己上
- 编译原理,语法分析,词法分析器,
- 小编译器 词法语法语义分析
- 编译原理课设 词法分析、语法分析、
- 人工智能,文本语义正负情感分析
- 语义网现状分析
- 编译原理语义分析实验源代码
- Jena本体操纵类(1)——本体文件读取
- 编译原理词法、语法、语义分析实验
- 《编译原理课程设计》-布尔表达式的
- 编译原理语义分析编译原理语义分析
- 布尔表达式的语法分析及语义分析程
- 编译原理__语义分析_实验报告
- 语义分析代码
- 语义分析之中文关键词提取
- tiny词法分析,语法分析,语义分析,
- 编译原理实验词法,语法,语义
- 山东大学编译原理
- zw_hello3222-8745847-语义分析及中间代码
- 编译原理词法分析+SLR语法分析+SLR语义
- 词法,语法,语义分析源程序
评论
共有 条评论