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
47de91c6
Commit
47de91c6
authored
12 years ago
by
Adam Radziszewski
Browse files
Options
Downloads
Patches
Plain Diff
fix iob-chan reader: dont complain when no channels at all
parent
8d58c6f9
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMakeLists.txt
+1
-1
1 addition, 1 deletion
CMakeLists.txt
libcorpus2/io/iob-chan.cpp
+21
-18
21 additions, 18 deletions
libcorpus2/io/iob-chan.cpp
with
22 additions
and
19 deletions
CMakeLists.txt
+
1
−
1
View file @
47de91c6
...
...
@@ -2,7 +2,7 @@ PROJECT(Corpus2Library)
set
(
corpus2_ver_major
"1"
)
set
(
corpus2_ver_minor
"1"
)
set
(
corpus2_ver_patch
"
0
"
)
set
(
corpus2_ver_patch
"
1
"
)
cmake_minimum_required
(
VERSION 2.8.0
)
...
...
This diff is collapsed.
Click to expand it.
libcorpus2/io/iob-chan.cpp
+
21
−
18
View file @
47de91c6
...
...
@@ -145,13 +145,14 @@ Sentence::Ptr IobChanReader::actual_next_sentence()
}
std
::
vector
<
std
::
string
>
spl
;
boost
::
algorithm
::
split
(
spl
,
line
,
boost
::
is_any_of
(
"
\t
"
));
if
(
spl
.
size
()
!=
4
)
{
if
(
spl
.
size
()
!=
3
and
spl
.
size
()
!=
4
)
{
std
::
cerr
<<
"Invalid line: "
<<
line
<<
"("
<<
spl
.
size
()
<<
")
\n
"
;
}
else
{
const
std
::
string
&
orth
=
spl
[
0
];
const
std
::
string
&
lemma
=
spl
[
1
];
const
std
::
string
&
tag_string
=
spl
[
2
];
const
std
::
string
&
anns
=
spl
[
3
];
// if no annotations, let anns = ""
const
std
::
string
&
anns
=
(
spl
.
size
()
==
4
)
?
spl
[
3
]
:
""
;
Tag
tag
=
parse_tag
(
tag_string
);
Token
*
t
=
new
Token
();
t
->
set_orth
(
UnicodeString
::
fromUTF8
(
orth
));
...
...
@@ -165,24 +166,26 @@ Sentence::Ptr IobChanReader::actual_next_sentence()
t
->
set_wa
(
PwrNlp
::
Whitespace
::
Newline
);
}
s
->
append
(
t
);
std
::
vector
<
std
::
string
>
annsplit
;
boost
::
algorithm
::
split
(
annsplit
,
anns
,
boost
::
is_any_of
(
","
));
foreach
(
const
std
::
string
&
a
,
annsplit
)
{
std
::
vector
<
std
::
string
>
one_ann_split
;
boost
::
algorithm
::
split
(
one_ann_split
,
a
,
boost
::
is_any_of
(
"-"
));
if
(
one_ann_split
.
size
()
!=
2
)
{
std
::
cerr
<<
"Invalid annotation:"
<<
a
<<
"
\n
"
;
}
else
{
const
std
::
string
&
aname
=
one_ann_split
[
0
];
const
std
::
string
&
aiob
=
one_ann_split
[
1
];
Corpus2
::
IOB
::
Enum
iob
=
Corpus2
::
IOB
::
from_string
(
aiob
);
if
(
iob
==
Corpus2
::
IOB
::
PostLast
)
{
std
::
cerr
<<
"Invalid IOB tag: "
<<
aiob
<<
"
\n
"
;
if
(
!
anns
.
empty
())
{
std
::
vector
<
std
::
string
>
annsplit
;
boost
::
algorithm
::
split
(
annsplit
,
anns
,
boost
::
is_any_of
(
","
));
foreach
(
const
std
::
string
&
a
,
annsplit
)
{
std
::
vector
<
std
::
string
>
one_ann_split
;
boost
::
algorithm
::
split
(
one_ann_split
,
a
,
boost
::
is_any_of
(
"-"
));
if
(
one_ann_split
.
size
()
!=
2
)
{
std
::
cerr
<<
"Invalid annotation:"
<<
a
<<
"
\n
"
;
}
else
{
if
(
!
s
->
has_channel
(
aname
))
{
s
->
create_channel
(
aname
);
const
std
::
string
&
aname
=
one_ann_split
[
0
];
const
std
::
string
&
aiob
=
one_ann_split
[
1
];
Corpus2
::
IOB
::
Enum
iob
=
Corpus2
::
IOB
::
from_string
(
aiob
);
if
(
iob
==
Corpus2
::
IOB
::
PostLast
)
{
std
::
cerr
<<
"Invalid IOB tag: "
<<
aiob
<<
"
\n
"
;
}
else
{
if
(
!
s
->
has_channel
(
aname
))
{
s
->
create_channel
(
aname
);
}
s
->
get_channel
(
aname
).
set_iob_at
(
s
->
size
()
-
1
,
iob
);
}
s
->
get_channel
(
aname
).
set_iob_at
(
s
->
size
()
-
1
,
iob
);
}
}
}
...
...
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