diff --git a/src/ner/model.cpp b/src/ner/model.cpp deleted file mode 100644 index ecff88906..000000000 --- a/src/ner/model.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "ner/model.h" - -namespace ltp { -namespace ner { - -Model::Model() { -} - -Model::~Model() { -} - -void -Model::save(std::ostream & ofs) { - // write a signature into the file - char chunk[16] = {'o','t','n','e','r', '\0'}; - ofs.write(chunk, 16); - - int off = ofs.tellp(); - - unsigned labels_offset = 0; - unsigned lexicon_offset = 0; - unsigned feature_offset = 0; - unsigned parameter_offset = 0; - - write_uint(ofs, 0); // the label offset - write_uint(ofs, 0); // the cluster lexicon offset - write_uint(ofs, 0); // the features offset - write_uint(ofs, 0); // the parameter offset - - labels_offset = ofs.tellp(); - labels.dump(ofs); - - lexicon_offset = ofs.tellp(); - cluster_lexicon.dump(ofs); - - feature_offset = ofs.tellp(); - space.dump(ofs); - - parameter_offset = ofs.tellp(); - param.dump(ofs); - - ofs.seekp(off); - write_uint(ofs, labels_offset); - write_uint(ofs, lexicon_offset); - write_uint(ofs, feature_offset); - write_uint(ofs, parameter_offset); -} - -bool Model::load(std::istream & ifs) { - char chunk[16]; - ifs.read(chunk, 16); - - if (strcmp(chunk, "otner")) { - return false; - } - - unsigned labels_offset = read_uint(ifs); - unsigned lexicon_offset = read_uint(ifs); - unsigned feature_offset = read_uint(ifs); - unsigned parameter_offset = read_uint(ifs); - - ifs.seekg(labels_offset); - if (!labels.load(ifs)) { - return false; - } - - ifs.seekg(lexicon_offset); - if (!cluster_lexicon.load(ifs)) { - return false; - } - - ifs.seekg(feature_offset); - if (!space.load(labels.size(), ifs)) { - return false; - } - - ifs.seekg(parameter_offset); - if (!param.load(ifs)) { - return false; - } - - return true; -} - -} // end for namespace ner -} // end for namespace ltp diff --git a/src/ner/model.h b/src/ner/model.h deleted file mode 100644 index dfc8e1de4..000000000 --- a/src/ner/model.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef __LTP_NER_MODEL_H__ -#define __LTP_NER_MODEL_H__ - -#include "framework/serializable.h" -#include "ner/featurespace.h" -#include "ner/parameter.h" -#include "utils/smartmap.hpp" - -namespace ltp { -namespace ner { - -namespace utils = ltp::utility; - -class Model : public framework::Serializable { -public: - Model(); - ~Model(); - - /* - * get number of labels; - * - * @return int the number of labels - */ - inline int num_labels(void) { - return labels.size(); - } - - /* - * save the model to a output stream - * - * @param[out] ofs the output stream - */ - void save(std::ostream & ofs); - - /* - * load the model from an input stream - * - * @param[in] ifs the input stream - */ - bool load(std::istream & ifs); -public: - //! - utils::IndexableSmartMap labels; - - //! - FeatureSpace space; - - //! - Parameters param; - - //! - utils::SmartMap cluster_lexicon; -}; - -} // end for namespace ner -} // end for namespace ltp - -#endif // end for __LTP_NER_MODEL_H__