⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blind_ime_more.h

📁 it is about embeded system
💻 H
📖 第 1 页 / 共 2 页
字号:
/*	blind_ime.h	080907	BY 吴文腾        080929        Modify by StevenZ*/#ifndef _BLIND_IME_H#define	_BLIND_IME_H#include "create.h"#include <string.h>#define MAXFIELD 20#define MAXLINE  50/*区域判断所需宏*/#define BIME_MAXX	3400 #define BIME_MAXY	3600#define BIME_MINX	240#define BIME_MINY	450#define BIME_MXA    	(BIME_MINX+(BIME_MAXX-BIME_MINX)/2)/*触摸屏返回值结构体*/typedef struct{	unsigned short pressure;/*0:松开 1:首次按下 2:按住*/	unsigned short x;	unsigned short y;	unsigned short pad;}BIME_TS_RET;typedef struct index{       char syllable[MAXFIELD];                /* 拼音 */       char sequence[MAXFIELD];               /* 同音字起始序列号 */       char character[MAXFIELD];               /* 汉字(存放最后输入的汉字) */}INDEX;typedef struct words{                char sequence[MAXFIELD];               /* 同音字起始序列号 */       char character[MAXFIELD];               /* 汉字 */       int  freq;                              /* 字频 */       char phrase[MAXLINE];                  /* 词组 */}WORDS;struct cha{            char sequence[MAXFIELD];                 /* 同音字起始序列号 */      char character[MAXFIELD];                 /* 汉字 */       char phrase[MAXLINE];                    /* 词组 */      int   freq;                               /* 字频 */      struct cha * link;};typedef struct blind{        char array[MAXFIELD];                    /* 统计序列 */        char syllable[MAXLINE];                  /* 拼音(one or two) */  }BLIND;/************************/STOCK_DBS my_stock;char  * array;                       //接收触摸屏程序的字符串struct cha * first;            //同音字链表首址char  character[MAXFIELD];          //存放当前被选择的汉字或词组struct cha * cur;                   //指向语音当前所读的汉字                /************************/int  find_input_files(char *,char *,char *);int  get_words_record(STOCK_DBS *, const char *, FILE *, char *);void get_index_record(STOCK_DBS * , const char * , FILE *, char *,char *);void get_blind_record(STOCK_DBS * , const char * , FILE *, char *,char *);int  database_get(STOCK_DBS * , const char * , FILE * );void display(WORDS);              void  freq_change( STOCK_DBS *, char *);/*[语音识别]或触摸控制判断是否选择左或右,选左返回1,否则返回0*/static int bime_left_or_right(){	int ts_fd;	BIME_TS_RET ts_ret;	ts_fd=open("/dev/touchscreen/0raw",O_RDONLY);	if(ts_fd<0)	{		printf("open device error!!");		exit(1);	}	do{		read(ts_fd,&ts_ret,1);	}while(ts_ret.pressure);	close(ts_fd);	if(ts_ret.x<BIME_MXA)	{		return 1;	}	return 0;}//**根据字符串序列检索得到拼音**void get_blind_record(STOCK_DBS *my_stock , const char *program_name ,                      FILE *error_file_pointer, char * array, char *cret){  int ret,i,flg;   char array_cp[16];   char c,t2s_str[300];  char * syllable;  char * str1, *str2;  DBC * cursor_blind;  DBT  key,data;  BLIND my_blind;  strcpy( array_cp, array );                      //将array的值赋给数组seq,保证其稳定性   memset(&my_blind, 0, sizeof(BLIND));  memset(&key, 0, sizeof(DBT));  memset(&data, 0, sizeof(DBT));  ret = my_stock->sta_dbp->cursor( my_stock->sta_dbp, NULL, &cursor_blind, 0);  print_error(ret);   key.data = array_cp ;               key.size = strlen( array_cp ) +1 ;  ret = cursor_blind->get( cursor_blind, &key, &data, DB_SET_RANGE ) ;    print_error( ret );  data.data = &my_blind;  data.size = sizeof( my_blind );  data.ulen = sizeof( BLIND );  data.flags = DB_DBT_USERMEM;   ret = cursor_blind->get( cursor_blind, &key, &data, DB_CURRENT ) ;    print_error( ret );  printf("\t字符串:%s", my_blind.array);  printf("\t拼音:%s\n", my_blind.syllable);   str1 = my_blind.syllable ;   flg=0;  for(i=0; i<strlen(str1); i++)  {       if( isdigit( my_blind.syllable[i] ) != 0 )     	{     		flg=1;	 	break;     	}  }  if(flg)  	{  		str1[i]='\0';                                   //截取第一个拼音		printf( "拼音1:%s\n", str1);  		str2 = &my_blind.syllable[i+1] ;                 //截取第二个拼音  		printf( "拼音2:%s\n", str2);				if( cursor_blind != NULL)    		   	cursor_blind->close(cursor_blind); 				sprintf(t2s_str,",[i1],请再选择拼音,左:%s1,右:%s1,[i0],",str1,str2);		printf("t2s_str=%s\n",t2s_str);		T2S_t2s(t2s_str);		//c = speech(0x01);		if( bime_left_or_right()) 		{			strcpy(cret,str1);		}		else strcpy(cret,str2);  	}  else  	{		printf("no slection!!!\n");  		strcpy(cret,str1);  	}}/*  根据拼音查找并显示拼音字库索引表记录, 并返回同音字起始序列号  */void get_index_record(STOCK_DBS *my_stock , const char *program_name,                      FILE *error_file_pointer, char * input,char *cret){  int ret;   char * sequence;  DBC * cursor_index;  DBT  key,data;  INDEX my_index;  /* 创建数据库游标 */  ret = my_stock->words_index_dbp->cursor( my_stock->words_index_dbp, NULL, &cursor_index, 0);  print_error(ret);  memset(&my_index, 0, sizeof(INDEX));  memset(&key, 0, sizeof(DBT));  memset(&data, 0, sizeof(DBT));  key.data = input;                                        //关键字赋值  key.size = strlen(input) + 1;  ret = cursor_index->get( cursor_index, &key, &data, DB_SET);  //get函数根据关键字进行游标查询数据库  print_error(ret);  data.data = &my_index;         data.ulen = sizeof(INDEX);  data.flags = DB_DBT_USERMEM;   ret = cursor_index->get( cursor_index, &key, &data, DB_CURRENT);  //游标定位  print_error(ret);    sequence = my_index.sequence;  strcpy(cret,sequence);  //printf("***********拼音字库索引表*********\n");  printf("\t拼音;%s\n", my_index.syllable);  printf("\t起始序列号:%s\n", my_index.sequence);  printf("\t最近输入的汉字:%s\n", my_index.character);  if( cursor_index != NULL)    cursor_index->close(cursor_index);                    //同音字起始序列号为返回值}char  last_character[4];               //存放最后输入的汉字char  last_phrase[MAXFIELD];         //存放最后输入的汉字的词组/* 将检索到的同音字按字频排序,并返回链表的头指针 */#define LEN sizeof( struct cha )void display( WORDS my_words ){  struct cha *prt, *next;  struct cha *newnode;   newnode = (struct cha *)malloc(LEN);          //创建新结点  if( !newnode) exit(1);                   strcpy(newnode->sequence, my_words.sequence);  //为新结点赋值  strcpy(newnode->character, my_words.character);  strcpy(newnode->phrase, my_words.phrase);   newnode->freq = my_words.freq;  newnode->link = NULL;  if(first == NULL)                            //链表为空时  {     // newnode->link =first;      first = newnode;      }  else  {          if( newnode->freq >= first->freq )       //新结点字频大于等于链表头结点的字频时          {            newnode->link = first;            first = newnode;                                                 }         else                                //新结点字频小于链表头结点的字频时           {                      prt = next = first;             while( newnode->freq <= next->freq && next->link != NULL)               {                 prt = next;                 next = next ->link;                       }             if(newnode->freq <= next->freq)                 {                  next->link = newnode;                 }              else               {                 prt->link = newnode;                 newnode->link = next;               }                       }   }}void get_first_phrase(char *s_tmp,char *phrase){  int i=0;  while(phrase[i]!=','&&phrase[i]!='\0')  {    s_tmp[i]=phrase[i];    i++;  }  s_tmp[i]='\0';}void * display_th(void * data)              //语音读同音字链表线程{  char s_tmp[20];//  T2S_option( FEMALE, 1, 1 );            //调用语音函数读出汉字  //T2S_t2s("由同音字词语选汉字");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -