LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
MultiLevelAnalysisDictionaryIterators.cpp
Go to the documentation of this file.
1// Copyright 2002-2013 CEA LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6/***************************************************************************
7 * Copyright (C) 2004-2012 by CEA LIST *
8 * *
9 ***************************************************************************/
11
12#include <iostream>
13#include <limits>
14#ifdef WIN32
15#undef min
16#undef max
17#endif
18#include <cassert>
19
20namespace Lima
21{
22
23namespace LinguisticProcessing
24{
25
26namespace AnalysisDict
27{
28
30 const std::vector<std::pair<Common::AccessSubWordIterator,Common::AccessSubWordIterator> >& accessItrs,
31 const MultiLevelAnalysisDictionary& dico) :
32 m_accessItrs(accessItrs),
33 m_dico(dico)
34{}
35
38
39const std::pair<uint64_t,DictionaryEntry>
41{
42
43 std::vector<uint64_t> indexes(m_dico.getDictionaryCount(),0);
44 auto indexItr = indexes.begin();
45 auto offset = std::numeric_limits< uint64_t >::max();
46 for (auto it = m_accessItrs.cbegin();
47 it != m_accessItrs.cend(); it++, indexItr++)
48 {
49 if (it->first != it->second)
50 {
51 auto data = *(it->first); // clazy:exclude=rule-of-two-soft
52 if (data.first < offset)
53 {
54 offset = data.first;
55 std::fill(indexes.begin(), indexes.end(), 0);
56 *indexItr = data.second;
57 }
58 else if (data.first == offset)
59 {
60 *indexItr = data.second;
61 }
62 }
63 }
64 return std::make_pair(offset, m_dico.getEntry(indexes));
65}
66
71
72
74{
75 // find lower offset
76 auto offset = std::numeric_limits<uint64_t>::max();
77 for (auto accessItr : m_accessItrs)
78 {
79 if (accessItr.first != accessItr.second)
80 {
81 auto data = *(accessItr.first);
82 if (data.first < offset)
83 {
84 offset = data.first;
85 }
86 }
87 }
88 // advance lower offset iteratos
89 for (auto accessItr : m_accessItrs)
90 {
91 if (accessItr.first != accessItr.second)
92 {
93 auto data = *(accessItr.first);
94 if (data.first == offset)
95 {
96 (accessItr.first)++;
97 }
98 }
99 }
100 return *this;
101}
102
104 const AbstractDictionarySubWordIterator& abit) const
105{
106 const auto& it = static_cast<const MultiLevelAnalysisDictionarySubWordIterator&>(abit);
107 return m_accessItrs == it.m_accessItrs;
108}
109
111{
112 const auto& it = static_cast<const MultiLevelAnalysisDictionarySubWordIterator&>(abit);
113 return m_accessItrs != it.m_accessItrs;
114}
115
116
118 const std::vector<Common::AccessSuperWordIterator>& it) :
119 m_accessItrs(it)
120{}
121
122
128
131
136
138{
139// const MultiLevelAnalysisDictionarySuperWordIterator& it=static_cast<const MultiLevelAnalysisDictionarySuperWordIterator&>(abit);
140// return m_accessItr.operator==(it.m_accessItr);
141 std::cerr << "unimplemented method at "<<__FILE__<<", line "<<__LINE__<<std::endl;
142 assert(false);
143 return false;
144}
145
147{
148// const MultiLevelAnalysisDictionarySuperWordIterator& it=static_cast<const MultiLevelAnalysisDictionarySuperWordIterator&>(abit);
149// return m_accessItr.operator!=(it.m_accessItr);
150 std::cerr << "unimplemented method at "<<__FILE__<<", line "<<__LINE__<<std::endl;
151 assert(false);
152 return true;
153}
154
159
161{
162// return *m_accessItr;
163 std::cerr << "unimplemented method at "<<__FILE__<<", line "<<__LINE__<< std::endl;
164 assert(false);
165 LimaString res;
166 return res;
167}
168
169}
170
171}
172
173}
virtual const std::pair< uint64_t, DictionaryEntry > operator*() const override
return subword data SubWord data are the ending offset of the subword, \ and the corresponding dictio...
MultiLevelAnalysisDictionarySubWordIterator(const std::vector< std::pair< Common::AccessSubWordIterator, Common::AccessSubWordIterator > > &accessItr, const MultiLevelAnalysisDictionary &dico)
virtual DictionaryEntry getEntry(const Lima::LimaString &word) const override
get dictionary entry for a word
NAUTITIA.
QString LimaString
Definition LimaString.h:33