LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
BowTextHandler.cpp
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 * Copyright (C) 2004-2012 by CEA LIST *
8 * *
9 ***************************************************************************/
10#include "BowTextHandler.h"
11
13
14using namespace std;
15using namespace Lima::Common::BagOfWords;
16
17namespace Lima
18{
19
20namespace LinguisticProcessing
21{
22
24 : AbstractTextualAnalysisHandler(),m_bowstream(0),m_writer(0),m_bowtext()
25{
26}
27
28
30{
31 if (m_writer!=0) {
32 delete m_writer;
33 }
34 if (m_bowstream!=0) {
35 delete m_bowstream;
36 }
37}
38
43
44
46{
47 m_writer->endAnalysis();
48 istringstream in(m_bowstream->str());
49 BoWBinaryReader reader;
50 reader.readHeader(in);
51 reader.readBoWText(in,m_bowtext);
52
53 // Insertion du bowtext au handler de contenu et de structure
55 CONTENT_ID contentId=get_LastContentId();
56 ContentHandler< BoWText >::addContent(contentId,m_bowtext);
57 Node node("BOW_TEXT_NAME2",
58 1,
59 1,
60 contentId,
61 2,
62 "",
63 "text",
64 "bow",
65 "bow",
66 0,
67 0,
68 0,
69 0
70 );
71 add_Node(node);
72}
73
74
76{
77 m_bowtext.clear();
78 if (m_bowstream!=0) {
79 delete m_bowstream;
80 m_bowstream=0;
81 }
82 //if (m_writer!=0) {
83 // delete m_writer;
84 // m_writer=0;
85 //}
86 if (m_writer == nullptr){
87 m_writer=new BowTextWriter();
88 }
89 m_bowstream=new std::ostringstream();
90 //m_writer=new BowTextWriter();
91 m_writer->setOut(m_bowstream);
92 m_writer->startAnalysis();
93// set_LastStructureId(1);
94}
95
96void BowTextHandler::handle(const char* buf, int length)
97{
98 m_writer->handle(buf,length);
99}
100
104
108
109void BowTextHandler::startNode( const std::string& /*elementName*/, bool /*forIndexing*/ )
110{
111}
112
116
117}
118
119}
void readBoWText(std::istream &file, BoWText &bowText)
This class represents a list of elements, that are pointers on polymmorphic tokens that can be simple...
Definition bowText.h:48
void addContent(CONTENT_ID ContentId, Content datas)
Ajouter un contenu au handler.
virtual void endAnalysis() override
function called by the LIMA analyzer on the end of a text part that is to be analyzed
virtual void startDocument(const Common::Misc::GenericDocumentProperties &props) override
notify the start of a new document, and give its properties
virtual void endNode(const Common::Misc::GenericDocumentProperties &props) override
notify the end of a hierarchyNode
virtual void startNode(const std::string &elementName, bool forIndexing) override
notify the start of a new hierarchyNode
Common::BagOfWords::BoWText & getBowText()
virtual void endDocument() override
notify the end of the document
virtual void startAnalysis() override
function called by the LIMA analyzer on start of a new document
virtual void handle(const char *buf, int length) override
gives content.
void setOut(std::ostream *out) override
set the output stream.
virtual void startAnalysis() override
function called by the LIMA analyzer on start of a new document
virtual void handle(const char *buf, int length) override
gives content.
virtual void endAnalysis() override
function called by the LIMA analyzer on the end of a text part that is to be analyzed
noeud de contenu au sein d'une structure.
Definition DataTypes.h:62
void add_Node(const Node &node)
void set_LastContentId(CONTENT_ID)
NAUTITIA.
uint64_t CONTENT_ID
Identifier of an feature content.
Definition DataTypes.h:45
STL namespace.