diff --git a/libcorpus2/CMakeLists.txt b/libcorpus2/CMakeLists.txt index cada0f8635fbabf2a2bf0f79b7e5ab7ba6b19b2c..c4f079e7fb6a84f250af730bcca5a2f710403883 100644 --- a/libcorpus2/CMakeLists.txt +++ b/libcorpus2/CMakeLists.txt @@ -66,6 +66,7 @@ SET(libcorpus2_STAT_SRC io/plainwriter.cpp io/premorphwriter.cpp io/reader.cpp + io/relreader.cpp io/rft.cpp io/sax.cpp io/statwriter.cpp diff --git a/libcorpus2/io/relreader.cpp b/libcorpus2/io/relreader.cpp new file mode 100644 index 0000000000000000000000000000000000000000..db62c55dca4a25c9647365bdaae839ee21d915f4 --- /dev/null +++ b/libcorpus2/io/relreader.cpp @@ -0,0 +1,33 @@ +/* + Copyright (C) 2010 Tomasz Śniatowski, Adam Radziszewski, Paweł Kędzia + Part of the libcorpus2 project + + This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3 of the License, or (at your option) +any later version. + + This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. + + See the LICENSE and COPYING files for more details. +*/ + +#include <libcorpus2/io/relreader.h> +#include <boost/make_shared.hpp> + +namespace Corpus2 { +RelationReader::RelationReader(const std::string &rela_path) + : rela_path_(rela_path) +{ + readed_ = false; +} + +void RelationReader::read() +{ + // mark that document has been readed + readed_ = true; +} + +} /* end ns Corpus2 */ diff --git a/libcorpus2/io/relreader.h b/libcorpus2/io/relreader.h new file mode 100644 index 0000000000000000000000000000000000000000..d9e0a6b63291a0db32a9d0e633e02f39ecf4c2e3 --- /dev/null +++ b/libcorpus2/io/relreader.h @@ -0,0 +1,66 @@ +/* + Copyright (C) 2010 Tomasz Śniatowski, Adam Radziszewski, Paweł Kędzia + Part of the libcorpus2 project + + This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3 of the License, or (at your option) +any later version. + + This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. + + See the LICENSE and COPYING files for more details. +*/ + +#ifndef LIBCORPUS2_RELREADER_H +#define LIBCORPUS2_RELREADER_H + +#include <vector> +#include <boost/shared_ptr.hpp> +#include <libcorpus2/relation.h> + +namespace Corpus2 { + +/** + * A reader for realtion documents. Note that document is read into memory + * before any processing may take place. + */ +class RelationReader { +public: + /** + * Reads a document with relations + * @param rela_path path to file with relations + * TODO! Not implemented yet! + */ + RelationReader(const std::string &rela_path); + + /** + * Relations accessor. If relations are not readed then read relations + * and returns list of them. + * @return List of readed relations + */ + const std::vector< boost::shared_ptr<Relation> >& relations() { + if (!readed_) { + read(); + } + + return relations_; + } + +private: + void read(); + + /// List of the relations in given relation file + std::vector< boost::shared_ptr<Relation> > relations_; + + /// Path to file with relations + const std::string rela_path_; + + /// + bool readed_; +}; +} /* end ns Corpus2 */ + +#endif // LIBCORPUS2_RELREADER_H