LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
OffsetMapping.h
Go to the documentation of this file.
1// Copyright (C) 2016 by CEA - LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6#ifndef OFFSETMAPPING_H
7#define OFFSETMAPPING_H
8
11#include <iostream>
12#include <map>
13
14namespace Lima {
15namespace LinguisticProcessing {
16namespace AnalysisDumpers {
17
19public:
22
27 void addMapping(unsigned int offset, unsigned int newOffset);
28 void createInverseMapping();
29
30 void clear();
31
32 bool isEmpty() { return m_mappingNewToOld.size()==0; }
33
34 OffsetMapping operator+(unsigned int n) const;
35 void add(const OffsetMapping& otherMapping);
36
37 unsigned int getOriginalOffset(unsigned int newOffset) const;
38
39 void getNewOffsets(unsigned int prevOffset, std::vector<unsigned int>& newOffsets) const;
40
41 friend LIMA_ANALYSISDUMPERS_EXPORT std::ostream& operator<<(std::ostream& os, const OffsetMapping& offsetMapping);
42 std::string toString() const;
43
44private:
45 // expanded text duplicates some parts of the original text:
46 // hence, new to old mapping is n->1 whereas old to new mapping is 1->n
47 std::map<unsigned int, unsigned int> m_mappingNewToOld;
48 std::multimap<unsigned int, unsigned int> m_mappingOldToNew;
49};
50
51} // end namespace
52} // end namespace
53} // end namespace
54
55#endif
#define LIMA_ANALYSISDUMPERS_EXPORT
QDebug & operator<<(QDebug &qd, const std::string &str)
Definition QsLog.cpp:39
just for semantics: base class for analysisData
NAUTITIA.