LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
searchGraph.h
Go to the documentation of this file.
1// Copyright 2002-2018 CEA LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6/************************************************************************
7 *
8 * @file searchGraph.h
9 * @author besancon (besanconr@zoe.cea.fr)
10 * @date Tue May 24 2005
11 * @version $Id$
12 * copyright Copyright (C) 2005-2018 by CEA LIST
13 * Project Automaton
14 *
15 * @brief classes to abstract the sense of search in the graph
16 * (forward/backward)
17 *
18 ***********************************************************************/
19#ifndef SEARCHGRAPH_H
20#define SEARCHGRAPH_H
21
22#include "AutomatonExport.h"
24#include <deque>
25
26namespace Lima {
27namespace LinguisticProcessing {
28namespace Automaton {
29
39
41public:
43 virtual ~SearchGraph() {}
44 virtual void findNextVertices(const LinguisticGraph* graph,
45 const LinguisticGraphVertex& current) = 0;
46 virtual bool getNextVertex(const LinguisticGraph* graph,
47 LinguisticGraphVertex& next) = 0;
48 virtual SearchGraph* createNew() const = 0;
50 virtual void clear() = 0;
51 virtual void reinit() = 0;
52};
53
54#ifdef DEBUG_LP
55LIMA_AUTOMATON_EXPORT std::ostream& output(std::ostream& os, const SearchGraph *x, const LinguisticGraph* graph);
56#endif
57
59 public SearchGraph
60{
61public:
64 void findNextVertices(const LinguisticGraph* graph,
65 const LinguisticGraphVertex& current) override;
66 bool getNextVertex(const LinguisticGraph* graph,
67 LinguisticGraphVertex& next) override;
68 SearchGraph* createNew() const override;
70 void clear() override{
71 m_current.pop_back();
72 }
73 void reinit() override{
74 m_current.clear();
75 }
76
77 typedef std::pair<LinguisticGraphVertex,std::pair<LinguisticGraphInEdgeIt,LinguisticGraphInEdgeIt> > Vertex2EdgePair;
78
79private:
80 // use a deque for a stack so that can be clear()ed
81 std::deque<Vertex2EdgePair> m_current;
82
83#ifdef DEBUG_LP
84 friend LIMA_AUTOMATON_EXPORT std::ostream& output(std::ostream& os, const BackwardSearch::Vertex2EdgePair& x, const LinguisticGraph* graph);
85 friend LIMA_AUTOMATON_EXPORT std::ostream& output(std::ostream& os, const BackwardSearch& x, const LinguisticGraph* graph);
86#endif
87};
88
90 public SearchGraph
91{
92public:
95 void findNextVertices(const LinguisticGraph* graph,
96 const LinguisticGraphVertex& current) override;
97 bool getNextVertex(const LinguisticGraph* graph,
98 LinguisticGraphVertex& next) override;
99 SearchGraph* createNew() const override;
101 void clear() override {
102 m_current.pop_back();
103 }
104 void reinit() override {
105 m_current.clear();
106 }
107
108 typedef std::pair<LinguisticGraphVertex,std::pair<LinguisticGraphOutEdgeIt,LinguisticGraphOutEdgeIt> > Vertex2EdgePair;
109
110private:
111 // use a deque for a stack so that can be clear()ed
112 std::deque<Vertex2EdgePair> m_current;
113
114#ifdef DEBUG_LP
115 friend LIMA_AUTOMATON_EXPORT std::ostream& output(std::ostream& os, const ForwardSearch::Vertex2EdgePair& x, const LinguisticGraph* graph);
116 friend LIMA_AUTOMATON_EXPORT std::ostream& output(std::ostream& os, const ForwardSearch& x, const LinguisticGraph* graph);
117#endif
118};
119
120} // end namespace
121} // end namespace
122} // end namespace
123
124#endif
#define LIMA_AUTOMATON_EXPORT
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, LinguisticVertexProperties > LinguisticGraph
Property to identify the chains in the graph.
std::pair< LinguisticGraphVertex, std::pair< LinguisticGraphInEdgeIt, LinguisticGraphInEdgeIt > > Vertex2EdgePair
Definition searchGraph.h:77
std::pair< LinguisticGraphVertex, std::pair< LinguisticGraphOutEdgeIt, LinguisticGraphOutEdgeIt > > Vertex2EdgePair
virtual void findNextVertices(const LinguisticGraph *graph, const LinguisticGraphVertex &current)=0
virtual bool getNextVertex(const LinguisticGraph *graph, LinguisticGraphVertex &next)=0
virtual SearchGraph * createNew() const =0
virtual LinguisticGraphVertex endOfGraph(const LinguisticAnalysisStructure::AnalysisGraph &graph)=0
An AnalysisData containing a LinguisticGraph with a language and an id.
SearchGraphSense
enumerated type to indicate in which sense the automaton should be built or searched
Definition searchGraph.h:35
@ FORWARDSEARCH
forward search in the graph
Definition searchGraph.h:36
@ BACKWARDSEARCH
backward search in the graph
Definition searchGraph.h:37
NAUTITIA.