Index: app/src/gue/Makefile
===================================================================
--- app/src/gue/Makefile	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
+++ app/src/gue/Makefile	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
@@ -0,0 +1,42 @@
+PAR=-Wno-deprecated -O3 -fpermissive -static
+PAR2=-c -Wno-deprecated -O3 -fpermissive
+LIB_PATH=../lib
+COMMON_PATH=../common
+CMDLINE_FILE='"../gue/cmdline.h"'
+
+
+gue: main.cc guess.o $(LIB_PATH)/auttools.o $(LIB_PATH)/word.o \
+      cmdline.c common_guess.o common.o
+	g++ $(PAR) main.cc guess.o \
+	$(LIB_PATH)/auttools.o $(LIB_PATH)/word.o cmdline.c common.o common_guess.o \
+	-o gue
+
+guess.o: guess.h guess.cc
+	g++ $(PAR2) guess.cc
+
+common_guess.o: cmdline.h  common_guess.cc common_guess.h
+	g++ $(PAR2) common_guess.cc
+
+common.o: $(COMMON_PATH)/cmdline_common.ggo $(COMMON_PATH)/common.cc \
+	 $(COMMON_PATH)/common.h
+	g++ $(PAR2) -D _CMDLINE_FILE=$(CMDLINE_FILE) $(COMMON_PATH)/common.cc
+
+cmdline.c cmdline.h: cmdline.ggo
+	gengetopt -i cmdline.ggo --conf-parser
+
+cmdline.ggo: cmdline_guess.ggo ../common/cmdline_common.ggo
+	cat cmdline_guess.ggo ../common/cmdline_common.ggo > cmdline.ggo
+
+
+clean: clean.cmdline
+	rm *.o || true
+	rm gue || true
+
+
+clean.cmdline:
+	rm cmdline.* || true
+
+copy:
+ifdef UTT_BIN_DIR
+	cp gue ${UTT_BIN_DIR}
+endif
Index: app/src/gue/cmdline_guess.ggo
===================================================================
--- app/src/gue/cmdline_guess.ggo	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
+++ app/src/gue/cmdline_guess.ggo	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
@@ -0,0 +1,12 @@
+package "guess"
+version "0.1"
+
+option "guess_count"		n	"Guess up to n descriptions" int default="0" no
+option "delta"			-	"Stop displaying answers after fall of weight" float default="0.2" no
+option "cut-off"		-	"Do not display answers with less weight than cut-off" int default="200" no
+option "dictionary-home"	-	"dh" hidden
+option "dictionary"		d	"File with dictionary information" string typestr="filename" default="~/.utt/lang/pl_PL.ISO-8859-2/gue.bin" no
+option "per-info"		v	"Display performance information" flag off
+option "weights"		w	"Print weights" flag off hidden
+option "no-uppercase"		-	"Do not process form containing uppercase letters" flag off
+
Index: app/src/gue/common_guess.cc
===================================================================
--- app/src/gue/common_guess.cc	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
+++ app/src/gue/common_guess.cc	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
@@ -0,0 +1,50 @@
+#include <stdlib.h>
+#include <string.h>
+#include "common_guess.h"
+
+int guess_count=0;
+double delta=0.1;
+int cut_off=100;
+char dictionary[255];
+bool per_info=false;
+bool weights=true;
+
+void process_guess_options(gengetopt_args_info* args)
+{
+
+  if(args->dictionary_given)
+    {
+      expand_path(args->dictionary_arg,dictionary);
+    }
+  else if (args->dictionary_home_given && args->language_given)
+    {
+      char buf[255];
+      expand_path(args->dictionary_home_arg, buf);
+      sprintf(dictionary,"%s/%s/lem.bin",buf,args->language_arg);
+    }
+
+  if(args->guess_count_given)
+    guess_count=args->guess_count_arg;
+  else
+    guess_count=0;
+
+  if(guess_count==0)
+    guess_count=100;
+
+  if(args->delta_given)
+    delta=args->delta_arg;
+  else
+    delta=0.1;
+
+  if(args->cut_off_given)
+    cut_off=args->cut_off_arg;
+  else
+    cut_off=100;
+
+  if(args->per_info_given)
+    per_info=args->per_info_flag;
+
+  if(args->weights_given)
+    weights=false;
+
+}
Index: app/src/gue/common_guess.h
===================================================================
--- app/src/gue/common_guess.h	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
+++ app/src/gue/common_guess.h	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
@@ -0,0 +1,20 @@
+#ifndef __COMMON_GUESS_H
+#define __COMMON_GUESS_H
+
+#include <stdio.h>
+#define _CMDLINE_FILE "../gue/cmdline.h"
+#include "../common/common.h"
+#include "cmdline.h"
+
+#define DIC_FILE "gue.bin"
+
+extern int guess_count;
+extern double delta;
+extern int cut_off;
+extern char dictionary[];
+extern bool per_info;
+extern bool weights;
+
+void process_guess_options(gengetopt_args_info* args);
+
+#endif
Index: app/src/gue/guess.cc
===================================================================
--- app/src/gue/guess.cc	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
+++ app/src/gue/guess.cc	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
@@ -0,0 +1,138 @@
+
+#include "guess.h"
+
+#include <string.h>
+#include <iostream.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <time.h>
+
+#define DICT 1
+#define COR 2
+#define DICT_P 3
+#define COR_P 4
+
+#define W_PRE 0.1
+#define W_SUF 0.9
+
+#define PREF_SIGN '_'
+
+Guess::Guess(const char* suf_file)
+  : _suf(suf_file) {
+  /*  _suf = NULL;
+  _pref = NULL;
+
+   if (strlen(suf_file) > 0)
+    _suf = new TFTiv<char, char>(suf_file);
+  if (strlen(pref_file) > 0)
+    _pref = new TFTiv<char, char>(corp_file);
+  */
+}
+
+
+  char buf[MAX_LINE];
+  char out[MAX_LINE];
+  char* buf0_s = buf;
+  char* word_t = NULL;
+  long state_s = 0;
+  unsigned length_s = buf0_s - buf;
+  long len = 0;
+  int i=0;
+
+int Guess::ana(const char* word, Words& result) {
+
+  assert(word && &result);
+
+  /* Word zawiera wyraz, ktory mamy zbadac.
+   * Nalezy przepisac go w odwrotnej kolejnosci do bufora,
+   * znalezc najdluzszy prefiks pasujacy do tego bufora
+   * separatorem jest '/' - za tym znakiem znajduje sie
+   * prawdopodobienstwo wystapienia danego opisu */
+
+  buf0_s = buf;
+  word_t = strdup(word);
+
+  if (reverse(word, buf) != 0)
+    return -1;
+
+ 
+
+  state_s = -1;
+  //  printf("#buf0_s=%s, ", buf0_s);
+  state_s = _suf.pref(buf0_s, PREF_SIGN);
+  //  printf("#word=%s, buf0_s=%s\t", word, buf0_s);
+  /* jezeli state_s != -1 to oznacza, ze w slowniku jest zawarta
+   * informacja o prefiksie tego slowa.
+   * nie jest ona odwrocona, wiec porownujemy do word a nie do buf
+   */
+  //  printf("state_s=%d\t", state_s);
+  if (state_s != -1) {
+    state_s = _suf.pref(word_t, '~', state_s);
+    //    printf("state_s(wp)=%d, word_t=%s, word=%s\n", state_s, word_t, word);
+  }
+  if (state_s == -1) {
+  //  if (_suf != NULL) 
+    buf0_s = buf;
+    state_s = _suf.pref(buf0_s, '~');
+    //    printf("state_s=%d\n", state_s);
+  }
+
+  length_s = buf0_s - buf;
+ 
+  /* state jest stanem, od ktorego zaczyna sie sciezka opisujaca
+   * prawdopodobienstwo przeciwienstwa wystapienia opisu
+   * znajdujacego sie dalej na tej sciezce.
+   * Im mniejsza wartosc liczby tym wieksze prawdopodobienstwo */
+
+  len = 0;
+  i=0;
+  
+  //  if (_suf != NULL)
+    len = _suf.cont(state_s, out);
+  while (len > 0) {
+    i++;
+    add_word_prob(result, word, out, length_s, DICT);
+    len = _suf.cont(-1, out);
+  }
+    
+  return i;
+
+}
+
+
+int Guess::add_word_prob(Words& tab, const char* word, const char* path, unsigned len, int source) {
+
+  /* Dodaje do tablicy tab wyraz word wraz
+   * z prawdopodobienstwem i opisem zawartym
+   * w sciezce path */
+
+  //  printf("add_word_prob(");
+  //  fflush(stdout);
+  char p[MAX_LINE];
+
+  strcpy(p, path);
+
+  int probLen = strcspn(p, ";");
+  char prob[probLen+1];
+  strncpy(prob, p, probLen);
+  prob[probLen] = '\0';
+
+  char* desc = p + probLen+1; // +2 bo pomijamy jeszcze znak ';'
+
+  int i = tab.add(word, desc);
+
+  if (source==DICT) {
+    tab[i].len_suf(len);
+    tab[i].w_suf(atof(prob)); // + W_PRE*tab[i].w_suf()));
+    //    tab[i].w_suf((float)(W_SUF*(1000-atof(prob)) + W_PRE*tab[i].w_suf()));
+  }
+//   if (source==COR) {
+//     tab[i].len_pref(len);
+//     tab[i].w_pref(W_SUF*(1000-atof(prob)) + W_PRE*tab[i].w_pref());
+//   }
+//   printf(")\n");
+//   fflush(stdout);
+
+  return i;
+
+}
Index: app/src/gue/guess.h
===================================================================
--- app/src/gue/guess.h	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
+++ app/src/gue/guess.h	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
@@ -0,0 +1,56 @@
+
+#include "../lib/tfti.h"
+#include "../lib/word.h"
+
+#include <sys/timeb.h>
+
+/**************************************************************
+ * Zawiera definicje klasy Guess.                              *
+ *                                                            *
+ * Klasa ta pozwala na okreslenie opisu slowa nie             *
+ * znajdujacego sie w slowniku wraz z prawdopodobienstwem     *
+ * jego wystapienia.                                          *
+ *************************************************************/
+
+class Guess {
+
+ public:
+
+  // nazawa pliku slownika w parametrze
+  Guess(const char* suf_file);
+
+  // zwraca tablice opisow slowa wraz z prawdopodobienstwem ich wystapienia
+  int ana(const char* word, Words& result);
+
+  long time_overall;
+
+ private:
+
+  // sufiksy
+  TFTiv<char, char> _suf;
+
+  // prefiksy
+  TFTiv<char, char> _pref;
+
+  //odwraca ciag znakow
+  int reverse(const char* src, char* dest) {
+ 
+  //  assert((src != NULL) && (dest != NULL));
+
+    const char* c = src;
+  
+    int len = strlen(src);
+
+    for (int i=1; i<=len; ++i) {
+      dest[i-1] = src[len-i];
+    }
+
+    dest[len] = '\0';
+
+    return 0;
+  }
+
+  //dodaje nowy element do tablicy WordsProb
+  int add_word_prob(Words& tab, const char* word, const char* path, unsigned len, int source);
+
+};
Index: app/src/gue/main.cc
===================================================================
--- app/src/gue/main.cc	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
+++ app/src/gue/main.cc	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
@@ -0,0 +1,192 @@
+#include <time.h>
+#include <stdlib.h>
+#include "../lib/iotools.h"
+#define _CMDLINE_FILE "../gue/cmdline.h"
+#define CONFIGFILE1 "/home/ynka/utt/utt-0.9/conf/gue.conf"
+#define CONFIGFILE2 "/home/ynka/utt/utt-0.9/conf/gue.conf"
+#include "../common/common.h"
+#include "common_guess.h"
+#include "guess.h"
+#include "cmdline.h"
+
+#define W_SUFF 0.6
+#define W_PREF 0.4
+
+int main(int argc, char** argv) {
+
+  int non_standard_config=0;
+
+  gengetopt_args_info args;
+
+  if(cmdline_parser(argc, argv, &args) != 0)
+    exit(1);
+
+  process_config_files(&args,argv[0]);
+
+  process_common_options(&args,argv[0]);
+  process_guess_options(&args);
+
+
+  // PONIÅ»EJ POPRZEDNI KOD (JUSTYNY)
+// //preliminary command-line parsing - for configuration file info only
+//   gengetopt_args_info pre_args;
+
+//   if (cmdline_parser(argc, argv, &pre_args) != 0)
+//     	exit(1);
+//   if(pre_args.config_given){
+// 	printf("podano config: %s\n",pre_args.config_arg);
+// 	non_standard_config=1;
+//   }
+  
+
+// //configuration file 1 parsing
+// 	struct cmdline_parser_params *params;	
+// 	params = cmdline_parser_params_init();
+// 	params->initialize = 1;
+// 	if(cmdline_parser_config_file(CONFIGFILE1,&args, params)!=0){
+// 		printf("System-wide configuration file parsing error!\n");		
+// 		exit(1);
+// 	}  
+
+// //configuration file 2 parsing-overriding
+// 	params->initialize=0;
+// 	params->override=1;
+// 	char* config2=(non_standard_config)?pre_args.config_arg:CONFIGFILE2;
+// 	if(cmdline_parser_config_file(config2,&args, params)!=0){
+// 		printf("User configuration file parsing error!\n");		
+// 		return 1;
+// 	}
+
+// 	params->initialize=0;
+// 	params->override=1;
+// 	//params->check_required=1;
+	
+// 	free(params);
+
+// //command-line options parsing-overriding
+//   if (cmdline_parser(argc, argv, &args) != 0)
+//     exit(1);
+
+
+  char line[MAX_LINE];
+  char outline[MAX_LINE];
+  char parms[MAX_LINE], desc[MAX_LINE], lemma[MAX_LINE];
+  long line_count = 0;
+  //  printf("d_f=%s\n", dict_file);
+  Guess guess(dictionary);
+  int words_count=0;
+  time_t start_time = time(NULL);
+
+  Segment seg;
+  Words tab;
+  char* form; //[MAX_FORM];
+  while (fgets(line, MAX_LINE, inputf)==line) {
+    line_count++;
+    int start, len;
+
+    line[strlen(line)-1] = '\0';
+
+    if (!seg.parse(line)) {
+      fprintf(stderr, "BÂ³Â±d w wejÂ¶ciu (linia: %d)\n", line_count);
+      return -1;
+    }
+
+    if (process_seg(seg, args)) {
+      words_count++;
+      tab.clear();
+      if (args.input_field_given>0) {
+	form = getInput(args.input_field_arg, args.input_field_given, seg);
+      } else
+	form = seg.form;
+
+      if (NULL == form) {
+	continue;
+      }
+
+      guess.ana(form, tab);
+
+      if ((tab.count()==0) && (!args.no_fail_flag)) {
+	// no guesses - analysis was unsuccessful
+	seg.print(outline); //this is necessary - seg.parse destroys line...
+	fputs(outline, failedf);
+ 	if (copy_processed)
+ 	  fputs(line, stdout);
+	continue;
+      }
+      // we've got some guesses. Do we want to print it?
+      if (args.only_fail_flag)
+	continue;
+
+      float last_weight=0;
+      int i=0;
+      int count=0;
+      unsigned first=1;
+      char* parms_end = parms;
+      char last_lemma[MAX_LINE];
+
+      while ((i=tab.next()) != -1 && count++<guess_count) {
+	/* if we have "one-line" flag then everything goes in one segment as many fields,
+	 * if we have "one-field" flag everything goes in one segment as ONE field:
+	 * - diferent lemmas are separated with ';', sequent descriptions to one lemma
+	 *   are separated with ','
+	 */
+	if ((!first) && (tab[i].w_suf() < cut_off) || (tab[i].w_suf() < delta * last_weight)) {
+       	  break;
+	}
+	if (first) {
+	  parms_end += sprintf(parms_end, "%s", field_prefix);
+	} else if (!args.one_field_flag)
+	  parms_end += sprintf(parms_end, "%s", field_prefix);
+
+	if (!args.one_field_flag || strcmp(last_lemma, tab[i].lemma()) != 0) {
+          if (args.one_field_flag && !first)
+            parms_end += sprintf(parms_end, ";");
+          parms_end += sprintf(parms_end, "%s", tab[i].lemma());
+          strcpy(last_lemma, tab[i].lemma());
+        }
+
+	first=0;
+
+	last_weight = tab[i].w_suf();
+	if (!weights)
+	  parms_end += sprintf(parms_end, ",%s:%d",  tab[i].descr(), (int)tab[i].w_suf());
+	else
+	  parms_end += sprintf(parms_end, ",%s", tab[i].descr());
+
+	if (!args.one_field_flag) {
+	  seg.addfield(parms);
+	  parms_end = parms;
+	}
+	
+	if (!(args.one_field_flag || args.one_line_flag)) {
+	  seg.print(outline);
+	  fputs(outline, outputf);
+	  --seg.auxn;
+	}
+ 	//if (copy_processed)
+ 	//  fputs(outline, stdout);
+      } //while
+
+      if (args.one_field_flag)
+	seg.addfield(parms);
+
+      if (args.one_field_flag || args.one_line_flag){
+	seg.print(outline);
+	fputs(outline, outputf);
+      }
+    } else { // if (process_segment)
+      // jak to nie jest wyraz - to przepisz token na wyjscie.
+      //      printtok(line, start, len, cat, form);
+      seg.print(outline);
+      fputs(outline, outputf);
+      if (copy_processed)
+ 	fputs(outline, stdout);
+    }
+  }
+  time_t end_time = time(NULL);
+  if (per_info) {
+    printf("Liczba sÂ³Ã³w: %d\n", words_count);
+    printf("Czas analizy: %d sekund\n", end_time-start_time);
+  }
+  cmdline_parser_free(&args);
+}
