lib378 0.2

lib378 is a library for predictive text input.
lib378 is a library for predictive text input. The API is very simple and provides dictionary autocompletion and both partial and full matching.

The project can be used to get text input from input devices with few keys (like cellphones).

Example:

#include < stdio.h >
#include < termios.h >
#include < unistd.h >

#include "378.h"

char mygetch ( void )
{
int ch;
struct termios oldt, newt;

tcgetattr ( STDIN_FILENO, &oldt );
newt = oldt;
newt.c_lflag &= ~( ICANON | ECHO );
tcsetattr ( STDIN_FILENO, TCSANOW, &newt );
ch = getchar();
tcsetattr ( STDIN_FILENO, TCSANOW, &oldt );

return ch;
}

l378_DECLARE();

l378_KEYMAP = {
['a'] = '2', ['b'] = '2', ['c'] = '2',
['d'] = '3', ['e'] = '3', ['f'] = '3',
['g'] = '4', ['h'] = '4', ['i'] = '4',
['j'] = '5', ['k'] = '5', ['l'] = '5',
['m'] = '6', ['n'] = '6', ['o'] = '6',
['p'] = '7', ['q'] = '7', ['r'] = '7', ['s'] = '7',
['t'] = '8', ['u'] = '8', ['v'] = '8',
['w'] = '9', ['x'] = '9', ['y'] = '9', ['z'] = '9'
};

static FILE* l378_dictionary;

int main( const int argc, const char *argv[] )
{
char c;
char* s = NULL;

if( !(l378_dictionary = fopen( "compressed.dict", "r" )) )
return -1;

printf( " 1 2 3n" );
printf( " C abc defnn" );
printf( " 4 5 6n" );
printf( " ghi jkl mnonn" );
printf( " 7 8 9n" );
printf( " pqrs tuv wxyznn" );
printf( " TAB 0 - n" );
printf( " auto _ nextnn" );

while( 'n' != (c = mygetch()) )
{
switch( c )
{
//case '0':
// break;
case 't':
if( (s = l378_match()) )
printf( "%sr", s );
continue;
case '-':
break;
case '1':
printf( "ttttr" );
l378_popc();
break;
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
l378_pushc( c );
break;
default:
continue;
}

if( (s = l378_matche()) )
printf( "%sr", s );
else
printf( "%sr", l378_pattern );
}

printf( "n" );

fclose( l378_dictionary );

return 0;
}

// eof

What's New in This Release:

The API was cleaned up.
The compression algorithm was improved.
Optional bz2 support was added.
The cellphone example was updated.
A sample English dictionary was added.
Minor code fixes were made.

last updated on:
June 4th, 2007, 15:35 GMT
price:
FREE!
developed by:
Massimiliano Galanti
license type:
GPL (GNU General Public License) 
category:
ROOT \ Text Editing&Processing \ Others

FREE!

In a hurry? Add it to your Download Basket!

user rating 16

UNRATED
3.4/5
 

0/5

1 Screenshot
lib378

Add your review!

SUBMIT