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
22
#include "
linguisticProcessing/LinguisticProcessingCommon.h
"
23
24
#include <iostream>
25
#include <vector>
26
#include <map>
27
#include <QtCore/QMap>
28
#include <boost/shared_ptr.hpp>
29
30
namespace
Lima
{
31
class
ShiftFrom
;
32
namespace
Common
{
33
namespace
BagOfWords
{
34
35
class
AbstractBoWDocumentHandler
;
36
class
AbstractBoWElement
;
37
class
BoWDocument
;
38
class
BoWText
;
39
class
BoWToken
;
40
class
BoWRelation
;
41
class
BoWNamedEntity
;
42
class
BoWPredicate
;
43
enum
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
48
enum
BoWFileType
:
unsigned
char
{
49
BOWFILE_NOTYPE
,
50
BOWFILE_TEXT
,
51
BOWFILE_DOCUMENT
,
52
BOWFILE_DOCUMENTST
,
53
BOWFILE_SDOCUMENT
54
};
55
56
// reader and writer are not symmetrical : writer simply write infos;
57
// reader must handle mappings
58
class
BoWBinaryReaderPrivate;
59
class
LIMA_BOW_EXPORT
BoWBinaryReader
60
{
61
public
:
62
BoWBinaryReader
();
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,
70
AbstractBoWDocumentHandler
& handler,
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
82
private
:
83
BoWBinaryReader
(
const
BoWBinaryReader
&);
84
BoWBinaryReader
& operator=(
const
BoWBinaryReader
&);
85
BoWBinaryReaderPrivate
* m_d;
86
};
87
88
class
BoWBinaryWriterPrivate
;
89
class
LIMA_BOW_EXPORT
BoWBinaryWriter
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
:
109
BoWBinaryWriter
(
const
BoWBinaryWriter
&);
110
BoWBinaryWriter
& operator=(
const
BoWBinaryWriter
&);
111
BoWBinaryWriterPrivate
* m_d;
112
};
113
114
}
// end namespace
115
}
// end namespace
116
}
// end namespace
117
118
#endif
LinguisticProcessingCommon.h
LIMA_BOW_EXPORT
#define LIMA_BOW_EXPORT
Definition
LinguisticProcessingCommon.h:80
Lima::Common::BagOfWords::AbstractBoWDocumentHandler
Definition
AbstractBoWDocumentHandler.h:38
Lima::Common::BagOfWords::AbstractBoWElement
This class is the abstract base class of all elements that can be stored in a BoWText.
Definition
AbstractBoWElement.h:72
Lima::Common::BagOfWords::BoWBinaryReaderPrivate
Definition
bowBinaryReaderWriter.cpp:41
Lima::Common::BagOfWords::BoWBinaryReader::readSimpleToken
void readSimpleToken(std::istream &file, boost::shared_ptr< BoWToken > token)
Definition
bowBinaryReaderWriter.cpp:326
Lima::Common::BagOfWords::BoWBinaryReader::readHeader
void readHeader(std::istream &file)
Definition
bowBinaryReaderWriter.cpp:110
Lima::Common::BagOfWords::BoWBinaryReader::getFileType
BoWFileType getFileType() const
Definition
bowBinaryReaderWriter.cpp:454
Lima::Common::BagOfWords::BoWBinaryReader::readBoWToken
boost::shared_ptr< Lima::Common::BagOfWords::AbstractBoWElement > readBoWToken(std::istream &file)
Definition
bowBinaryReaderWriter.cpp:273
Lima::Common::BagOfWords::BoWBinaryReader::readBoWText
void readBoWText(std::istream &file, BoWText &bowText)
Definition
bowBinaryReaderWriter.cpp:140
Lima::Common::BagOfWords::BoWBinaryReader::readBoWDocumentBlock
BoWBlocType readBoWDocumentBlock(std::istream &file, BoWDocument &document, AbstractBoWDocumentHandler &handler, bool useIterator, bool useIndexIterator)
Definition
bowBinaryReaderWriter.cpp:180
Lima::Common::BagOfWords::BoWBinaryReader::BoWBinaryReader
BoWBinaryReader()
Definition
bowBinaryReaderWriter.cpp:83
Lima::Common::BagOfWords::BoWBinaryReader::getFileTypeString
std::string getFileTypeString() const
Definition
bowBinaryReaderWriter.cpp:92
Lima::Common::BagOfWords::BoWBinaryReader::readPredicate
void readPredicate(std::istream &file, boost::shared_ptr< BoWPredicate > bowPred)
Definition
bowBinaryReaderWriter.cpp:359
Lima::Common::BagOfWords::BoWBinaryWriterPrivate
Definition
bowBinaryReaderWriter.cpp:463
Lima::Common::BagOfWords::BoWBinaryWriter::writeBoWToken
void writeBoWToken(std::ostream &file, const boost::shared_ptr< AbstractBoWElement > bowToken) const
Definition
bowBinaryReaderWriter.cpp:559
Lima::Common::BagOfWords::BoWBinaryWriter::writeBoWDocument
void writeBoWDocument(std::ostream &file, const BoWDocument &bowText) const
Definition
bowBinaryReaderWriter.cpp:551
Lima::Common::BagOfWords::BoWBinaryWriter::writeBoWText
void writeBoWText(std::ostream &file, const BoWText &bowText) const
Definition
bowBinaryReaderWriter.cpp:529
Lima::Common::BagOfWords::BoWBinaryWriter::writeSimpleToken
void writeSimpleToken(std::ostream &file, const boost::shared_ptr< BoWToken > token) const
Definition
bowBinaryReaderWriter.cpp:602
Lima::Common::BagOfWords::BoWBinaryWriter::BoWBinaryWriter
BoWBinaryWriter(std::shared_ptr< const ShiftFrom > shiftFrom=std::shared_ptr< const ShiftFrom >())
Definition
bowBinaryReaderWriter.cpp:500
Lima::Common::BagOfWords::BoWBinaryWriter::writeHeader
void writeHeader(std::ostream &file, BoWFileType type) const
Definition
bowBinaryReaderWriter.cpp:514
Lima::Common::BagOfWords::BoWBinaryWriter::writePredicate
void writePredicate(std::ostream &file, const boost::shared_ptr< BoWPredicate > token) const
Definition
bowBinaryReaderWriter.cpp:645
Lima::Common::BagOfWords::BoWDocument
represent a document as a Bag Of Word, with associated document properties.
Definition
bowDocument.h:57
Lima::Common::BagOfWords::BoWNamedEntity
This is a complex token used to represent a named entity token.
Definition
bowNamedEntity.h:34
Lima::Common::BagOfWords::BoWPredicate
This is a BoW element used to represent a predicate (n-ary relation, template or semantic frame).
Definition
BoWPredicate.h:33
Lima::Common::BagOfWords::BoWRelation
This class is used to type the relation between a part and its enclosing complex token.
Definition
BoWRelation.h:50
Lima::Common::BagOfWords::BoWText
This class represents a list of elements, that are pointers on polymmorphic tokens that can be simple...
Definition
bowText.h:48
Lima::Common::BagOfWords::BoWToken
This class contains the representation of an element of the bag of words.
Definition
bowToken.h:46
Lima::ShiftFrom
Definition
shiftFrom.h:26
Lima::Common::BagOfWords
Definition
MultimediaDocumentReaderWriter.h:15
Lima::Common::BagOfWords::BoWBlocType
BoWBlocType
Definition
bowDocument.h:34
Lima::Common::BagOfWords::BoWFileType
BoWFileType
Definition
bowBinaryReaderWriter.h:48
Lima::Common::BagOfWords::BOWFILE_DOCUMENT
@ BOWFILE_DOCUMENT
Definition
bowBinaryReaderWriter.h:51
Lima::Common::BagOfWords::BOWFILE_SDOCUMENT
@ BOWFILE_SDOCUMENT
Definition
bowBinaryReaderWriter.h:53
Lima::Common::BagOfWords::BOWFILE_DOCUMENTST
@ BOWFILE_DOCUMENTST
Definition
bowBinaryReaderWriter.h:52
Lima::Common::BagOfWords::BOWFILE_NOTYPE
@ BOWFILE_NOTYPE
Definition
bowBinaryReaderWriter.h:49
Lima::Common::BagOfWords::BOWFILE_TEXT
@ BOWFILE_TEXT
Definition
bowBinaryReaderWriter.h:50
Lima::Common
Definition
DynamicLibrariesManager.cpp:34
Lima
NAUTITIA.
Definition
AmosePluginsManager.h:15
lima_linguisticprocessing
src
linguisticProcessing
common
BagOfWords
bowBinaryReaderWriter.h
Generated by
1.15.0