LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
SimpleAnalysisDictionaryIterators.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 ***************************************************************************/
10
11#include "SimpleAnalysisDictionaryIterators.h"
12#include "SimpleAnalysisDictionary.h"
13
14#include "common/misc/strwstrtools.h"
15
16using namespace std;
17using namespace Lima::Common;
18
19namespace Lima
20{
21namespace LinguisticProcessing
22{
23namespace AnalysisDict
24{
25
26SimpleAnalysisDictionarySubWordIterator::SimpleAnalysisDictionarySubWordIterator(
27 const AccessSubWordIterator& it,
28 const SimpleAnalysisDictionary& dico,
29 const LimaString& key,
30 const int offset) :
31 ClonableDictionarySubWordIterator(),
32 m_accessItr(it),
33 m_dico(dico),
34 m_key(key),
35 m_offset(offset)
36{}
37
38SimpleAnalysisDictionarySubWordIterator::SimpleAnalysisDictionarySubWordIterator(const SimpleAnalysisDictionarySubWordIterator& source) :
39ClonableDictionarySubWordIterator(),
40 m_accessItr(source.m_accessItr),
41 m_dico(source.m_dico),
42 m_key(source.m_key),
43 m_offset(source.m_offset)
44{}
45
46SimpleAnalysisDictionarySubWordIterator::~SimpleAnalysisDictionarySubWordIterator() {}
47
48const std::pair<int,Dictionary::DictionaryEntry>
49SimpleAnalysisDictionarySubWordIterator::operator*() const
50{
51#ifdef DEBUG_CD
53 LDEBUG << "SimpleAnalysisDictionarySubWordIterator::operator*()";
54#endif
55 const std::pair<int,int64_t> pos =
56 *m_accessItr;
57
58#ifdef DEBUG_CD
59 LDEBUG << "SimpleAnalysisDictionarySubWordIterator::operator*(): m_access=("
60 << pos.first << "," << pos.second << ")"
61 ;
62#endif
63
64 int offset = pos.first;
65
66 // TODO: optimize it: access iterator knows it!
67 // reformation du mot
68 LimaString word(m_key, m_offset, offset - m_offset);
69 string word8 = Common::Misc::limastring2utf8stdstring(word);
70
71#ifdef DEBUG_CD
72 int dataOffset = m_dico.m_index2Data[pos.second-1];
73LDEBUG << "SimpleAnalysisDictionarySubWordIterator::operator*(): word=" << word8
74 << ", index =" << pos.second
75 << ", dataOffset =" << dataOffset;
76#endif
77
78 return std::pair<int, Dictionary::DictionaryEntry>
79 (offset, Dictionary::DictionaryEntry(
80 word, m_dico.m_stringStartAddr, m_dico.m_lingPropertiesStartAddr, m_dico.m_data+m_dico.m_index2Data[pos.second]));
81}
82
83
84SimpleAnalysisDictionarySuperWordIterator::SimpleAnalysisDictionarySuperWordIterator(
86 m_accessItr(it)
87{}
88
89
90SimpleAnalysisDictionarySuperWordIterator::SimpleAnalysisDictionarySuperWordIterator(const SimpleAnalysisDictionarySuperWordIterator& source) :
91 ClonableDictionarySuperWordIterator(),
92 m_accessItr(source.m_accessItr)
93{}
94
95SimpleAnalysisDictionarySuperWordIterator::~SimpleAnalysisDictionarySuperWordIterator()
96{}
97
98} // namespace AnalysisDict
99} // namespace LinguisticProcessing
100} // namespace Lima
#define LDEBUG
Definition LimaCommon.h:157
#define ANALYSISDICTLOGINIT
NAUTITIA.
QString LimaString
Definition LimaString.h:33
STL namespace.