LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
ApproxStringMatcher.h
Go to the documentation of this file.
1// Copyright 2002-2020 CEA LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6#ifndef LIMA_MORPHOLOGICANALYSIS_APPROXSTRINGMATCHER_H
7#define LIMA_MORPHOLOGICANALYSIS_APPROXSTRINGMATCHER_H
8
16//#include "linguisticProcessing/core/Automaton/SpecificEntityAnnotation.h"
17
18#include "NameIndexResource.h"
19
20namespace Lima
21{
22namespace LinguisticProcessing
23{
24namespace MorphologicAnalysis
25{
26
27#define APPROX_STRING_MATCHER_CLASSID "ApproxStringMatcher"
28
29// TODO : à mettre dans le .cpp avec une implémentation private
30typedef struct _Suggestion {
31 // Position of candidate (number of unicode character) in search string
33 // length of candidate (number of unicode character)
35 // number of errors (delete/add) to match
37 // id of target in lexicon ??
38 // long unsigned int match_id;
40
41LIMA_DATA_EXPORT std::ostream& operator<<(std::ostream &os, const Suggestion& node);
42LIMA_DATA_EXPORT QDebug& operator<<(QDebug& os, const Suggestion& node);
43
44// TODO : à mettre dans le .cpp avec une implémentation private
45typedef struct _Solution {
46 // position of matched string in text
48 // list of vertex in graph
49 std::deque<LinguisticGraphVertex> vertices;
50 // matched string
52 // normalized string = matched element in lexicon
54 // length of matched string in text
55 uint64_t length;
57
58typedef struct _SolutionCompare {
59 bool operator() (const Solution& s1, const Solution& s2) const;
61
62LIMA_DATA_EXPORT std::ostream& operator<<(std::ostream &os, const Solution& solution);
63LIMA_DATA_EXPORT QDebug& operator<<(QDebug& os, const Solution& solution);
64
66{
67 typedef std::pair< std::basic_string<wchar_t>, std::basic_string<wchar_t> > Regex;
68 typedef std::vector<Regex> RegexMap;
69 typedef std::set<Solution,SolutionCompare> OrderedSolution;
70
71public:
73 virtual ~ApproxStringMatcher();
74
75 void init(
77 Manager* manager) override;
78
79 LimaStatusCode process(
80 AnalysisContent& analysis) const override;
81
82
83private:
84 void matchApproxTokenAndFollowers(
88 std::pair<NameIndex::const_iterator,NameIndex::const_iterator> nameRange,
89 OrderedSolution& result) const;
90
91 void computeVertexMatches(
92 const LinguisticGraph& g,
93 const LinguisticGraphVertex vStart,
94 const LinguisticGraphVertex vEnd,
95 const Suggestion& suggestion, Solution& tempResult) const;
96
97 int findApproxPattern(
98 const std::basic_string<wchar_t>& pattern, LimaString text,
99 std::vector<Suggestion>& suggestions, int nbMaxError) const;
100
101 void createVertex(
105 const Solution& solution,
107
108 QString wcharStr2LimaStr(const std::basic_string<wchar_t>& wstring) const;
109 std::basic_string<wchar_t> LimaStr2wcharStr(const QString& limastr) const;
110 std::basic_string<wchar_t> buildPattern(const std::basic_string<wchar_t>& normalizedForm) const;
111
112 MediaId m_language;
113 LinguisticCode m_neCode;
114 LinguisticCode m_neMicroCode;
116 FsaStringsPool* m_sp;
117 int m_nbMaxNumError;
118 int m_nbMaxDenError;
120 Common::MediaticData::EntityGroupId m_entityGroupId;
121 RegexMap m_regexes;
122 std::shared_ptr<NameIndexResource> m_nameIndex;
123};
124} // MorphologicAnalysis
125} // LinguisticProcessing
126} // Lima
127
128#endif
This file is the main header file for the data related to annotation graphs.
#define LIMA_DATA_EXPORT
Definition LimaCommon.h:128
A graph structure for linguistic analysis.
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, LinguisticVertexProperties > LinguisticGraph
Property to identify the chains in the graph.
#define LIMA_MORPHOLOGICANALYSIS_EXPORT
Defines a Factory to create Object of type Base.
Holds all data that pass through the ProcessUnits Analysis data are shared pointers,...
define abstract interface for access method
Holds an annotation graph and gives an API to manipulate it.
Manage initialization of InitializableObjects using configuration module and parameters.
struct Lima::LinguisticProcessing::MorphologicAnalysis::_Suggestion Suggestion
struct Lima::LinguisticProcessing::MorphologicAnalysis::_Solution Solution
struct Lima::LinguisticProcessing::MorphologicAnalysis::_SolutionCompare SolutionCompare
std::ostream & operator<<(ostream &os, const Suggestion &suggestion)
NAUTITIA.
LimaStatusCode
Definition LimaCommon.h:236
QString LimaString
Definition LimaString.h:33
bool operator()(const Solution &s1, const Solution &s2) const