LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
LangDetector.cpp
Go to the documentation of this file.
1#include "LangDetector.h"
2#include "LangDetectorCore.h"
9#include <iostream>
10#include <QtCore/QString>
11
13using namespace Lima::Common::Misc;
14
16{
17
19
24
26{
27 delete m_d;
28}
29
30
32{
33 QString fileName = Common::Misc::findFileInPaths(
34 Common::MediaticData::MediaticData::single().getResourcesPath().c_str(),
35 unitConfiguration.getParamsValueAtKey("langDetectorModel").c_str() );
36 m_d->loadModel(fileName.toStdString());
37}
38
41 LINFO << "start langdetector process";
42 QString* originalText=dynamic_cast<QString*>(analysis.getData("Text").get());
43 std::string langLabel = m_d->detectLang(originalText->toStdString());
45 LINFO << "The detected language is: "<<language;
46 return SUCCESS_ID;
47}
48
49
50}
#define LANGDETECTOR_CLASSID
#define LINFO
Definition LimaCommon.h:158
#define LANGDETECTORLOGINIT
Defines a Factory to create Object of type Base.
Holds all data that pass through the ProcessUnits Analysis data are shared pointers,...
std::shared_ptr< AnalysisData > getData(const QString &id)
return AnalysisData by id
Manage initialization of InitializableObjects using configuration module and parameters.
static std::string labelToPrintable(const std::string &label)
std::string detectLang(const std::string &text) const
LimaStatusCode process(AnalysisContent &analysis) const override
Process on data in analysisContent.
void init(Common::XMLConfigurationFiles::GroupConfigurationStructure &unitConfiguration, Manager *manager) override
initialize with parameters from configuration file.
static const MediaticData & single()
const singleton accessor
Definition Singleton.h:51
QString findFileInPaths(const QString &paths, const QString &fileName, const QChar &separator)
Find the given file in the given paths.
static SimpleFactory< MediaProcessUnit, LangDetector > langdetectorFactory(LANGDETECTOR_CLASSID)
LimaStatusCode
Definition LimaCommon.h:236
@ SUCCESS_ID
Definition LimaCommon.h:237
launch exception related to the configuration file parsing