LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
bowBinaryReaderWriter.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 *
8 * @file bowBinaryReaderWriter.h
9 * @author Romaric Besancon (romaric.besancon@cea.fr)
10 * @date Tue Mar 20 2007
11 * copyright Copyright (C) 2007 by CEA LIST
12 * Project Common
13 *
14 * @brief reader writer of bow in binary format
15 *
16 *
17 ***********************************************************************/
18
19#ifndef BOWBINARYREADERWRITER_H
20#define BOWBINARYREADERWRITER_H
21
23
24#include <iostream>
25#include <vector>
26#include <map>
27#include <QtCore/QMap>
28#include <boost/shared_ptr.hpp>
29
30namespace Lima {
31 class ShiftFrom;
32namespace Common {
33namespace BagOfWords {
34
35class AbstractBoWDocumentHandler;
36class AbstractBoWElement;
37class BoWDocument;
38class BoWText;
39class BoWToken;
40class BoWRelation;
41class BoWNamedEntity;
42class BoWPredicate;
43enum BoWBlocType: unsigned char;
44// reader/writer are kept independent from BoW (instead of having
45// read/write functions in each BoW element) because it is easier
46// to handle common mappings (pointers, entity types etc).
47
55
56// reader and writer are not symmetrical : writer simply write infos;
57// reader must handle mappings
58class BoWBinaryReaderPrivate;
60{
61 public:
63 virtual ~BoWBinaryReader();
64
65 void readHeader(std::istream& file);
66 void readBoWText(std::istream& file,
67 BoWText& bowText);
68 BoWBlocType readBoWDocumentBlock(std::istream& file,
69 BoWDocument& document,
71 bool useIterator,
72 bool useIndexIterator);
73 boost::shared_ptr< Lima::Common::BagOfWords::AbstractBoWElement > readBoWToken(std::istream& file);
74 void readSimpleToken(std::istream& file,
75 boost::shared_ptr< BoWToken > token);
76 void readPredicate(std::istream& file,
77 boost::shared_ptr< BoWPredicate > bowPred);
78
79 BoWFileType getFileType() const;
80 std::string getFileTypeString() const;
81
82private:
84 BoWBinaryReader& operator=(const BoWBinaryReader&);
86};
87
90{
91 public:
92 BoWBinaryWriter(std::shared_ptr<const ShiftFrom> shiftFrom = std::shared_ptr<const ShiftFrom>());
93 virtual ~BoWBinaryWriter();
94
95 void writeHeader(std::ostream& file,
96 BoWFileType type) const;
97 void writeBoWText(std::ostream& file,
98 const BoWText& bowText) const;
99 void writeBoWDocument(std::ostream& file,
100 const BoWDocument& bowText) const;
101 void writeBoWToken(std::ostream& file,
102 const boost::shared_ptr< AbstractBoWElement > bowToken) const;
103 void writeSimpleToken(std::ostream& file,
104 const boost::shared_ptr< BoWToken > token) const;
105 void writePredicate(std::ostream& file,
106 const boost::shared_ptr< BoWPredicate > token) const;
107
108 private:
110 BoWBinaryWriter& operator=(const BoWBinaryWriter&);
112};
113
114} // end namespace
115} // end namespace
116} // end namespace
117
118#endif
#define LIMA_BOW_EXPORT
represent a document as a Bag Of Word, with associated document properties.
Definition bowDocument.h:57
This class represents a list of elements, that are pointers on polymmorphic tokens that can be simple...
Definition bowText.h:48
NAUTITIA.