Skip to content
Snippets Groups Projects
Commit 75b314aa authored by Paweł Kędzia's avatar Paweł Kędzia
Browse files

Document contains path to file what was readed.

parent 64904b22
Branches
No related merge requests found
......@@ -20,8 +20,8 @@ or FITNESS FOR A PARTICULAR PURPOSE.
namespace Corpus2 {
namespace whole {
Document::Document()
: paragraphs_(), relations_()
Document::Document(const std::string& path)
: paragraphs_(), relations_(), path_(path)
{
}
......
......@@ -33,7 +33,10 @@ namespace whole {
class Document
{
public:
Document();
/**
* Path to file, if not set, then default is empty
*/
Document(const std::string& path = "");
~Document();
/// Adds paragraphs to document
......@@ -56,12 +59,20 @@ public:
return relations_;
}
/// Returns path to the document
const std::string& path() const {
return path_;
}
protected:
/// Paragraphs in document
std::vector< boost::shared_ptr<Chunk> > paragraphs_;
std::vector<boost::shared_ptr<Chunk> > paragraphs_;
/// Relations in document
std::vector< boost::shared_ptr<Relation> > relations_;
std::vector<boost::shared_ptr<Relation> > relations_;
/// Path to the file (if it's not a file, then is empty)
const std::string path_;
};
} // whole ns
......
......@@ -24,6 +24,7 @@ namespace whole {
: DocumentReaderI("document")
{
make_readers(tagset, annot_path, rela_path);
make_id_doc(annot_path, rela_path);
}
void DocumentReader::make_readers(const Tagset& tagset,
......@@ -33,10 +34,16 @@ namespace whole {
rel_reader_ = boost::make_shared<RelationReader>(rela_path);
}
void DocumentReader::make_id_doc(const std::string &annot_path,
const std::string &rela_path)
{
id_ = (annot_path + ";" + rela_path);
}
boost::shared_ptr<Document> DocumentReader::read()
{
boost::shared_ptr<Chunk> chunk;
boost::shared_ptr<Document> document = boost::make_shared<Document>();
boost::shared_ptr<Document> document = boost::make_shared<Document>(id_);
// Read ccl document and makes document
while (1) {
......
......@@ -78,12 +78,22 @@ private:
const std::string &annot_path,
const std::string &rela_path);
/**
* Based on given paths (annotations and relations) makes document identifier
* Document identifier is set to id_ class-state
*/
void make_id_doc(const std::string &annot_path,
const std::string &rela_path);
// -------------------------------------------------------------------------
/// Pointer to CclReader
boost::shared_ptr<CclReader> ccl_reader_;
/// Pointer to RelationReader
boost::shared_ptr<RelationReader> rel_reader_;
/// Future document identifier
std::string id_;
};
} // whole ns
......
......@@ -19,7 +19,7 @@ namespace Corpus2 {
namespace whole {
class Document {
public:
Document();
Document(const std::string& path = "");
~Document();
void add_paragraph(const boost::shared_ptr<Chunk> para);
......@@ -27,6 +27,8 @@ namespace whole {
const std::vector< boost::shared_ptr<Chunk> >& paragraphs() const;
const std::vector< boost::shared_ptr<Relation> >& relations() const;
const std::string& path() const;
};
} // whole ns
} // Corpus2 ns
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment