diff --git a/libcorpus2/CMakeLists.txt b/libcorpus2/CMakeLists.txt index bc866c345cac128be6d971f5dde97c6a34ce1431..cada0f8635fbabf2a2bf0f79b7e5ab7ba6b19b2c 100644 --- a/libcorpus2/CMakeLists.txt +++ b/libcorpus2/CMakeLists.txt @@ -44,6 +44,7 @@ SET(libcorpus2_STAT_SRC document.cpp exception.cpp lexeme.cpp + relation.cpp sentence.cpp tag.cpp tagging.cpp diff --git a/libcorpus2/relation.cpp b/libcorpus2/relation.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8e22ca957c270838ae16cffea633c38013db9973 --- /dev/null +++ b/libcorpus2/relation.cpp @@ -0,0 +1,32 @@ +/* + 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/relation.h> + +namespace Corpus2 { + +Relation::Relation(const std::string& name, + const boost::shared_ptr<const DirectionPoint> from, + const boost::shared_ptr<const DirectionPoint> to) + : name_(name), from_(from), to_(to) +{ +} + +Relation::~Relation() +{ +} + +} /* end ns Corpus2 */ diff --git a/libcorpus2/relation.h b/libcorpus2/relation.h new file mode 100644 index 0000000000000000000000000000000000000000..4a0f2b235c6d9c9d7a61dd5a3256c155e54f3784 --- /dev/null +++ b/libcorpus2/relation.h @@ -0,0 +1,107 @@ +/* + 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_RELATIONT_H +#define LIBCORPUS2_RELATIONT_H + +#include <string> +#include <boost/shared_ptr.hpp> + +namespace Corpus2 { + +/** + * Helper class to represent one of two point of direction in any relation. + * Each relation has two points: from (source) and to (target) + */ +class DirectionPoint +{ +public: + /** + * @param sentence_id Sentence identifier + * @param channel_name Channel name + * @param annotation_number Annotation number + */ + DirectionPoint(const std::string sentence_id, + const std::string channel_name, + const int annotation_number) + : sentence_id_(sentence_id), channel_name_(channel_name), + annotation_number_(annotation_number) + { + // + } + + /// Sentence identifier accessor + const std::string sentence_id() const { + return sentence_id_; + } + + /// Channel name accessor + const std::string channel_name() const { + return channel_name_; + } + + /// Annotatio number accessor + int annotation_number() const { + return annotation_number_; + } + +private: + const std::string sentence_id_; + const std::string channel_name_; + const int annotation_number_; +}; + +/** + * Class to represent directed relation. As points of direction uses + * DirectionPoint class. Relation contains two points: from and to + */ +class Relation +{ +public: + /** + * Makes directed relation + * @param name Name of the relation + * @param from Source of relation direction + * @param to Target of relation direction + */ + Relation(const std::string& name, + const boost::shared_ptr<const DirectionPoint> from, + const boost::shared_ptr<const DirectionPoint> to); + + ~Relation(); + + /// Accessor to "from" direction point + const boost::shared_ptr<const DirectionPoint> from() const { + return from_; + } + + /// Accessor to "to" direction point + const boost::shared_ptr<const DirectionPoint> to() const { + return to_; + } + +private: + /// Direction name + const std::string& name_; + + /// Direction points: from and to + const boost::shared_ptr<const DirectionPoint> from_; + const boost::shared_ptr<const DirectionPoint> to_; +}; + +} /* end ns Corpus2 */ + +#endif // LIBCORPUS2_RELATIONT_H