From 645f3420d2b73a5b6544a5959c26da0b16ad6476 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20K=C4=99dzia?= <Pawel.Kedzia@pwr.wroc.pl>
Date: Thu, 17 Nov 2011 12:12:32 +0100
Subject: [PATCH] Relation wrapper

---
 swig/corpus2.i  |  1 +
 swig/relation.i | 57 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)
 create mode 100644 swig/relation.i

diff --git a/swig/corpus2.i b/swig/corpus2.i
index c791ab7..83890f2 100644
--- a/swig/corpus2.i
+++ b/swig/corpus2.i
@@ -12,6 +12,7 @@
 %include "chunk.i"
 %include "iob.i"
 %include "lexeme.i"
+%include "relation.i"
 %include "sentence.i"
 %include "tag.i"
 %include "tagset.i"
diff --git a/swig/relation.i b/swig/relation.i
new file mode 100644
index 0000000..d273e72
--- /dev/null
+++ b/swig/relation.i
@@ -0,0 +1,57 @@
+#ifndef SWIG_LIBCORPUS2_RELATION_I
+#define SWIG_LIBCORPUS2_RELATION_I
+
+%module libcorpusrelation
+%{
+  #include <libcorpus2/relation.h>
+%}
+
+%include "std_defs.i"
+%include "std_string.i"
+%include "boost_shared_ptr.i"
+
+// %feature("notabstract") Corpus2::TokenMetaData;
+%template(DirectionPointPtr) boost::shared_ptr<Corpus2::DirectionPoint>;
+%template(ConstDirectionPointPtr) boost::shared_ptr<const Corpus2::DirectionPoint>;
+%template(RelationPtr) boost::shared_ptr<Corpus2::Relation>;
+%template(ConstRelationPtr) boost::shared_ptr<const Corpus2::Relation>;
+
+namespace Corpus2 {
+  class DirectionPoint {
+  public:
+    DirectionPoint(const std::string, const std::string, const int);
+
+    const std::string sentence_id() const;
+    const std::string channel_name() const;
+    int annotation_number() const;
+  };
+
+  class Relation {
+  public:
+    /*
+    Relation(const std::string& name,
+       const boost::shared_ptr<const DirectionPoint> from,
+       const boost::shared_ptr<const DirectionPoint> to);
+    */
+    Relation(const std::string& name,
+       const DirectionPoint& from,
+       const DirectionPoint& to);
+    ~Relation();
+
+
+    /* It must be renamed because "from" is python keyword */
+    %rename(rel_from) from() const;
+    const boost::shared_ptr<const DirectionPoint>& from() const;
+    /* Also "to" for consistency should be renamed to rel_to */
+    %rename(rel_to) to() const;
+    const boost::shared_ptr<const DirectionPoint>& to() const;
+    /* ...and "name" to rel_name */
+    %rename(rel_name) name() const;
+    const std::string name() const;
+  };
+}
+
+using namespace std;
+using namespace Corpus2;
+
+#endif /* SWIG_LIBCORPUS2_RELATION_I */
-- 
GitLab