Re: ASSISTANCE IN USING HUNSPELL- correction

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: ASSISTANCE IN USING HUNSPELL- correction

ge-7
Hi, Sunday,

I tried your example, I get following:
Good words:
en@gepem:~/program/hunspell-1.2.1/src/tools$ ./example /tmp/x.aff /tmp/x.dic /tmp/x.tst g
wa
we
wi
wo
wu
ewe
ewa
iwu
iwo
Bad words:
en@gepem:~/program/hunspell-1.2.1/src/tools$ ./example /tmp/x.aff /tmp/x.dic /tmp/x.tst b
dwe

That seems to be perfectly reasonable for me.
What do you think?

Regards, Eleonora

My example.cxx looks:
-------------------
#include <cstring>
#include <cstdlib>
#include <cstdio>

#include "hunspell.hxx"

extern char * mystrdup(const char * s);

using namespace std;

int
main(int argc, char** argv)
{

    char * af;
    char * df;
    char * wtc;
    char *gb;
    FILE* wtclst;

  /* first parse the command line options */
  /* arg1 - affix file, arg2 dictionary file, arg3 - file of words to check */

  if (argv[1]) {
       af = mystrdup(argv[1]);
  } else {
    fprintf(stderr,"correct syntax is:\n");
    fprintf(stderr,"example affix_file dictionary_file file_of_words_to_check g/b\n");
    exit(1);
  }
  if (argv[2]) {
       df = mystrdup(argv[2]);
  } else {
    fprintf(stderr,"correct syntax is:\n");
    fprintf(stderr,"example affix_file dictionary_file file_of_words_to_check g/b\n");
    exit(1);
  }
  if (argv[3]) {
       wtc = mystrdup(argv[3]);
  } else {
    fprintf(stderr,"correct syntax is:\n");
    fprintf(stderr,"example affix_file dictionary_file file_of_words_to_check g/b\n");
    exit(1);
  }
  if (argv[4]) {
       gb = mystrdup(argv[4]);
  } else {
    fprintf(stderr,"correct syntax is:\n");
    fprintf(stderr,"example affix_file dictionary_file file_of_words_to_check g/b\n");
    exit(1);
  }

 
  /* open the words to check list */
  wtclst = fopen(wtc,"r");
  if (!wtclst) {
    fprintf(stderr,"Error - could not open file of words to check\n");
    exit(1);
  }

   
    Hunspell * pMS= new Hunspell(af,df);
   
    int k;
    int dp;
    char buf[101];

    while(fgets(buf,100,wtclst)) {
      k = strlen(buf);
      *(buf + k - 1) = '\0';
       dp = pMS->spell(buf);
       if (dp) {
          if(gb[0] == 'g'){
            fprintf(stdout,"%s\n",buf);
          }
/*          fprintf(stdout,"\"%s\" is okay\n",buf);
          fprintf(stdout,"\n");*/
       } else {
          if(gb[0] == 'b'){
            fprintf(stdout,"%s\n",buf);
          }
/*          fprintf(stdout,"\"%s\" is incorrect!\n",buf);
          fprintf(stdout,"   suggestions:\n");
          char ** wlst;
          int ns = pMS->suggest(&wlst,buf);
          for (int i=0; i < ns; i++) {
            fprintf(stdout,"    ...\"%s\"\n",wlst[i]);
            free(wlst[i]);
          }
          fprintf(stdout,"\n");
          free(wlst);*/
       }
    }

    delete pMS;
    fclose(wtclst);
    free(wtc);
    free(df);
    free(af);

    return 0;
}

-------------------

Hi Eleonora,
                 thanks for the the explanation on hunspell. i really appreciate it.But  the problem i have now is that hunspell programe  suggests only the word in the testing dictionary, it did not generate word from affix rule for  the language i ' m building the dictionary  for. I tested it
 with English dictionary and affix files, it worked very well.Below are testing affix and  dictionary files.


TESTING AFFIX  RULE
 SET ISO8859-1
 TRY aeiouAEIOU                       

 PFX A Y 1
 PFX A   0 wi

 PFX B Y
 1
 PFX B  0 li

 SFX R N 1
 SFX R   0 ra

 SFX Z N 1
 SFX Z   0 re

 PFX D N 1
 PFX D   0 e

 PFX I N 1
 PFX I   0 i


TESTING DICT
6
wa/ARDI
we/AZDI
wi/AI
wo/ABI
wu/AZID
lo/BRZI

TESTING WORD
wa
we
wi
wo
wu
ewe
ewa
dwe
iwu
iwo

after i executing this command "example yor_NIGG.aff yor_NIGG.dic my_file.txt"  it gives

" " is not correct
   suggesting we

like this for word in dictionary file only.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]