FreeLing  3.1
lang_ident.h
Go to the documentation of this file.
00001 
00002 //
00003 //    Copyright (C) 2006   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 General Public License
00008 //    (GNU GPL) 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 //    General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU 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;
00061     double Threshold;
00063     double ScaleFactor;
00064 
00066     void language_probabilities (std::vector<std::pair<double,std::wstring> > &, const std::wstring &, const std::set<std::wstring>&) const;
00067 
00068   public:
00070     lang_ident();
00072     lang_ident(const std::wstring &);
00074     void add_language(const std::wstring&);
00077     void train_language(const std::wstring &, const std::wstring &, const std::wstring &);
00079     std::wstring identify_language (const std::wstring&, const std::set<std::wstring> &ls=std::set<std::wstring>()) const; 
00081     void rank_languages (std::vector<std::pair<double,std::wstring> > &, const std::wstring &, const std::set<std::wstring> &ls=std::set<std::wstring>()) const;
00082 
00083   };
00084 
00085 } // namespace
00086 
00087 #endif