Skip to content
Snippets Groups Projects
Commit 47de91c6 authored by Adam Radziszewski's avatar Adam Radziszewski
Browse files

fix iob-chan reader: dont complain when no channels at all

parent 8d58c6f9
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ PROJECT(Corpus2Library) ...@@ -2,7 +2,7 @@ PROJECT(Corpus2Library)
set(corpus2_ver_major "1") set(corpus2_ver_major "1")
set(corpus2_ver_minor "1") set(corpus2_ver_minor "1")
set(corpus2_ver_patch "0") set(corpus2_ver_patch "1")
cmake_minimum_required(VERSION 2.8.0) cmake_minimum_required(VERSION 2.8.0)
......
...@@ -145,13 +145,14 @@ Sentence::Ptr IobChanReader::actual_next_sentence() ...@@ -145,13 +145,14 @@ Sentence::Ptr IobChanReader::actual_next_sentence()
} }
std::vector<std::string> spl; std::vector<std::string> spl;
boost::algorithm::split(spl, line, boost::is_any_of("\t")); 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"; std::cerr << "Invalid line: " << line << "(" << spl.size() << ")\n";
} else { } else {
const std::string& orth = spl[0]; const std::string& orth = spl[0];
const std::string& lemma = spl[1]; const std::string& lemma = spl[1];
const std::string& tag_string = spl[2]; 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); Tag tag = parse_tag(tag_string);
Token* t = new Token(); Token* t = new Token();
t->set_orth(UnicodeString::fromUTF8(orth)); t->set_orth(UnicodeString::fromUTF8(orth));
...@@ -165,6 +166,7 @@ Sentence::Ptr IobChanReader::actual_next_sentence() ...@@ -165,6 +166,7 @@ Sentence::Ptr IobChanReader::actual_next_sentence()
t->set_wa(PwrNlp::Whitespace::Newline); t->set_wa(PwrNlp::Whitespace::Newline);
} }
s->append(t); s->append(t);
if (!anns.empty()) {
std::vector<std::string> annsplit; std::vector<std::string> annsplit;
boost::algorithm::split(annsplit, anns, boost::is_any_of(",")); boost::algorithm::split(annsplit, anns, boost::is_any_of(","));
foreach (const std::string& a, annsplit) { foreach (const std::string& a, annsplit) {
...@@ -188,6 +190,7 @@ Sentence::Ptr IobChanReader::actual_next_sentence() ...@@ -188,6 +190,7 @@ Sentence::Ptr IobChanReader::actual_next_sentence()
} }
} }
} }
}
if (s) { if (s) {
foreach (const AnnotatedSentence::chan_map_t::value_type& v, s->all_channels()) { foreach (const AnnotatedSentence::chan_map_t::value_type& v, s->all_channels()) {
s->get_channel(v.first).make_segments_from_iob(); s->get_channel(v.first).make_segments_from_iob();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment