commit 76f51c00d25fa76380df552435a5a0c97361d224 Author: Daniel Swanson Date: Thu Jul 29 11:48:20 2021 -0500 helper functions are nice and string_to_wostream should be gone diff --git a/apertium/Makefile.am b/apertium/Makefile.am index 5327ef2..5d774b5 100644 --- a/apertium/Makefile.am +++ b/apertium/Makefile.am @@ -37,7 +37,6 @@ h_sources = a.h \ stream.h \ stream_tagger.h \ streamed_type.h \ - string_to_wostream.h \ shell_utils.h \ tagger.h \ tagger_data.h \ diff --git a/apertium/apertium-prelatex.l b/apertium/apertium-prelatex.l index b06deb3..3df8bb0 100644 --- a/apertium/apertium-prelatex.l +++ b/apertium/apertium-prelatex.l @@ -11,7 +11,6 @@ #include #include #include -#include extern "C" { #if !defined(__STDC__) diff --git a/apertium/file_morpho_stream.cc b/apertium/file_morpho_stream.cc index 4cb8a76..4f1ed7f 100644 --- a/apertium/file_morpho_stream.cc +++ b/apertium/file_morpho_stream.cc @@ -61,10 +61,8 @@ FileMorphoStream::get_next_word() if(word->isAmbiguous()) { - vector &ref = td->getDiscardRules(); - for(unsigned int i = 0; i < ref.size(); i++) - { - word->discardOnAmbiguity(ref[i]); + for (auto& it : td->getDiscardRules()) { + word->discardOnAmbiguity(it); } } // cout << *word << endl; @@ -81,6 +79,10 @@ FileMorphoStream::get_next_word() while(true) { + UString str = input.readBlank(true); + if (!str.empty()) { + vwords[ivwords]->add_ignored_string(str); + } UChar32 symbol = input.get(); if(input.eof() || (null_flush && symbol == '\0')) { @@ -88,56 +90,11 @@ FileMorphoStream::get_next_word() vwords[ivwords]->add_tag(ca_tag_keof, ""_u, td->getPreferRules()); return get_next_word(); } - if(symbol == '^') + else if(symbol == '^') { readRestOfWord(ivwords); return get_next_word(); } - else - { - UString str = ""_u; - if(symbol == '\\') - { - symbol = input.get(); - str += '\\'; - str += symbol; - symbol = '\\'; - } - else - { - str += symbol; - } - - while(symbol != '^') - { - symbol = input.get(); - if(input.eof() || (null_flush && symbol == '\0')) { - end_of_file = true; - vwords[ivwords]->add_ignored_string(str); - vwords[ivwords]->add_tag(ca_tag_keof, ""_u, td->getPreferRules()); - return get_next_word(); - } else if(symbol == '\\') { - str += '\\'; - symbol = input.get(); - if(input.eof() || (null_flush && symbol == '\0')) { - end_of_file = true; - vwords[ivwords]->add_ignored_string(str); - vwords[ivwords]->add_tag(ca_tag_keof, ""_u, td->getPreferRules()); - return get_next_word(); - } - str += symbol; - symbol = '\\'; - } else if(symbol == '^') { - if(str.size() > 0) { - vwords[ivwords]->add_ignored_string(str); - } - readRestOfWord(ivwords); - return get_next_word(); - } else { - str += symbol; - } - } - } } } diff --git a/apertium/string_to_wostream.h b/apertium/string_to_wostream.h deleted file mode 100644 index b90eee8..0000000 --- a/apertium/string_to_wostream.h +++ /dev/null @@ -1,13 +0,0 @@ -// Include string_utils.h instead if you're linking against apertium - -#ifndef __STRING_TO_WOSTREAM_H_ -#define __STRING_TO_WOSTREAM_H_ - -#include - -std::wostream & operator<<(std::wostream & ostr, std::string const & str) { - ostr << str.c_str(); - return ostr; -} - -#endif