Skip to content

Commit

Permalink
helper functions are nice and string_to_wostream should be gone
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-martian committed Jul 29, 2021
1 parent b66a970 commit 76f51c0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 65 deletions.
1 change: 0 additions & 1 deletion apertium/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 0 additions & 1 deletion apertium/apertium-prelatex.l
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <vector>
#include <apertium/latex_accentsmap.h>
#include <lttoolbox/string_utils.h>
#include <apertium/string_to_wostream.h>

extern "C" {
#if !defined(__STDC__)
Expand Down
57 changes: 7 additions & 50 deletions apertium/file_morpho_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ FileMorphoStream::get_next_word()

if(word->isAmbiguous())
{
vector<UString> &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;
Expand All @@ -81,63 +79,22 @@ 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'))
{
end_of_file = true;
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;
}
}
}
}
}

Expand Down
13 changes: 0 additions & 13 deletions apertium/string_to_wostream.h

This file was deleted.

0 comments on commit 76f51c0

Please sign in to comment.