FreeLing
4.0
|
00001 00002 // 00003 // Copyright (C) 2014 TALP Research Center 00004 // Universitat Politecnica de Catalunya 00005 // 00006 // This library is free software; you can redistribute it and/or 00007 // modify it under the terms of the GNU Affero General Public License 00008 // (GNU AGPL) as published by the Free Software Foundation; either 00009 // version 3 of the License, or (at your option) any later version. 00010 // 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 // Affero General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Affero General Public License 00017 // along with this library; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 // 00020 // contact: Muntsa Padro (mpadro@lsi.upc.edu) 00021 // TALP Research Center 00022 // despatx Omega.S107 - Campus Nord UPC 00023 // 08034 Barcelona. SPAIN 00024 // 00026 00027 // ///////////////////////////////// 00028 // 00029 // lang_ident.h 00030 // 00031 // Class that implements a language identifier 00032 // 00034 00035 #ifndef _LANGIDENT_H 00036 #define _LANGIDENT_H 00037 00038 #include <map> 00039 #include <set> 00040 #include <vector> 00041 #include <string> 00042 00043 #include "freeling/windll.h" 00044 #include "freeling/morfo/idioma.h" 00045 00046 namespace freeling { 00047 00054 00055 class WINDLL lang_ident { 00056 private: 00058 std::map<std::wstring,idioma*> idiomes; 00059 std::set<std::wstring> all_known_languages; 00060 00062 void language_perplexities (std::vector<std::pair<double,std::wstring> > &, 00063 const std::wstring &, 00064 const std::set<std::wstring>&) const; 00065 00066 public: 00068 lang_ident(); 00070 lang_ident(const std::wstring &cfgfile); 00072 ~lang_ident(); 00074 void add_language(const std::wstring &modelfile); 00077 void train_language(const std::wstring &textfile, const std::wstring &modelfile, 00078 const std::wstring &code, size_t order); 00082 std::wstring identify_language (const std::wstring &text, 00083 const std::set<std::wstring> &ls=std::set<std::wstring>()) const; 00086 void rank_languages (std::vector<std::pair<double,std::wstring> > &result, 00087 const std::wstring &text, 00088 const std::set<std::wstring> &ls=std::set<std::wstring>()) const; 00089 00090 }; 00091 00092 } // namespace 00093 00094 #endif