LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
FsaAccessBuilderRandom16.h
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 FsaAccessBuilder16.h - description
8 -------------------
9 begin : mar mai 27 2003
10 copyright : (C) 2003 by Olivier Mesnard
11 email : olivier.mesnard@cea.fr
12 ***************************************************************************/
13
14/***************************************************************************
15 * Copyright (C) 2003 by CEA *
16 * author Olivier MESNARD olivier.mesnard@cea.fr *
17 * *
18 * Compact dictionnary based on finite state automata implemented with *
19 * Boost Graph library. *
20 * Algorithm is described in article from Daciuk, Mihov, Watson & Watson: *
21 * "Incremental Construction of Minimal Acyclic Finite State Automata" *
22 ***************************************************************************/
23#ifndef FSA_ACCESS_BUILDER_RANDOM16_H
24#define FSA_ACCESS_BUILDER_RANDOM16_H
25
26#include <vector>
27#include <boost/config.hpp>
28#include <boost/graph/adjacency_list.hpp>
29#include <boost/graph/adjacency_list.hpp>
30
31#include "FsaAccessReader16.h"
33
34namespace Lima {
35namespace Common {
36namespace FsaAccess {
37
39 public FsaAccessReader16<selected_graph_types16::builderGraphType> {
40 // type of graph
42
43 typedef boost::graph_traits<graphType>::vertex_descriptor dicoVertex;
44 typedef boost::graph_traits<graphType>::edge_descriptor dicoEdge;
45 typedef boost::graph_traits<graphType>::degree_size_type dico_degree_size;
46
47 public:
48 FsaAccessBuilderRandom16( bool trie_direction_fwd = true );
50 void addRandomWord( const Lima::LimaString & newWord ) override;
51
52 // For IO
53 void write( const std::string & filename );
54 void write( std::ostream &os );
55 void write( FsaAccessDataOutputHandler &oh );
56 FsaAccessIOHandler<graphType>* getFsaAccessIOHandler() const override;
57
58 protected:
59 void write ( AbstractFsaAccessOStreamWrapper &ow );
60 private:
61 void replaceOrRegister( dicoVertex candidateState,
62 PrefixIterator* prefixIt );
63 void merge( dicoVertex inRegister, dicoVertex tempState,
64 dicoVertex parentState, const ForwardPrefixIterator& textIt);
65 void suppressEdge(
66 const boost::graph_traits<graphType>::vertex_descriptor from,
67 const boost::graph_traits<graphType>::vertex_descriptor to,
68 const char32_t currentChar,
69 const Lima::LimaChar* const word_content,
70 const int32_t wordOffset );
71 void cloneVertex(
72 const boost::graph_traits<graphType>::vertex_descriptor oldTo,
73 const boost::graph_traits<graphType>::vertex_descriptor newTo );
74 void replaceEdge( const boost::graph_traits<graphType>::vertex_descriptor from,
75 const boost::graph_traits<graphType>::vertex_descriptor to,
76 const char32_t currentChar,
77 const int32_t wordOffset );
78 int updateHash( dicoVertex from,
79 PrefixIterator* prefixIt );
80 bool scanAndCloneConfluentStates( dicoVertex from,
81 PrefixIterator* prefixIt,
82 dicoVertex& lastState );
83 bool cloneConfluentStates(
84 char32_t currentChar,
85 int32_t wordOffset,
86 boost::graph_traits<selected_graph_types16::builderGraphType>::vertex_descriptor& toOldPath,
87 PrefixIterator* prefixIt,
88 boost::graph_traits<selected_graph_types16::builderGraphType>::vertex_descriptor fromNewPath,
89 boost::graph_traits<selected_graph_types16::builderGraphType>::vertex_descriptor& toNewPath );
90 void addEdge(
91 const boost::graph_traits<selected_graph_types16::builderGraphType>::vertex_descriptor from,
92 const boost::graph_traits<selected_graph_types16::builderGraphType>::vertex_descriptor to,
93 const char32_t currentChar,
94 const Lima::LimaChar* const word_content,
95 const int32_t wordOffset );
96 void initConversion( const boost::graph_traits<graphType>::vertex_descriptor from ) const;
97 void addSuffix( dicoVertex from, PrefixIterator* prefixIt ) override;
98 private:
99 dict_packing_type m_packingStatus;
100};
101
102
103} // namespace compactDict
104} // namespace Common
105} // namespace Lima
106
107#endif //FSA_ACCESS_BUILDER_RANDOM16_H
#define LIMA_FSAACCESS_EXPORT
Definition LimaCommon.h:130
define abstract interface for access method inherits to AbstractAccesByString with additional addRand...
NAUTITIA.
QChar LimaChar
Definition LimaString.h:30
QString LimaString
Definition LimaString.h:33
boost::adjacency_list< boost::vecS, boost::listS, boost::bidirectionalS, dicoVertexCountProperty > builderGraphType
Graph used for FsaDictBuilder container types are chosen for their efficiency in insertion bidirectio...