Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorYuri Gorshenin <y@maps.me>2016-12-06 13:13:00 +0300
committerYuri Gorshenin <y@maps.me>2016-12-08 18:59:22 +0300
commit6f88abce2c15ef0584d6a120d49291b74063b5b1 (patch)
tree5f3a2c20ecc9a28d08515660e61fca3816f1bf07 /base
parentbeb358d3b7015bdf6fb4ede96c74ae703ccb9940 (diff)
Review fixes.
Diffstat (limited to 'base')
-rw-r--r--base/levenshtein_dfa.cpp2
-rw-r--r--base/levenshtein_dfa.hpp13
2 files changed, 10 insertions, 5 deletions
diff --git a/base/levenshtein_dfa.cpp b/base/levenshtein_dfa.cpp
index fdf5423b7a..0586e83390 100644
--- a/base/levenshtein_dfa.cpp
+++ b/base/levenshtein_dfa.cpp
@@ -276,7 +276,7 @@ bool LevenshteinDFA::IsValid(State const & s) const
bool LevenshteinDFA::IsAccepting(Position const & p) const
{
- return m_size - p.m_offset <= p.m_errorsLeft;
+ return p.IsStandard() && m_size - p.m_offset <= p.m_errorsLeft;
}
bool LevenshteinDFA::IsAccepting(State const & s) const
diff --git a/base/levenshtein_dfa.hpp b/base/levenshtein_dfa.hpp
index 16aa635d77..3ba7bbb22c 100644
--- a/base/levenshtein_dfa.hpp
+++ b/base/levenshtein_dfa.hpp
@@ -16,10 +16,10 @@ namespace strings
// "bca" is three, not two. The code is based on the work "Fast
// String Correction with Levenshtein-Automata" by Klaus U. Schulz and
// Stoyan Mihov. For a fixed number of allowed errors and fixed
-// alphabet the construction time and size of automata is O(length of
-// the pattern), but the size grows exponentially with the number of
-// errors, so be reasonable and don't use this class when the number
-// of errors is too high.
+// alphabet the construction time and size of automata is
+// O(length of the pattern), but the size grows exponentially with the
+// number of errors, so be reasonable and don't use this class when
+// the number of errors is too high.
//
// *NOTE* The class *IS* thread-safe.
//
@@ -36,6 +36,11 @@ public:
Position() = default;
Position(size_t offset, uint8_t errorsLeft, bool transposed);
+ // SubsumedBy is a relation on two positions, which allows to
+ // efficiently remove unnecessary positions in a state. When the
+ // function returns true, it means that |rhs| is more powerful
+ // than the current position and it is safe to remove the current
+ // position from the state, if the state contains |rhs|.
bool SubsumedBy(Position const & rhs) const;
bool operator<(Position const & rhs) const;