LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
CompoundsCompatibilityBuilder.h
Go to the documentation of this file.
1// Copyright 2002-2022 CEA LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6#ifndef COMPOUNDS_COMPATIBILITY_BUILDER_H
7#define COMPOUNDS_COMPATIBILITY_BUILDER_H
8
9#include "CompoundsExport.h"
10#include<set>
11#include<vector>
12#include<list>
13#include<map>
14#include<iostream>
15
16namespace Lima
17{
18namespace LinguisticProcessing
19{
20namespace Compounds
21{
22
23LIMA_COMPOUNDS_EXPORT std::ostream& operator<<(std::ostream& os, const std::set< uint64_t >& subres);
24LIMA_COMPOUNDS_EXPORT std::ostream& operator<<(std::ostream& os, const std::vector< uint64_t >& subres);
25
27{
28public:
31
32 std::list< std::set< uint64_t > > computeCompatibilities(
33 std::map< uint64_t, std::set< uint64_t > >& exclusions,
34 std::map< uint64_t, bool >& sizes,
35 std::vector< uint64_t >& order);
36 std::list< std::set< uint64_t > > computeCompatibilitiesWithChain(
37 std::map< uint64_t, std::set< uint64_t > >& exclusions,
38 std::map< uint64_t, bool >& sizes,
39 std::vector< uint64_t >& order);
40
41 void displayResult(const std::list< std::set< uint64_t > >& searchSpace);
42
43 friend std::ostream& operator<<(std::ostream& os, const std::set< uint64_t >& subres);
44 friend std::ostream& operator<<(std::ostream& os, const std::vector< uint64_t >& subres);
45
46private:
47
48 std::vector< std::set< uint64_t > > buildSearchSpace(
49 std::map< uint64_t, std::set< uint64_t > >& exclusions,
50 const std::vector< uint64_t >& order);
51
52 struct SizeSorter
53 {
54 bool operator()(const std::set< uint64_t >& a, const std::set< uint64_t >& b) const
55 {
56 if (a.size() > b.size())
57 {
58 return true;
59 }
60 else if (a.size() < b.size())
61 {
62 return false;
63 }
64 else if (a.empty() && b.empty())
65 {
66 return false;
67 }
68 else
69 {
70 std::set< uint64_t >::const_reverse_iterator ita, ita_end;
71 std::set< uint64_t >::const_reverse_iterator itb, itb_end;
72 ita = a.rbegin(); ita_end = a.rend();
73 itb = b.rbegin(); itb_end = b.rend();
74 for (; ita != ita_end; ita++,itb++)
75 {
76 if (*ita > *itb)
77 return true;
78 }
79 }
80 return false;
81 }
82 };
83
84 std::set< std::set< uint64_t >, SizeSorter > removeVertexEntriesFromSearchSpace(
85 const std::vector< std::set< uint64_t > >& searchSpace,
86 std::map< uint64_t, bool >& sizes);
87
88
89 std::list< std::set< uint64_t > > removeIncludedVector(const std::set< std::set< uint64_t >, SizeSorter >& searchSpace);
90
91};
92
93} // SyntacticAnalysis
94} // LinguisticProcessing
95} // Lima
96
97#endif // COMPOUNDS_COMPATIBILITY_BUILDER_H
#define LIMA_COMPOUNDS_EXPORT
QDebug & operator<<(QDebug &qd, const std::string &str)
Definition QsLog.cpp:39
std::ostream & operator<<(std::ostream &os, const std::set< uint64_t > &subres)
NAUTITIA.