LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
limaSimpleClient.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 by CEA - LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6#include "limaSimpleClient.h"
8
9#include "common/LimaCommon.h"
10#include "common/LimaVersion.h"
18#include "common/QsLog/QsLog.h"
23
28
29#include <boost/algorithm/string/regex.hpp>
30#include <QtCore/QTimer>
31#include <QMetaType>
32
33using namespace Lima::LinguisticProcessing;
34using namespace Lima::Common::MediaticData;
35using namespace Lima::Common::Misc;
36using namespace std;
37
38namespace Lima {
39
40// utility function for debug
41std::string getThreadId()
42{
43 boost::thread::id id=boost::this_thread::get_id();
44 //std::thread::id id = std::this_thread::get_id();
45 ostringstream tid;
46 tid << id;
47 return tid.str();
48}
49
50//***********************************************************************
52m_delegate(nullptr)
53{
54}
55
57{
58 if (m_delegate!=nullptr) {
59 delete m_delegate;
60 }
61}
62
63void LimaSimpleClient::initialize(const std::string& language,
64 const std::string& pipeline)
65{
66 // remove existing one if exist, to ensure proper initialization
67 // -> do not remove existing delegate: contains the thread and the objects that communicate inside the thread
68 // (QCoreApplication, LimaController and LimaWorker)
69 //if (m_delegate!=nullptr) {
70 // delete m_delegate;
71 //}
72 if (m_delegate==nullptr) {
73 m_delegate=new LimaSimpleClientDelegate();
74 }
75 // just relaunch initialize
76 m_delegate->initialize(language,pipeline);
77
78}
79
80std::string LimaSimpleClient::analyze(const std::string& text)
81{
82 return m_delegate->analyze(text);
83}
84
85} // end namespace
void initialize(const std::string &language, const std::string &pipeline)
std::string analyze(const std::string &text)
std::string analyze(const std::string &text)
analyze a text, encoded in UTF-8.
void initialize(const std::string &language, const std::string &pipeline)
initialize the LIMA analyzer with one language and one pipeline
NAUTITIA.
std::string getThreadId()
STL namespace.