Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
corpus2
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Analysers
corpus2
Commits
ff245095
Commit
ff245095
authored
12 years ago
by
jezozwierzak
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of nlp.pwr.wroc.pl:corpus2
parents
d55d81ca
2086ac32
Branches
Branches containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
libcorpus2_whole/io/relwriter.cpp
+27
-60
27 additions, 60 deletions
libcorpus2_whole/io/relwriter.cpp
libcorpus2_whole/io/relwriter.h
+2
-23
2 additions, 23 deletions
libcorpus2_whole/io/relwriter.h
swig/relationwriter.i
+5
-8
5 additions, 8 deletions
swig/relationwriter.i
with
34 additions
and
91 deletions
libcorpus2_whole/io/relwriter.cpp
+
27
−
60
View file @
ff245095
...
@@ -19,9 +19,11 @@ or FITNESS FOR A PARTICULAR PURPOSE.
...
@@ -19,9 +19,11 @@ or FITNESS FOR A PARTICULAR PURPOSE.
#include
<libcorpus2/exception.h>
#include
<libcorpus2/exception.h>
#include
<libcorpus2_whole/io/relwriter.h>
#include
<libcorpus2_whole/io/relwriter.h>
#include
<
f
stream>
#include
<
io
stream>
#include
<sstream>
#include
<sstream>
#include
<fstream>
#include
<boost/make_shared.hpp>
#include
<boost/make_shared.hpp>
using
namespace
std
;
namespace
Corpus2
{
namespace
Corpus2
{
namespace
whole
{
namespace
whole
{
...
@@ -33,73 +35,38 @@ RelationWriter::RelationWriter(const std::string &rela_path)
...
@@ -33,73 +35,38 @@ RelationWriter::RelationWriter(const std::string &rela_path)
void
RelationWriter
::
write
(
const
std
::
vector
<
boost
::
shared_ptr
<
Relation
>
>&
relations
)
void
RelationWriter
::
write
(
const
std
::
vector
<
boost
::
shared_ptr
<
Relation
>
>&
relations
)
{
{
file_
.
reset
(
new
std
::
ofstream
(
rela_path_
.
c_str
()
)
);
ofstream
ofs
(
rela_path_
.
c_str
()
,
ofstream
::
out
);
//header
//header
file_
->
write
(
"<relations>
\n
"
,
12
);
ofs
<<
"<relations>
\n
"
;
//relations
foreach
(
const
boost
::
shared_ptr
<
Relation
>&
r
,
relations
){
foreach
(
const
boost
::
shared_ptr
<
Relation
>&
r
,
relations
){
file_
->
write
(
" <rel name=
\"
"
,
14
);
ofs
<<
" <rel name=
\"
"
;
std
::
streamsize
size
=
r
->
name
().
size
();
ofs
<<
r
->
name
().
c_str
()
<<
"
\"
>"
<<
endl
;
file_
->
write
(
r
->
name
().
c_str
(),
size
);
ofs
<<
" <from sent=
\"
"
;
//Maybe additional info about set is needed in Relation class
ofs
<<
r
->
from
()
->
sentence_id
();
//file_->write("\" set=\"Anaphora\">\n",18);
ofs
<<
"
\"
chan=
\"
"
;
file_
->
write
(
"
\"
>
\n
"
,
3
);
ofs
<<
r
->
from
()
->
channel_name
();
file_
->
write
(
" <from sent=
\"
"
,
18
);
ofs
<<
"
\"
>"
;
size
=
r
->
from
()
->
sentence_id
().
size
();
ofs
<<
r
->
from
()
->
annotation_number
();
file_
->
write
(
r
->
from
()
->
sentence_id
().
c_str
(),
size
);
ofs
<<
"</from>"
<<
endl
;
file_
->
write
(
"
\"
chan=
\"
"
,
8
);
ofs
<<
" <to sent=
\"
"
;
size
=
r
->
from
()
->
channel_name
().
size
();
ofs
<<
r
->
to
()
->
sentence_id
();
file_
->
write
(
r
->
from
()
->
channel_name
().
c_str
(),
size
);
ofs
<<
"
\"
chan=
\"
"
;
file_
->
write
(
"
\"
>"
,
2
);
ofs
<<
r
->
to
()
->
channel_name
();
int
an_num
=
r
->
from
()
->
annotation_number
();
ofs
<<
"
\"
>"
;
std
::
ostringstream
ss
;
ofs
<<
r
->
to
()
->
annotation_number
();
ss
<<
an_num
;
ofs
<<
"</to>"
<<
endl
;
std
::
string
str
=
ss
.
str
();
ofs
<<
" </rel>"
<<
endl
;
size
=
str
.
size
();
file_
->
write
(
str
.
c_str
(),
size
);
file_
->
write
(
"</from>
\n
"
,
8
);
file_
->
write
(
" <to sent=
\"
"
,
16
);
size
=
r
->
to
()
->
sentence_id
().
size
();
file_
->
write
(
r
->
to
()
->
sentence_id
().
c_str
(),
size
);
file_
->
write
(
"
\"
chan=
\"
"
,
8
);
size
=
r
->
to
()
->
channel_name
().
size
();
file_
->
write
(
r
->
to
()
->
channel_name
().
c_str
(),
size
);
file_
->
write
(
"
\"
>"
,
2
);
an_num
=
r
->
to
()
->
annotation_number
();
std
::
ostringstream
ss1
;
ss1
<<
an_num
;
str
=
ss1
.
str
();
size
=
str
.
size
();
file_
->
write
(
str
.
c_str
(),
size
);
file_
->
write
(
"</to>
\n
"
,
6
);
//file_->write("\n",1);
file_
->
write
(
" </rel>"
,
9
);
file_
->
write
(
"
\n
"
,
1
);
}
}
//footer
//footer
file_
->
write
(
"</relations>"
,
12
)
;
ofs
<<
"</relations>"
;
file_
->
close
();
ofs
.
close
();
}
}
void
write_relation
(
const
boost
::
shared_ptr
<
Relation
>&
r
)
{
//std::streamsize size = r->from()->sentence_id().size();
//f->write(r->from()->sentence_id().c_str(),size);
}
void
do_header
(){
}
void
do_footer
(){
}
}
// whole ns
}
// whole ns
}
// Corpus2 ns
}
// Corpus2 ns
...
...
This diff is collapsed.
Click to expand it.
libcorpus2_whole/io/relwriter.h
+
2
−
23
View file @
ff245095
...
@@ -24,8 +24,6 @@ or FITNESS FOR A PARTICULAR PURPOSE.
...
@@ -24,8 +24,6 @@ or FITNESS FOR A PARTICULAR PURPOSE.
#include
<libcorpus2_whole/relation.h>
#include
<libcorpus2_whole/relation.h>
#include
<libcorpus2/io/xmlwriter.h>
#include
<iostream>
#include
<iostream>
namespace
Corpus2
{
namespace
Corpus2
{
...
@@ -33,8 +31,7 @@ namespace whole {
...
@@ -33,8 +31,7 @@ namespace whole {
/**
/**
* A reader for realtion documents. Note that document is read into memory
* A writer for realtion documents.
* before any processing may take place.
*/
*/
class
RelationWriter
{
class
RelationWriter
{
public:
public:
...
@@ -44,6 +41,7 @@ public:
...
@@ -44,6 +41,7 @@ public:
*/
*/
RelationWriter
(
const
std
::
string
&
rela_path
);
RelationWriter
(
const
std
::
string
&
rela_path
);
/**
/**
* Lazy relations accessor.
* Lazy relations accessor.
* If relations are not readed then read relations and returns list of them.
* If relations are not readed then read relations and returns list of them.
...
@@ -54,29 +52,10 @@ public:
...
@@ -54,29 +52,10 @@ public:
private:
private:
void
write_relation
(
const
boost
::
shared_ptr
<
Relation
>&
r
);
void
do_header
();
void
do_footer
();
// -------------------------------------------------------------------------
/// List of the relations in given relation file
std
::
vector
<
boost
::
shared_ptr
<
Relation
>
>
relations_
;
/// Path to file with relations
/// Path to file with relations
std
::
string
rela_path_
;
std
::
string
rela_path_
;
/// File pointer
boost
::
shared_ptr
<
std
::
ofstream
>
file_
;
// -------------------------------------------------------------------------
// Temporary information of actual parsing relation
std
::
string
rel_name_
;
std
::
string
ann_number_
;
boost
::
shared_ptr
<
DirectionPoint
>
rel_from_
;
boost
::
shared_ptr
<
DirectionPoint
>
rel_to_
;
};
};
}
// whole ns
}
// whole ns
...
...
This diff is collapsed.
Click to expand it.
swig/relationwriter.i
+
5
−
8
View file @
ff245095
...
@@ -9,14 +9,11 @@
...
@@ -9,14 +9,11 @@
namespace
Corpus2
{
namespace
Corpus2
{
namespace whole {
namespace whole {
class RelationWriter {
class RelationWriter {
public:
public:
RelationWriter(const std::string &rela_path);
RelationWriter(const std::string &rela_path);
void write(const std::vector< boost::shared_ptr<Relation> > relations);
void write(const std::vector< boost::shared_ptr<Relation> > relations);
private:
void do_header();
void do_footer();
//void write_relation(const boost::shared_ptr<Relation>& r);
};
};
} // whole ns
} // whole ns
}
// Corpus2 ns
}
// Corpus2 ns
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment