MCPcopy Create free account
hub / github.com/buggins/coolreader / main

Function main

tinydict/tinydict.cpp:944–1002  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

942
943#ifdef TEST_APP
944int main( int argc, const char * * argv )
945{
946 TinyDictIndexFile index;
947 TinyDictDataFile data;
948 TinyDictDataFile zdata;
949 if ( !index.open("mueller7.index") ) {
950 printf("cannot open index file mueller7.index\n");
951 return -1;
952 }
953 if ( !data.open("mueller7.dict") ) {
954 printf("cannot open data file mueller7.dict\n");
955 return -1;
956 }
957 if ( !zdata.open("mueller7.dict.dz") ) {
958 printf("cannot open data file mueller7.dict.dz\n");
959 return -1;
960 }
961 TinyDictWordList words;
962 const char * pattern = "full";
963 index.find( pattern, true, words );
964 printf( "%d words matched pattern %s\n", words.length(), pattern );
965 for ( int i=0; i<words.length(); i++ ) {
966 TinyDictWord * p = words.get(i);
967 printf("%s %d %d\n", p->getWord(), p->getStart(), p->getSize() );
968 const char * text = zdata.read( p );
969 if ( text )
970 printf( "article:\n%s\n", text );
971 else
972 printf( "cannot read article\n" );
973 }
974
975 {
976 // create TinyDictionaryList object
977 TinyDictionaryList dicts;
978 // register dictionaries using
979 dicts.add( "mueller7.index", "mueller7.dict.dz" );
980
981 // container for results
982 TinyDictResultList results;
983 dicts.find(results, "empty", 0 ); // find exact match
984
985 // for each source dictionary that matches pattern
986 for ( int d = 0; d<results.length(); d++ ) {
987 TinyDictWordList * words = results.get(d);
988 printf("dict: %s\n", words->getDictionaryName() );
989 // for each found word
990 for ( int i=0; i<words->length(); i++ ) {
991 TinyDictWord * word = words->get(i);
992 printf("word: %s\n", word->getWord() );
993 printf("article: %s\n", words->getArticle( i ) );
994 }
995 }
996 }
997#ifdef _WIN32
998 printf("Press any key...");
999 getchar();
1000#endif
1001 return 0;

Callers

nothing calls this directly

Calls 11

getDictionaryNameMethod · 0.80
getArticleMethod · 0.80
openMethod · 0.45
findMethod · 0.45
lengthMethod · 0.45
getMethod · 0.45
getWordMethod · 0.45
getStartMethod · 0.45
getSizeMethod · 0.45
readMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected