lib378 0.2

lib378 is a library for predictive text input.
LICENSE TYPE:
GPL (GNU General Public License) 
USER RATING:
3.4/5 16
DEVELOPED BY:
Massimiliano Galanti
HOMEPAGE:
lib378.sourceforge.net
CATEGORY:
ROOT \ Text Editing&Processing \ Others
1 lib378 Screenshot:
lib378
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

#predictive text input #dictionary autocompletion #embeddable text library #lib378 #predictive #text #input

  Add it to your Download Basket!

 Add it to your Watch List!

0/5

Rate it!
send us
an update

Add your review!

SUBMIT