diff --git a/src/ner/CMakeLists.txt b/src/ner/CMakeLists.txt index c1178f859..b488fd1ff 100644 --- a/src/ner/CMakeLists.txt +++ b/src/ner/CMakeLists.txt @@ -1,8 +1,4 @@ -include_directories ( - ${SOURCE_DIR}/ner - ${SOURCE_DIR}/utils - ${SOURCE_DIR}/utils/math) -# ${THIRDPARTY_DIR}/boost/include) +include_directories (${SOURCE_DIR}/) set (ner_VERSION "0.0.1") diff --git a/src/ner/decoder.cpp b/src/ner/decoder.cpp index 938feadaa..400fd8d41 100644 --- a/src/ner/decoder.cpp +++ b/src/ner/decoder.cpp @@ -1,103 +1,103 @@ -#include "decoder.h" +#include "ner/decoder.h" namespace ltp { namespace ner { void Decoder::decode(Instance * inst) { - init_lattice(inst); - viterbi_decode(inst); - get_result(inst); - free_lattice(); + init_lattice(inst); + viterbi_decode(inst); + get_result(inst); + free_lattice(); } void Decoder::init_lattice(const Instance * inst) { - int len = inst->size(); - lattice.resize(len, L); - lattice = NULL; + int len = inst->size(); + lattice.resize(len, L); + lattice = NULL; } void Decoder::viterbi_decode(const Instance * inst) { - int len = inst->size(); - for (int i = 0; i < len; ++ i) { - for (int l = 0; l < L; ++ l) { - if (i == 0) { - LatticeItem * item = new LatticeItem(i, l, inst->uni_scores[i][l], NULL); - lattice_insert(lattice[i][l], item); - } else { - for (int pl = 0; pl < L; ++ pl) { - if (false == base.legal_trans(pl, l)) { - continue; - } - - double score = 0.; - const LatticeItem * prev = lattice[i-1][pl]; - - if (!prev) { - continue; - } - - // std::cout << i << " " << pl << " " << l << std::endl; - score = inst->uni_scores[i][l] + inst->bi_scores[pl][l] + prev->score; - const LatticeItem * item = new LatticeItem(i, l, score, prev); - lattice_insert(lattice[i][l], item); - } - } // end for if i == 0 + int len = inst->size(); + for (int i = 0; i < len; ++ i) { + for (int l = 0; l < L; ++ l) { + if (i == 0) { + LatticeItem * item = new LatticeItem(i, l, inst->uni_scores[i][l], NULL); + lattice_insert(lattice[i][l], item); + } else { + for (int pl = 0; pl < L; ++ pl) { + if (false == base.legal_trans(pl, l)) { + continue; + } + + double score = 0.; + const LatticeItem * prev = lattice[i-1][pl]; + + if (!prev) { + continue; + } + + // std::cout << i << " " << pl << " " << l << std::endl; + score = inst->uni_scores[i][l] + inst->bi_scores[pl][l] + prev->score; + const LatticeItem * item = new LatticeItem(i, l, score, prev); + lattice_insert(lattice[i][l], item); } + } // end for if i == 0 } + } } void Decoder::get_result(Instance * inst) { - int len = inst->size(); - const LatticeItem * best_item = NULL; - for (int l = 0; l < L; ++ l) { - if (!lattice[len-1][l]) { - continue; - } - if (best_item == NULL || (lattice[len-1][l]->score > best_item->score)) { - best_item = lattice[len - 1][l]; - } + int len = inst->size(); + const LatticeItem * best_item = NULL; + for (int l = 0; l < L; ++ l) { + if (!lattice[len-1][l]) { + continue; } + if (best_item == NULL || (lattice[len-1][l]->score > best_item->score)) { + best_item = lattice[len - 1][l]; + } + } - const LatticeItem * item = best_item; - inst->predicted_tagsidx.resize(len); + const LatticeItem * item = best_item; + inst->predicted_tagsidx.resize(len); - while (item) { - inst->predicted_tagsidx[item->i] = item->l; - // std::cout << item->i << " " << item->l << std::endl; - item = item->prev; - } + while (item) { + inst->predicted_tagsidx[item->i] = item->l; + // std::cout << item->i << " " << item->l << std::endl; + item = item->prev; + } } void Decoder::free_lattice() { - for (int i = 0; i < lattice.nrows(); ++ i) { - for (int j = 0; j < lattice.ncols(); ++ j) { - if (lattice[i][j]) delete lattice[i][j]; - } + for (int i = 0; i < lattice.nrows(); ++ i) { + for (int j = 0; j < lattice.ncols(); ++ j) { + if (lattice[i][j]) delete lattice[i][j]; } + } } /*void KBestDecoder::decode(Instance * inst, KBestDecodeResult & result) { - init_lattice(inst); - kbest_viterbi_decode(inst); - get_result(result); - free_lattice(); + init_lattice(inst); + kbest_viterbi_decode(inst); + get_result(result); + free_lattice(); } void KBestDecoder::init_lattice(const Instance * inst) { - int len = inst->len(); - lattice.resize(len, L); + int len = inst->len(); + lattice.resize(len, L); - for (int i = 0; i < len; ++ i) { - for (int l = 0; l < L; ++ l) { - lattice[i][l] = new KHeap(k); - } + for (int i = 0; i < len; ++ i) { + for (int l = 0; l < L; ++ l) { + lattice[i][l] = new KHeap(k); } + } } void KBestDecoder::kbest_viterbi_decode(const Instance * inst) { }*/ -} // end for namespace ner -} // end for namespace ltp +} // end for namespace ner +} // end for namespace ltp diff --git a/src/ner/decoder.h b/src/ner/decoder.h index e18bb166d..5ce0355a9 100644 --- a/src/ner/decoder.h +++ b/src/ner/decoder.h @@ -3,9 +3,9 @@ #include #include -#include "instance.h" -#include "mat.h" -#include "rulebase.h" +#include "ner/instance.h" +#include "ner/rulebase.h" +#include "utils/math/mat.h" namespace ltp { namespace ner { diff --git a/src/ner/extractor.cpp b/src/ner/extractor.cpp index 69fb69d6f..dd875811a 100644 --- a/src/ner/extractor.cpp +++ b/src/ner/extractor.cpp @@ -1,8 +1,7 @@ -#include "extractor.h" -#include "settings.h" - -#include "strutils.hpp" -#include "chartypes.hpp" +#include "ner/extractor.h" +#include "ner/settings.h" +#include "utils/strutils.hpp" +#include "utils/chartypes.hpp" namespace ltp { namespace ner { diff --git a/src/ner/extractor.h b/src/ner/extractor.h index e2590d78a..8c05963b0 100644 --- a/src/ner/extractor.h +++ b/src/ner/extractor.h @@ -3,10 +3,9 @@ #include #include -#include "instance.h" - -#include "template.hpp" -#include "strvec.hpp" +#include "ner/instance.h" +#include "utils/template.hpp" +#include "utils/strvec.hpp" namespace ltp { namespace ner { diff --git a/src/ner/featurespace.cpp b/src/ner/featurespace.cpp index b116cf5ab..9e867b362 100644 --- a/src/ner/featurespace.cpp +++ b/src/ner/featurespace.cpp @@ -1,6 +1,5 @@ -#include "featurespace.h" - -#include "extractor.h" +#include "ner/featurespace.h" +#include "ner/extractor.h" namespace ltp { namespace ner { diff --git a/src/ner/featurespace.h b/src/ner/featurespace.h index 53983685d..8eff642df 100644 --- a/src/ner/featurespace.h +++ b/src/ner/featurespace.h @@ -4,7 +4,7 @@ #include #include -#include "smartmap.hpp" +#include "utils/smartmap.hpp" namespace ltp { namespace ner { diff --git a/src/ner/featurevec.h b/src/ner/featurevec.h deleted file mode 100644 index 1e0652652..000000000 --- a/src/ner/featurevec.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef __LTP_NER_FEATURE_VECTOR_H__ -#define __LTP_NER_FEATURE_VECTOR_H__ - -namespace ltp { -namespace ner { - -struct FeatureVector { -public: - FeatureVector () : n(0), idx(0), val(0), loff(0) { - } - - ~FeatureVector() { - } - - void clear() { - if (idx) { - delete [](idx); - idx = 0; - } - - if (val) { - delete [](val); - val = 0; - } - } - -public: - int n; - int * idx; - double * val; - int loff; -}; - -} // end for namespace segmentor -} // end for namespace ltp - -#endif // end for __LTP_SEGMENTOR_FEATRUE_VECTOR_H__ diff --git a/src/ner/instance.h b/src/ner/instance.h index e67b84e79..683f22540 100644 --- a/src/ner/instance.h +++ b/src/ner/instance.h @@ -2,9 +2,9 @@ #define __LTP_NER_INSTANCE_H__ #include -#include "featurevec.h" -#include "mat.h" -#include "sparsevec.h" +#include "utils/math/mat.h" +#include "utils/math/featurevec.h" +#include "utils/math/sparsevec.h" namespace ltp { namespace ner { @@ -167,7 +167,7 @@ class Instance { math::SparseVec features; /*< the gold features */ math::SparseVec predicted_features; /*< the predicted features */ - math::Mat< FeatureVector *> uni_features; + math::Mat< math::FeatureVector *> uni_features; math::Mat< double > uni_scores; math::Mat< double > bi_scores; }; diff --git a/src/ner/model.cpp b/src/ner/model.cpp index b44bd8193..ecff88906 100644 --- a/src/ner/model.cpp +++ b/src/ner/model.cpp @@ -1,4 +1,4 @@ -#include "model.h" +#include "ner/model.h" namespace ltp { namespace ner { diff --git a/src/ner/model.h b/src/ner/model.h index ec898b70e..7084889c8 100644 --- a/src/ner/model.h +++ b/src/ner/model.h @@ -1,10 +1,9 @@ #ifndef __LTP_NER_MODEL_H__ #define __LTP_NER_MODEL_H__ -#include "featurespace.h" -#include "parameter.h" - -#include "smartmap.hpp" +#include "ner/featurespace.h" +#include "ner/parameter.h" +#include "utils/smartmap.hpp" namespace ltp { namespace ner { diff --git a/src/ner/ner.cpp b/src/ner/ner.cpp index 897eee707..660c51cac 100644 --- a/src/ner/ner.cpp +++ b/src/ner/ner.cpp @@ -1,12 +1,11 @@ #include "ner.h" -#include "time.hpp" -#include "logging.hpp" -#include "instance.h" -#include "extractor.h" -#include "options.h" - -#include "nerio.h" +#include "utils/time.hpp" +#include "utils/logging.hpp" +#include "ner/instance.h" +#include "ner/extractor.h" +#include "ner/options.h" +#include "ner/nerio.h" #include #include diff --git a/src/ner/ner.h b/src/ner/ner.h index 4c13f4514..a204bea17 100644 --- a/src/ner/ner.h +++ b/src/ner/ner.h @@ -1,9 +1,9 @@ #ifndef __LTP_NER_NER_H__ #define __LTP_NER_NER_H__ -#include "cfgparser.hpp" -#include "model.h" -#include "decoder.h" +#include "utils/cfgparser.hpp" +#include "ner/model.h" +#include "ner/decoder.h" namespace ltp { namespace ner { diff --git a/src/ner/ner_dll.cpp b/src/ner/ner_dll.cpp index d04761e71..30df83a95 100644 --- a/src/ner/ner_dll.cpp +++ b/src/ner/ner_dll.cpp @@ -1,11 +1,8 @@ -#include "ner_dll.h" - -#include "ner.h" -#include "settings.h" -//#include "instance.h" - -#include "logging.hpp" -#include "codecs.hpp" +#include "ner/ner_dll.h" +#include "ner/ner.h" +#include "ner/settings.h" +#include "utils/logging.hpp" +#include "utils/codecs.hpp" #include diff --git a/src/ner/nerio.h b/src/ner/nerio.h index 35489cf27..b9c3f227b 100644 --- a/src/ner/nerio.h +++ b/src/ner/nerio.h @@ -2,11 +2,11 @@ #define __LTP_NER_IO_H__ #include -#include "settings.h" -#include "instance.h" -#include "strutils.hpp" -#include "sbcdbc.hpp" -#include "codecs.hpp" +#include "ner/settings.h" +#include "ner/instance.h" +#include "utils/strutils.hpp" +#include "utils/sbcdbc.hpp" +#include "utils/codecs.hpp" namespace ltp { namespace ner { diff --git a/src/ner/options.cpp b/src/ner/options.cpp index 85b2ca7ef..9f44136b3 100644 --- a/src/ner/options.cpp +++ b/src/ner/options.cpp @@ -1,4 +1,4 @@ -#include "options.h" +#include "ner/options.h" namespace ltp { namespace ner { diff --git a/src/ner/otner.cpp b/src/ner/otner.cpp index 6b3763a25..48e54d406 100644 --- a/src/ner/otner.cpp +++ b/src/ner/otner.cpp @@ -1,7 +1,7 @@ #include -#include "cfgparser.hpp" -#include "logging.hpp" -#include "ner.h" +#include "utils/cfgparser.hpp" +#include "utils/logging.hpp" +#include "ner/ner.h" using namespace ltp::utility; using namespace ltp::ner; diff --git a/src/ner/parameter.h b/src/ner/parameter.h index cfd469b0c..ba9f929fd 100644 --- a/src/ner/parameter.h +++ b/src/ner/parameter.h @@ -2,8 +2,8 @@ #define __LTP_NER_PARAMETER_H__ #include -#include "sparsevec.h" -#include "featurevec.h" +#include "utils/math/sparsevec.h" +#include "utils/math/featurevec.h" namespace ltp { namespace ner { diff --git a/src/ner/rulebase.h b/src/ner/rulebase.h index 115759070..a785e6f97 100644 --- a/src/ner/rulebase.h +++ b/src/ner/rulebase.h @@ -6,10 +6,10 @@ #include #include -#include "settings.h" -#include "sbcdbc.hpp" -#include "smartmap.hpp" -#include "chartypes.hpp" +#include "ner/settings.h" +#include "utils/sbcdbc.hpp" +#include "utils/smartmap.hpp" +#include "utils/chartypes.hpp" namespace ltp { namespace ner { diff --git a/src/parser/CMakeLists.txt b/src/parser/CMakeLists.txt index b0586d648..e7c0747a3 100644 --- a/src/parser/CMakeLists.txt +++ b/src/parser/CMakeLists.txt @@ -1,9 +1,6 @@ # example of configure time generate header -include_directories (./ - ${SOURCE_DIR}/parser - ${SOURCE_DIR}/utils - ${SOURCE_DIR}/utils/math) +include_directories (${SOURCE_DIR}/) set (lgdpj_VERSION "0.0.1") diff --git a/src/parser/collections.cpp b/src/parser/collections.cpp index c5c53b2be..c5a44d05d 100644 --- a/src/parser/collections.cpp +++ b/src/parser/collections.cpp @@ -1,4 +1,4 @@ -#include "collections.h" +#include "parser/collections.h" namespace ltp { namespace parser { diff --git a/src/parser/collections.h b/src/parser/collections.h index c5c579a33..22cd4c5d1 100644 --- a/src/parser/collections.h +++ b/src/parser/collections.h @@ -3,10 +3,9 @@ #include #include -#include "stringmap.hpp" -#include "smartmap.hpp" - -#include "instance.h" +#include "utils/stringmap.hpp" +#include "utils/smartmap.hpp" +#include "parser/instance.h" namespace ltp { namespace parser { diff --git a/src/parser/conllreader.h b/src/parser/conllreader.h index a8ac9ae61..5ddcc5992 100644 --- a/src/parser/conllreader.h +++ b/src/parser/conllreader.h @@ -4,13 +4,12 @@ #include #include -#include "codecs.hpp" -#include "strutils.hpp" -#include "logging.hpp" - -#include "settings.h" -#include "instance.h" -#include "options.h" +#include "utils/codecs.hpp" +#include "utils/strutils.hpp" +#include "utils/logging.hpp" +#include "parser/settings.h" +#include "parser/instance.h" +#include "parser/options.h" namespace ltp { namespace parser { diff --git a/src/parser/conllwriter.h b/src/parser/conllwriter.h index 0d4e91a4f..c4602ae2e 100644 --- a/src/parser/conllwriter.h +++ b/src/parser/conllwriter.h @@ -3,8 +3,8 @@ #include -#include "strutils.hpp" -#include "instance.h" +#include "utils/strutils.hpp" +#include "parser/instance.h" namespace ltp { namespace parser { diff --git a/src/parser/debug.h b/src/parser/debug.h index 3849f99a0..13e163aa9 100644 --- a/src/parser/debug.h +++ b/src/parser/debug.h @@ -2,7 +2,7 @@ #define __DEBUG_H__ #include -#include "instance.h" +#include "parser/instance.h" namespace ltp { namespace parser { diff --git a/src/parser/decoder.h b/src/parser/decoder.h index 4d065d379..d333fc8a1 100644 --- a/src/parser/decoder.h +++ b/src/parser/decoder.h @@ -1,9 +1,9 @@ #ifndef __LTP_PARSER_DECODER_H__ #define __LTP_PARSER_DECODER_H__ -#include "instance.h" -#include "settings.h" -#include "options.h" +#include "parser/instance.h" +#include "parser/settings.h" +#include "parser/options.h" #include #include diff --git a/src/parser/decoder1o.cpp b/src/parser/decoder1o.cpp index 73474eabe..e3b94afc5 100644 --- a/src/parser/decoder1o.cpp +++ b/src/parser/decoder1o.cpp @@ -1,4 +1,4 @@ -#include "decoder1o.h" +#include "parser/decoder1o.h" namespace ltp { namespace parser { diff --git a/src/parser/decoder1o.h b/src/parser/decoder1o.h index 4d6b10942..d3265ff2f 100644 --- a/src/parser/decoder1o.h +++ b/src/parser/decoder1o.h @@ -1,12 +1,11 @@ #ifndef __LTP_PARSER_DECODER_1_O_H__ #define __LTP_PARSER_DECODER_1_O_H__ -#include "instance.h" -#include "decoder.h" -#include "mat.h" -#include "options.h" - -#include "debug.h" +#include "parser/instance.h" +#include "parser/decoder.h" +#include "parser/options.h" +#include "parser/debug.h" +#include "utils/math/mat.h" namespace ltp { namespace parser { diff --git a/src/parser/decoder2o.cpp b/src/parser/decoder2o.cpp index dd3a295cc..ec5a5a7e1 100644 --- a/src/parser/decoder2o.cpp +++ b/src/parser/decoder2o.cpp @@ -1,5 +1,5 @@ -#include "decoder2o.h" -#include "options.h" +#include "parser/decoder2o.h" +#include "parser/options.h" namespace ltp { namespace parser { diff --git a/src/parser/decoder2o.h b/src/parser/decoder2o.h index 788bb3111..37280d185 100644 --- a/src/parser/decoder2o.h +++ b/src/parser/decoder2o.h @@ -1,7 +1,7 @@ #ifndef __LTP_PARSER_DECODER_2_O_H__ #define __LTP_PARSER_DECODER_2_O_H__ -#include "decoder.h" +#include "parser/decoder.h" namespace ltp { namespace parser { diff --git a/src/parser/extractor.cpp b/src/parser/extractor.cpp index 553e818dd..1df4f3f0a 100644 --- a/src/parser/extractor.cpp +++ b/src/parser/extractor.cpp @@ -1,6 +1,6 @@ -#include "extractor.h" -#include "options.h" -#include "settings.h" +#include "parser/extractor.h" +#include "parser/options.h" +#include "parser/settings.h" #define LEN(x) (x.size()) #define LAST(x) ((x)[(x).size()-1]) diff --git a/src/parser/extractor.h b/src/parser/extractor.h index b5b96b440..5be58191e 100644 --- a/src/parser/extractor.h +++ b/src/parser/extractor.h @@ -6,13 +6,13 @@ #include #include -#include "collections.h" -#include "instance.h" +#include "parser/collections.h" +#include "parser/instance.h" -#include "strvec.hpp" -#include "template.hpp" -#include "strutils.hpp" -#include "strpaste.hpp" +#include "utils/strvec.hpp" +#include "utils/template.hpp" +#include "utils/strutils.hpp" +#include "utils/strpaste.hpp" #include "debug.h" diff --git a/src/parser/featurespace.cpp b/src/parser/featurespace.cpp index 1dbd07d43..db53dfd50 100644 --- a/src/parser/featurespace.cpp +++ b/src/parser/featurespace.cpp @@ -1,10 +1,9 @@ -#include "options.h" -#include "featurespace.h" -#include "extractor.h" - -#include "treeutils.hpp" -#include "strvec.hpp" -#include "logging.hpp" +#include "parser/options.h" +#include "parser/featurespace.h" +#include "parser/extractor.h" +#include "parser/treeutils.hpp" +#include "utils/strvec.hpp" +#include "utils/logging.hpp" namespace ltp { namespace parser { diff --git a/src/parser/featurespace.h b/src/parser/featurespace.h index 990db5511..3ba4a5352 100644 --- a/src/parser/featurespace.h +++ b/src/parser/featurespace.h @@ -4,9 +4,9 @@ #include #include -#include "instance.h" -#include "collections.h" -#include "smartmap.hpp" +#include "parser/instance.h" +#include "parser/collections.h" +#include "utils/smartmap.hpp" namespace ltp { namespace parser { diff --git a/src/parser/instance.h b/src/parser/instance.h index b637e4f36..2db6c182f 100644 --- a/src/parser/instance.h +++ b/src/parser/instance.h @@ -5,9 +5,9 @@ #include #include -#include "mat.h" -#include "sparsevec.h" -#include "featurevec.h" +#include "utils/math/mat.h" +#include "utils/math/sparsevec.h" +#include "utils/math/featurevec.h" namespace ltp { namespace parser { diff --git a/src/parser/lgdpj.cpp b/src/parser/lgdpj.cpp index 7baef0430..4dc0ace71 100644 --- a/src/parser/lgdpj.cpp +++ b/src/parser/lgdpj.cpp @@ -5,9 +5,9 @@ * Author: LIU, Yijia */ #include -#include "cfgparser.hpp" -#include "logging.hpp" -#include "parser.h" +#include "utils/cfgparser.hpp" +#include "utils/logging.hpp" +#include "parser/parser.h" using namespace ltp::parser; diff --git a/src/parser/model.cpp b/src/parser/model.cpp index 9ab1c7c03..85b02e30a 100644 --- a/src/parser/model.cpp +++ b/src/parser/model.cpp @@ -1,4 +1,4 @@ -#include "model.h" +#include "parser/model.h" namespace ltp { namespace parser { diff --git a/src/parser/model.h b/src/parser/model.h index 31e5fa847..fb33bc3e5 100644 --- a/src/parser/model.h +++ b/src/parser/model.h @@ -1,9 +1,9 @@ #ifndef __LTP_PARSER_MODEL_H__ #define __LTP_PARSER_MODEL_H__ -#include "featurespace.h" -#include "parameters.h" -#include "options.h" +#include "parser/featurespace.h" +#include "parser/parameters.h" +#include "parser/options.h" namespace ltp { namespace parser { diff --git a/src/parser/options.cpp b/src/parser/options.cpp index 3d2d051df..8f33881e5 100644 --- a/src/parser/options.cpp +++ b/src/parser/options.cpp @@ -1,4 +1,4 @@ -#include "options.h" +#include "parser/options.h" namespace ltp { namespace parser { diff --git a/src/parser/parameters.h b/src/parser/parameters.h index 59dd3a5eb..03fcbfe87 100644 --- a/src/parser/parameters.h +++ b/src/parser/parameters.h @@ -1,8 +1,8 @@ #ifndef __LTP_PARSER_PARAMETERS_H__ #define __LTP_PARSER_PARAMETERS_H__ -#include "sparsevec.h" -#include "featurevec.h" +#include "utils/math/sparsevec.h" +#include "utils/math/featurevec.h" namespace ltp { namespace parser { diff --git a/src/parser/parser.cpp b/src/parser/parser.cpp index c753d6372..e06f1a584 100644 --- a/src/parser/parser.cpp +++ b/src/parser/parser.cpp @@ -1,11 +1,10 @@ -#include "parser.h" -#include "options.h" -#include "decoder1o.h" -#include "decoder2o.h" -#include "conllreader.h" -#include "conllwriter.h" - -#include "treeutils.hpp" +#include "parser/parser.h" +#include "parser/options.h" +#include "parser/decoder1o.h" +#include "parser/decoder2o.h" +#include "parser/conllreader.h" +#include "parser/conllwriter.h" +#include "parser/treeutils.hpp" #if _WIN32 #include diff --git a/src/parser/parser.h b/src/parser/parser.h index 3468a6e2c..d1d0253ab 100644 --- a/src/parser/parser.h +++ b/src/parser/parser.h @@ -3,16 +3,14 @@ #include -#include "instance.h" -#include "model.h" -#include "extractor.h" -#include "decoder.h" - -#include "cfgparser.hpp" -#include "logging.hpp" -#include "time.hpp" - -#include "debug.h" +#include "parser/instance.h" +#include "parser/model.h" +#include "parser/extractor.h" +#include "parser/decoder.h" +#include "parser/debug.h" +#include "utils/cfgparser.hpp" +#include "utils/logging.hpp" +#include "utils/time.hpp" using namespace std; using namespace ltp::utility; diff --git a/src/parser/parser_dll.cpp b/src/parser/parser_dll.cpp index 52178789a..6a1cf63bd 100644 --- a/src/parser/parser_dll.cpp +++ b/src/parser/parser_dll.cpp @@ -1,10 +1,8 @@ -#include "parser_dll.h" - -#include "parser.h" -#include "settings.h" - -#include "logging.hpp" -#include "codecs.hpp" +#include "parser/parser_dll.h" +#include "parser/parser.h" +#include "parser/settings.h" +#include "utils/logging.hpp" +#include "utils/codecs.hpp" #include diff --git a/src/postagger/CMakeLists.txt b/src/postagger/CMakeLists.txt index fba0495ac..c560d5074 100644 --- a/src/postagger/CMakeLists.txt +++ b/src/postagger/CMakeLists.txt @@ -1,7 +1,4 @@ -include_directories (./ - ${SOURCE_DIR}/postagger - ${SOURCE_DIR}/utils - ${SOURCE_DIR}/utils/math) +include_directories ( ${SOURCE_DIR}/ ) set (postagger_VERSION "0.0.1") diff --git a/src/postagger/decoder.cpp b/src/postagger/decoder.cpp index e341030d4..94b642ef6 100644 --- a/src/postagger/decoder.cpp +++ b/src/postagger/decoder.cpp @@ -1,4 +1,4 @@ -#include "decoder.h" +#include "postagger/decoder.h" namespace ltp { namespace postagger { diff --git a/src/postagger/decoder.h b/src/postagger/decoder.h index 46cc42658..a186998a7 100644 --- a/src/postagger/decoder.h +++ b/src/postagger/decoder.h @@ -3,8 +3,8 @@ #include #include -#include "instance.h" -#include "mat.h" +#include "postagger/instance.h" +#include "utils/math/mat.h" namespace ltp { namespace postagger { diff --git a/src/postagger/extractor.cpp b/src/postagger/extractor.cpp index a48a379fc..b0ce3b59d 100644 --- a/src/postagger/extractor.cpp +++ b/src/postagger/extractor.cpp @@ -1,9 +1,8 @@ -#include "extractor.h" -#include "settings.h" - -#include "codecs.hpp" -#include "strutils.hpp" -#include "chartypes.hpp" +#include "postagger/extractor.h" +#include "postagger/settings.h" +#include "utils/codecs.hpp" +#include "utils/strutils.hpp" +#include "utils/chartypes.hpp" namespace ltp { namespace postagger { diff --git a/src/postagger/extractor.h b/src/postagger/extractor.h index 79b420e0b..8237e7ff2 100644 --- a/src/postagger/extractor.h +++ b/src/postagger/extractor.h @@ -3,10 +3,10 @@ #include #include -#include "instance.h" -#include "template.hpp" -#include "strvec.hpp" +#include "postagger/instance.h" +#include "utils/template.hpp" +#include "utils/strvec.hpp" namespace ltp { namespace postagger { diff --git a/src/postagger/featurespace.cpp b/src/postagger/featurespace.cpp index 2537c6073..34d161a7f 100644 --- a/src/postagger/featurespace.cpp +++ b/src/postagger/featurespace.cpp @@ -1,6 +1,5 @@ -#include "featurespace.h" - -#include "extractor.h" +#include "postagger/featurespace.h" +#include "postagger/extractor.h" namespace ltp { namespace postagger { diff --git a/src/postagger/featurespace.h b/src/postagger/featurespace.h index e89a50cba..f4aa310fc 100644 --- a/src/postagger/featurespace.h +++ b/src/postagger/featurespace.h @@ -4,7 +4,7 @@ #include #include -#include "smartmap.hpp" +#include "utils/smartmap.hpp" namespace ltp { namespace postagger { diff --git a/src/postagger/featurevec.h b/src/postagger/featurevec.h deleted file mode 100644 index 38c937006..000000000 --- a/src/postagger/featurevec.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef __LTP_POSTAGGER_FEATURE_VECTOR_H__ -#define __LTP_POSTAGGER_FEATURE_VECTOR_H__ - -namespace ltp { -namespace postagger { - -struct FeatureVector { -public: - FeatureVector () : n(0), idx(0), val(0) { - } - - ~FeatureVector() { - } - - void clear() { - if (idx) { - delete [](idx); - idx = 0; - } - - if (val) { - delete [](val); - val = 0; - } - } - - -public: - int n; - int * idx; - double * val; - int loff; -}; - -} // end for namespace postagger -} // end for namespace ltp - -#endif // end for __LTP_POSTAGGER_FEATRUE_VECTOR_H__ diff --git a/src/postagger/instance.h b/src/postagger/instance.h index acc0a4546..93fed8e3c 100644 --- a/src/postagger/instance.h +++ b/src/postagger/instance.h @@ -2,9 +2,9 @@ #define __LTP_POSTAGGER_INSTANCE_H__ #include -#include "featurevec.h" -#include "mat.h" -#include "sparsevec.h" +#include "utils/math/mat.h" +#include "utils/math/sparsevec.h" +#include "utils/math/featurevec.h" namespace ltp { namespace postagger { @@ -66,7 +66,7 @@ class Instance { math::SparseVec features; /*< the gold features */ math::SparseVec predicted_features; /*< the predicted features */ - math::Mat< FeatureVector *> uni_features; + math::Mat< math::FeatureVector *> uni_features; math::Mat< double > uni_scores; math::Mat< double > bi_scores; diff --git a/src/postagger/model.cpp b/src/postagger/model.cpp index 2eb510635..90f8752eb 100644 --- a/src/postagger/model.cpp +++ b/src/postagger/model.cpp @@ -1,4 +1,4 @@ -#include "model.h" +#include "postagger/model.h" namespace ltp { namespace postagger { diff --git a/src/postagger/model.h b/src/postagger/model.h index fac743909..d7a343a70 100644 --- a/src/postagger/model.h +++ b/src/postagger/model.h @@ -1,10 +1,10 @@ #ifndef __LTP_POSTAGGER_MODEL_H__ #define __LTP_POSTAGGER_MODEL_H__ -#include "featurespace.h" -#include "parameter.h" +#include "postagger/featurespace.h" +#include "postagger/parameter.h" -#include "smartmap.hpp" +#include "utils/smartmap.hpp" namespace ltp { namespace postagger { diff --git a/src/postagger/options.cpp b/src/postagger/options.cpp index 1c507153e..03aa58c89 100644 --- a/src/postagger/options.cpp +++ b/src/postagger/options.cpp @@ -1,4 +1,4 @@ -#include "options.h" +#include "postagger/options.h" namespace ltp { namespace postagger { diff --git a/src/postagger/otpos.cpp b/src/postagger/otpos.cpp index 35d80cd45..d80b1604b 100644 --- a/src/postagger/otpos.cpp +++ b/src/postagger/otpos.cpp @@ -1,7 +1,7 @@ #include -#include "cfgparser.hpp" -#include "logging.hpp" -#include "postagger.h" +#include "utils/cfgparser.hpp" +#include "utils/logging.hpp" +#include "postagger/postagger.h" using namespace ltp::utility; using namespace ltp::postagger; diff --git a/src/postagger/parameter.h b/src/postagger/parameter.h index 1d968d379..7e057d593 100644 --- a/src/postagger/parameter.h +++ b/src/postagger/parameter.h @@ -2,8 +2,8 @@ #define __LTP_POSTAGGER_PARAMETER_H__ #include -#include "sparsevec.h" -#include "featurevec.h" +#include "utils/math/sparsevec.h" +#include "utils/math/featurevec.h" namespace ltp { namespace postagger { diff --git a/src/postagger/postag_dll.cpp b/src/postagger/postag_dll.cpp index a669072c0..73fe161c1 100644 --- a/src/postagger/postag_dll.cpp +++ b/src/postagger/postag_dll.cpp @@ -1,11 +1,9 @@ -#include "postag_dll.h" - -#include "postagger.h" -#include "settings.h" - -#include "logging.hpp" -#include "codecs.hpp" -#include "sbcdbc.hpp" +#include "postagger/postag_dll.h" +#include "postagger/postagger.h" +#include "postagger/settings.h" +#include "utils/logging.hpp" +#include "utils/codecs.hpp" +#include "utils/sbcdbc.hpp" #include diff --git a/src/postagger/postagger.cpp b/src/postagger/postagger.cpp index 8f944e113..51126853c 100644 --- a/src/postagger/postagger.cpp +++ b/src/postagger/postagger.cpp @@ -1,12 +1,10 @@ -#include "postagger.h" - -#include "time.hpp" -#include "logging.hpp" -#include "instance.h" -#include "extractor.h" -#include "options.h" - -#include "postaggerio.h" +#include "utils/time.hpp" +#include "utils/logging.hpp" +#include "postagger/postagger.h" +#include "postagger/instance.h" +#include "postagger/extractor.h" +#include "postagger/options.h" +#include "postagger/postaggerio.h" #include #include diff --git a/src/postagger/postagger.h b/src/postagger/postagger.h index 2e62136c9..1474fbe02 100644 --- a/src/postagger/postagger.h +++ b/src/postagger/postagger.h @@ -1,9 +1,9 @@ #ifndef __LTP_POSTAGGER_POSTAGGER_H__ #define __LTP_POSTAGGER_POSTAGGER_H__ -#include "cfgparser.hpp" -#include "model.h" -#include "decoder.h" +#include "utils/cfgparser.hpp" +#include "postagger/model.h" +#include "postagger/decoder.h" namespace ltp { namespace postagger { diff --git a/src/postagger/postaggerio.h b/src/postagger/postaggerio.h index 05e5454cb..55006d251 100644 --- a/src/postagger/postaggerio.h +++ b/src/postagger/postaggerio.h @@ -2,10 +2,10 @@ #define __LTP_POSTAGGER_IO_H__ #include -#include "settings.h" -#include "instance.h" -#include "sbcdbc.hpp" -#include "strutils.hpp" +#include "postagger/settings.h" +#include "postagger/instance.h" +#include "utils/sbcdbc.hpp" +#include "utils/strutils.hpp" namespace ltp { namespace postagger { diff --git a/src/segmentor/CMakeLists.txt b/src/segmentor/CMakeLists.txt index dc67886ac..2cc17cc59 100644 --- a/src/segmentor/CMakeLists.txt +++ b/src/segmentor/CMakeLists.txt @@ -1,8 +1,4 @@ -include_directories ( - ${SOURCE_DIR}/segmentor - ${SOURCE_DIR}/utils - ${SOURCE_DIR}/utils/math - ${THIRDPARTY_DIR}/boost/include) +include_directories ( ${SOURCE_DIR} ) set (segment_VERSION "0.0.1") diff --git a/src/segmentor/decoder.cpp b/src/segmentor/decoder.cpp index 369e8218a..18c70afc7 100644 --- a/src/segmentor/decoder.cpp +++ b/src/segmentor/decoder.cpp @@ -1,4 +1,4 @@ -#include "decoder.h" +#include "segmentor/decoder.h" namespace ltp { namespace segmentor { diff --git a/src/segmentor/decoder.h b/src/segmentor/decoder.h index c5a920322..c04da5c89 100644 --- a/src/segmentor/decoder.h +++ b/src/segmentor/decoder.h @@ -3,9 +3,9 @@ #include #include -#include "instance.h" -#include "mat.h" -#include "rulebase.h" +#include "segmentor/instance.h" +#include "segmentor/rulebase.h" +#include "utils/math/mat.h" namespace ltp { namespace segmentor { diff --git a/src/segmentor/extractor.cpp b/src/segmentor/extractor.cpp index 6fc7ee054..75d42c0d4 100644 --- a/src/segmentor/extractor.cpp +++ b/src/segmentor/extractor.cpp @@ -1,8 +1,7 @@ -#include "extractor.h" -#include "settings.h" - -#include "strutils.hpp" -#include "chartypes.hpp" +#include "segmentor/extractor.h" +#include "segmentor/settings.h" +#include "utils/strutils.hpp" +#include "utils/chartypes.hpp" namespace ltp { namespace segmentor { diff --git a/src/segmentor/extractor.h b/src/segmentor/extractor.h index f6f85f31f..365ad182e 100644 --- a/src/segmentor/extractor.h +++ b/src/segmentor/extractor.h @@ -3,10 +3,9 @@ #include #include -#include "instance.h" - -#include "template.hpp" -#include "strvec.hpp" +#include "segmentor/instance.h" +#include "utils/template.hpp" +#include "utils/strvec.hpp" namespace ltp { namespace segmentor { diff --git a/src/segmentor/featurespace.cpp b/src/segmentor/featurespace.cpp index a50e8123d..65c909a55 100644 --- a/src/segmentor/featurespace.cpp +++ b/src/segmentor/featurespace.cpp @@ -1,6 +1,5 @@ -#include "featurespace.h" - -#include "extractor.h" +#include "segmentor/featurespace.h" +#include "segmentor/extractor.h" namespace ltp { namespace segmentor { diff --git a/src/segmentor/featurespace.h b/src/segmentor/featurespace.h index b351d6fcc..375034583 100644 --- a/src/segmentor/featurespace.h +++ b/src/segmentor/featurespace.h @@ -4,7 +4,7 @@ #include #include -#include "smartmap.hpp" +#include "utils/smartmap.hpp" namespace ltp { namespace segmentor { diff --git a/src/segmentor/instance.h b/src/segmentor/instance.h index 08ad00d83..f485986b5 100644 --- a/src/segmentor/instance.h +++ b/src/segmentor/instance.h @@ -2,9 +2,9 @@ #define __LTP_SEGMENTOR_INSTANCE_H__ #include -#include "featurevec.h" -#include "mat.h" -#include "sparsevec.h" +#include "utils/math/mat.h" +#include "utils/math/featurevec.h" +#include "utils/math/sparsevec.h" namespace ltp { namespace segmentor { @@ -127,7 +127,7 @@ class Instance { math::SparseVec features; /*< the gold features */ math::SparseVec predicted_features; /*< the predicted features */ - math::Mat< FeatureVector *> uni_features; + math::Mat< math::FeatureVector *> uni_features; math::Mat< double > uni_scores; math::Mat< double > bi_scores; }; diff --git a/src/segmentor/model.h b/src/segmentor/model.h index 3824f1f07..3a11b092c 100644 --- a/src/segmentor/model.h +++ b/src/segmentor/model.h @@ -1,10 +1,9 @@ #ifndef __LTP_SEGMENTOR_MODEL_H__ #define __LTP_SEGMENTOR_MODEL_H__ -#include "featurespace.h" -#include "parameter.h" - -#include "smartmap.hpp" +#include "segmentor/featurespace.h" +#include "segmentor/parameter.h" +#include "utils/smartmap.hpp" namespace ltp { namespace segmentor { diff --git a/src/segmentor/options.cpp b/src/segmentor/options.cpp index 92d3c05e6..d3a5e67c5 100644 --- a/src/segmentor/options.cpp +++ b/src/segmentor/options.cpp @@ -1,4 +1,4 @@ -#include "options.h" +#include "segmentor/options.h" namespace ltp { namespace segmentor { diff --git a/src/segmentor/otcws.cpp b/src/segmentor/otcws.cpp index beef25ba0..e0f98d27a 100644 --- a/src/segmentor/otcws.cpp +++ b/src/segmentor/otcws.cpp @@ -1,7 +1,7 @@ #include -#include "cfgparser.hpp" -#include "logging.hpp" -#include "segmentor.h" +#include "utils/cfgparser.hpp" +#include "utils/logging.hpp" +#include "segmentor/segmentor.h" using namespace ltp::utility; using namespace ltp::segmentor; diff --git a/src/segmentor/parameter.h b/src/segmentor/parameter.h index 6a76da3bc..58dd0629f 100644 --- a/src/segmentor/parameter.h +++ b/src/segmentor/parameter.h @@ -2,8 +2,8 @@ #define __LTP_SEGMENTOR_PARAMETER_H__ #include -#include "sparsevec.h" -#include "featurevec.h" +#include "utils/math/sparsevec.h" +#include "utils/math/featurevec.h" namespace ltp { namespace segmentor { diff --git a/src/segmentor/rulebase.h b/src/segmentor/rulebase.h index 3786748f2..f76f254d5 100644 --- a/src/segmentor/rulebase.h +++ b/src/segmentor/rulebase.h @@ -5,11 +5,11 @@ #include #include -#include "settings.h" -#include "strutils.hpp" -#include "sbcdbc.hpp" -#include "smartmap.hpp" -#include "chartypes.hpp" +#include "segmentor/settings.h" +#include "utils/strutils.hpp" +#include "utils/sbcdbc.hpp" +#include "utils/smartmap.hpp" +#include "utils/chartypes.hpp" #if _WIN32 // disable auto-link feature in boost diff --git a/src/segmentor/segment_dll.cpp b/src/segmentor/segment_dll.cpp index 95a044348..9abb69049 100644 --- a/src/segmentor/segment_dll.cpp +++ b/src/segmentor/segment_dll.cpp @@ -1,11 +1,9 @@ -#include "segment_dll.h" - -#include "segmentor.h" -#include "settings.h" +#include "segmentor/segment_dll.h" +#include "segmentor/segmentor.h" +#include "segmentor/settings.h" //#include "instance.h" - -#include "logging.hpp" -#include "codecs.hpp" +#include "utils/logging.hpp" +#include "utils/codecs.hpp" #include diff --git a/src/segmentor/segmentor.cpp b/src/segmentor/segmentor.cpp index 41a014141..142bc2853 100644 --- a/src/segmentor/segmentor.cpp +++ b/src/segmentor/segmentor.cpp @@ -1,13 +1,11 @@ -#include "segmentor.h" - -#include "time.hpp" -#include "logging.hpp" -#include "instance.h" -#include "extractor.h" -#include "options.h" - -#include "segmentreader.h" -#include "segmentwriter.h" +#include "utils/time.hpp" +#include "utils/logging.hpp" +#include "segmentor/segmentor.h" +#include "segmentor/instance.h" +#include "segmentor/extractor.h" +#include "segmentor/options.h" +#include "segmentor/segmentreader.h" +#include "segmentor/segmentwriter.h" #include #include diff --git a/src/segmentor/segmentor.h b/src/segmentor/segmentor.h index 954773f37..2310501fa 100644 --- a/src/segmentor/segmentor.h +++ b/src/segmentor/segmentor.h @@ -1,10 +1,10 @@ #ifndef __LTP_SEGMENTOR_SEGMENTOR_H__ #define __LTP_SEGMENTOR_SEGMENTOR_H__ -#include "cfgparser.hpp" -#include "model.h" -#include "decoder.h" -#include "rulebase.h" +#include "utils/cfgparser.hpp" +#include "segmentor/model.h" +#include "segmentor/decoder.h" +#include "segmentor/rulebase.h" namespace ltp { namespace segmentor { diff --git a/src/segmentor/segmentreader.h b/src/segmentor/segmentreader.h index 6e4f6ba51..7df5b028f 100644 --- a/src/segmentor/segmentreader.h +++ b/src/segmentor/segmentreader.h @@ -2,11 +2,11 @@ #define __LTP_SEGMENTOR_READER_H__ #include -#include "settings.h" -#include "instance.h" -#include "rulebase.h" -#include "strutils.hpp" -#include "codecs.hpp" +#include "segmentor/settings.h" +#include "segmentor/instance.h" +#include "segmentor/rulebase.h" +#include "utils/strutils.hpp" +#include "utils/codecs.hpp" namespace ltp { namespace segmentor { diff --git a/src/segmentor/segmentwriter.h b/src/segmentor/segmentwriter.h index 4a5fd21c0..7f0525f64 100644 --- a/src/segmentor/segmentwriter.h +++ b/src/segmentor/segmentwriter.h @@ -2,7 +2,7 @@ #define __LTP_SEGMENTOR_WRITER_H__ #include -#include "instance.h" +#include "segmentor/instance.h" namespace ltp { namespace segmentor { diff --git a/src/segmentor/featurevec.h b/src/utils/math/featurevec.h similarity index 65% rename from src/segmentor/featurevec.h rename to src/utils/math/featurevec.h index a0fdbbff0..8b84e4632 100644 --- a/src/segmentor/featurevec.h +++ b/src/utils/math/featurevec.h @@ -1,8 +1,8 @@ -#ifndef __LTP_SEGMENTOR_FEATURE_VECTOR_H__ -#define __LTP_SEGMENTOR_FEATURE_VECTOR_H__ +#ifndef __LTP_FEATURE_VECTOR_H__ +#define __LTP_FEATURE_VECTOR_H__ namespace ltp { -namespace segmentor { +namespace math { struct FeatureVector { public: @@ -31,7 +31,7 @@ struct FeatureVector { int loff; }; -} // end for namespace segmentor +} // end for namespace math } // end for namespace ltp -#endif // end for __LTP_SEGMENTOR_FEATRUE_VECTOR_H__ +#endif // end for __LTP_FEATRUE_VECTOR_H__