Skip to content
Snippets Groups Projects
Commit 9da40d48 authored by Pawel Orlowicz's avatar Pawel Orlowicz
Browse files

Merge branch 'master' of nlp.pwr.wroc.pl:corpus2

parents 7a6aa7d8 8d0e3cf5
No related merge requests found
......@@ -2,7 +2,7 @@ PROJECT(Corpus2Library)
set(corpus2_ver_major "1")
set(corpus2_ver_minor "2")
set(corpus2_ver_patch "0")
set(corpus2_ver_patch "3")
cmake_minimum_required(VERSION 2.8.0)
......
......@@ -34,7 +34,7 @@ AnnotatedSentence::~AnnotatedSentence()
Sentence::Ptr AnnotatedSentence::clone_shared() const
{
boost::shared_ptr<AnnotatedSentence> copy;
copy = boost::make_shared<AnnotatedSentence>();
copy = boost::make_shared<AnnotatedSentence>(id_);
BOOST_FOREACH(const Token* t, tokens_) {
copy->append(t->clone());
}
......@@ -48,7 +48,7 @@ boost::shared_ptr<AnnotatedSentence> AnnotatedSentence::wrap_sentence(
boost::shared_ptr<AnnotatedSentence> a;
a = boost::dynamic_pointer_cast<AnnotatedSentence>(s);
if (!a) {
a = boost::make_shared<AnnotatedSentence>();
a = boost::make_shared<AnnotatedSentence>(s->id());
BOOST_FOREACH(Token* t, s->tokens()) {
a->append(t);
}
......@@ -63,7 +63,7 @@ boost::shared_ptr<AnnotatedSentence> AnnotatedSentence::wrap_sentence_clone(
boost::shared_ptr<AnnotatedSentence> a;
a = boost::dynamic_pointer_cast<AnnotatedSentence>(s);
if (!a) {
a = boost::make_shared<AnnotatedSentence>();
a = boost::make_shared<AnnotatedSentence>(s->id());
BOOST_FOREACH(Token* t, s->tokens()) {
a->append(t->clone());
}
......
......@@ -127,9 +127,20 @@ void CclWriter::paragraph_head()
void CclWriter::paragraph_head(const Chunk& c)
{
// in CCL format chunks may have at most two attributes:
// id (unique XML-style id) and type (typically p for paragraphs)
osi() << "<chunk";
BOOST_FOREACH(const Chunk::attr_map_t::value_type& v, c.attributes()) {
os() << " " << v.first << "=\"" << v.second << "\"";
if (c.has_attribute("id")) {
const std::string &val = c.get_attribute("id");
if (!val.empty()) {
os() << " id=\"" << val << "\"";
}
}
if (c.has_attribute("type")) {
const std::string &val = c.get_attribute("type");
if (!val.empty()) {
os() << " type=\"" << val << "\"";
}
}
os() << ">\n";
}
......
......@@ -151,6 +151,10 @@ protected:
return indent_;
}
/**
* Write indentation spaces to the output stream and return the stream
* for writing. Convenience function useful when starting new lines
* in the output. */
std::ostream& osi();
private:
......
......@@ -33,7 +33,7 @@ Sentence::~Sentence()
Sentence::Ptr Sentence::clone_shared() const
{
Sentence::Ptr s = boost::make_shared<Sentence>();
Sentence::Ptr s = boost::make_shared<Sentence>(id_);
BOOST_FOREACH(const Token* t, tokens_) {
s->append(t->clone());
}
......
......@@ -36,16 +36,14 @@ namespace whole {
class RelationWriter {
public:
/**
* Reads a document with relations
* Writes a document with relations
* @param rela_path path to file with relations
*/
RelationWriter(const std::string &rela_path);
/**
* Lazy relations accessor.
* If relations are not readed then read relations and returns list of them.
* @return List of readed relations
* Writes given vector of Relations to the file specified before
*/
void write(const std::vector< boost::shared_ptr<Relation> >& relations);
......
......@@ -28,7 +28,7 @@ Relation::Relation(const std::string& name,
{
}
boost::shared_ptr<Relation> Relation::rel_pt(){
boost::shared_ptr<Relation> Relation::clone_shared(){
relation_=boost::shared_ptr<Relation>(new Relation(name_,from_,to_));
return relation_;
}
......
......@@ -118,7 +118,8 @@ public:
return name_;
}
boost::shared_ptr<Relation> rel_pt();
///Shared pointer to copy of the relation
boost::shared_ptr<Relation> clone_shared();
private:
/// Direction name
......
......@@ -44,7 +44,7 @@ namespace whole {
void set_to(const DirectionPoint& dp);
void set_name(const std::string& s);
boost::shared_ptr<Relation> rel_pt();
boost::shared_ptr<Relation> clone_shared();
/* It must be renamed because "from" is python keyword */
%rename(rel_from) from() const;
const boost::shared_ptr<const DirectionPoint>& from() const;
......
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