FreeLing  3.0
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 
00036 #ifndef _LANGIDENT_H
00037 #define _LANGIDENT_H
00038 
00039 #include <map>
00040 #include <set>
00041 #include <vector>
00042 #include <string>
00043 
00044 #include "freeling/windll.h"
00045 #include "freeling/morfo/idioma.h"
00046 
00053 
00054 class WINDLL lang_ident {
00055  private:
00057   std::map<std::wstring,idioma> idiomes;
00058   std::set<std::wstring> all_known_languages;
00060   double Threshold;
00062   double ScaleFactor;
00063 
00065   void language_probabilities (std::vector<std::pair<double,std::wstring> > &, const std::wstring &, const std::set<std::wstring>&) const;
00066 
00067  public:
00069   lang_ident (const std::wstring &);
00071   void add_language(const std::wstring&);
00074   void train_language(const std::wstring &, const std::wstring &, const std::wstring &);
00076   std::wstring identify_language (const std::wstring&, const std::set<std::wstring>&) const; 
00078   void rank_languages (std::vector<std::pair<double,std::wstring> > &, const std::wstring &, const std::set<std::wstring>&) const;
00079 
00080 };
00081 
00082 
00083 #endif