1 // Copyright (C) 2005 Universitat d'Alacant / Universidad de Alicante 2 // 3 // This program is free software; you can redistribute it and/or 4 // modify it under the terms of the GNU General Public License as 5 // published by the Free Software Foundation; either version 2 of the 6 // License, or (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, but 9 // WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 // General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program; if not, see <http://www.gnu.org/licenses/>. 15 16 #ifndef TAGGER_H 17 #define TAGGER_H 18 19 #include "apertium_config.h" 20 21 #include "basic_stream_tagger.h" 22 #include "basic_stream_tagger_trainer.h" 23 #include "basic_tagger.h" 24 #include "constructor_eq_delete.h" 25 #include "err_exception.h" 26 #include "file_tagger.h" 27 #include "optional.h" 28 #include <apertium/file_morpho_stream.h> 29 30 #include "getopt_long.h" 31 #include <string> 32 33 namespace Apertium { 34 class apertium_tagger : private constructor_eq_delete { 35 public: 36 apertium_tagger(int &argc, char **&argv); 37 38 private: 39 enum FunctionTypeType { Unigram, SlidingWindow, Perceptron }; 40 enum UnigramType { Stream_5_3_1, Stream_5_3_2, Stream_5_3_3 }; 41 enum FunctionType { Tagger, Retrain, Supervised, Train }; 42 static void help(); 43 static const struct option longopts[]; 44 45 static std::string option_string(const int &indexptr_); 46 static std::string option_string(const struct option &option_); 47 static void locale_global_(); 48 void set_indexptr(); 49 void flagOptionCase(bool (basic_Tagger::Flags::*GetFlag)(), 50 void (basic_Tagger::Flags::*SetFlag)(const bool &)); 51 std::string option_string(); 52 void functionTypeTypeOptionCase(const FunctionTypeType &FunctionTypeType_); 53 void functionTypeOptionCase(const FunctionType &FunctionType_); 54 void getCgAugmentedModeArgument(); 55 void getIterationsArgument(); 56 unsigned long optarg_unsigned_long(const char *metavar); 57 void get_file_arguments( 58 bool get_crp_fn, 59 char **DicFn, char **CrpFn, 60 char **TaggedFn, char **UntaggedFn, 61 char **TsxFn, char **ProbFn); 62 void init_FILE_Tagger(FILE_Tagger &FILE_Tagger_, string const &TsxFn); 63 64 MorphoStream* setup_untagged_morpho_stream( 65 FILE_Tagger &FILE_Tagger_, 66 char *DicFn, char *UntaggedFn, 67 FILE **Dictionary, FILE **UntaggedCorpus); 68 void close_untagged_files( 69 char *DicFn, char *UntaggedFn, 70 FILE *Dictionary, FILE *UntaggedCorpus); 71 72 void g_StreamTagger(StreamTagger &StreamTagger_); 73 void s_StreamTaggerTrainer(StreamTaggerTrainer &StreamTaggerTrainer_); 74 void g_FILE_Tagger(FILE_Tagger &FILE_Tagger_); 75 void r_FILE_Tagger(FILE_Tagger &FILE_Tagger_); 76 void s_FILE_Tagger(FILE_Tagger &FILE_Tagger_); 77 void t_FILE_Tagger(FILE_Tagger &FILE_Tagger_); 78 void c_FILE_Tagger(FILE_Tagger &FILE_Tagger_); 79 int &argc; 80 char **&argv; 81 int The_val; 82 int nonoptarg; 83 84 85 int The_indexptr; 86 Optional<int> FunctionTypeTypeOption_indexptr; 87 Optional<int> FunctionTypeOption_indexptr; 88 89 90 Optional<FunctionTypeType> TheFunctionTypeType; 91 Optional<UnigramType> TheUnigramType; 92 Optional<FunctionType> TheFunctionType; 93 unsigned long TheFunctionTypeOptionArgument; 94 unsigned long CgAugmentedMode; 95 basic_Tagger::Flags TheFlags; 96 }; 97 } 98 99 #endif // TAGGER_H 100