FreeLing
4.0
|
00001 00002 // 00003 // FreeLing - Open Source Language Analyzers 00004 // 00005 // Copyright (C) 2014 TALP Research Center 00006 // Universitat Politecnica de Catalunya 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Affero General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 3 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Affero General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Affero General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 // 00022 // contact: Lluis Padro (padro@lsi.upc.es) 00023 // TALP Research Center 00024 // despatx C6.212 - Campus Nord UPC 00025 // 08034 Barcelona. SPAIN 00026 // 00028 00029 #ifndef _OUTPUT_CONLL 00030 #define _OUTPUT_CONLL 00031 00032 #include <iostream> 00033 #include "freeling/output/output_handler.h" 00034 #include "freeling/output/conll_handler.h" 00035 00036 namespace freeling { 00037 00038 namespace io { 00039 00040 class WINDLL output_conll : public output_handler, public conll_handler { 00041 00042 public: 00043 // empty constructor. 00044 output_conll (); 00045 // constructor from cfg file 00046 output_conll (const std::wstring &cfgFile); 00047 // destructor. 00048 ~output_conll (); 00049 00051 void PrintResults (std::wostream &sout, const std::list<freeling::sentence> &ls) const; 00053 void PrintResults(std::wostream &sout, const freeling::document &doc) const; 00055 using output_handler::PrintResults; 00056 00057 private: 00058 std::wstring compute_value(const freeling::sentence &s, 00059 const freeling::word &w, 00060 const std::wstring &field, 00061 const std::vector<std::wstring> &openchunk, 00062 const std::vector<std::wstring> &closechunk, 00063 const std::map<std::wstring,std::wstring> &openmention, 00064 const std::map<std::wstring,std::wstring> &closemention) const; 00065 00066 static void add_srl(std::vector<std::wstring> &token, 00067 const freeling::sentence &s, int id); 00068 00069 static void openclosechunks(freeling::parse_tree::const_iterator n, 00070 std::vector<std::wstring> &open, 00071 std::vector<std::wstring> &close); 00072 00073 static void openclosementions(const freeling::document &doc, 00074 std::map<std::wstring,std::wstring> &open, 00075 std::map<std::wstring,std::wstring> &close); 00076 00077 static void add_mention_oc(std::map<std::wstring,std::wstring> &table, 00078 const std::wstring &key, 00079 const std::wstring &value); 00080 00082 void freeling2conll(const freeling::sentence &s, 00083 conll_sentence &cs, 00084 const std::map<std::wstring,std::wstring> &openmention=std::map<std::wstring,std::wstring>(), 00085 const std::map<std::wstring,std::wstring> &closemention=std::map<std::wstring,std::wstring>()) const; 00086 00087 00088 }; 00089 } 00090 } 00091 #endif