Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ModuleHelpers/NLP/FormalityChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

namespace Targoman {
namespace Apps {

struct gConfigs{
struct Classifier{
static inline QString makeConfig(const QString& _name);
Expand All @@ -39,7 +40,8 @@ struct gConfigs{
static Targoman::Common::Configuration::tmplConfigurable<bool> SupportsIXML;
};
};
}

} // namespace Apps

namespace API {
namespace ModuleHelpers {
Expand Down
64 changes: 0 additions & 64 deletions Modules/MT/MT.h

This file was deleted.

24 changes: 8 additions & 16 deletions Modules/MT/MT.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,15 @@
# Redistribution and use in source and binary forms are allowed under the
# terms of BSD License 2.0.
################################################################################
ModuleName=MT
include($$QBUILD_PATH/templates/projectConfigs.pri)

HEADERS += \
Classes/intfTranslatorBridge.hpp \
Classes/intfTranslatorEngine.hpp \
Classes/TranslationDispatcher.h \
Engines/clsNMT.h \
TranslationDefs.hpp \
MT.h

SOURCES += \
Classes/TranslationDispatcher.cpp \
Engines/clsNMT.cpp \
MT.cpp
addSubdirs(moduleSrc, Dependencies)
#addSubdirs(functionalTest, Dependencies)

OTHER_FILES += \

################################################################################
include($$QBUILD_PATH/templates/moduleConfigs.pri)
migrations/db/* \
migrations/db/.dbdiff.dev_.cfg \
migrations/local/* \
migrations/local/*.sh \
migrations/local/.migrations

Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
# along with Targoman. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
/**
@author S. Mehran M. Ziabary <ziabary@targoman.com>
* @author S. Mehran M. Ziabary <ziabary@targoman.com>
* @author Kambiz Zandi <kambizzandi@gmail.com>
*/

#include <QVariantMap>
#include <QTime>
#include <QUrl>
Expand All @@ -27,35 +29,40 @@
#include "libTargomanTextProcessor/TextProcessor.h"
#include "Engines/clsNMT.h"
#include "Interfaces/AAA/AAA.hpp"
#include "Interfaces/NLP/FormalityChecker.h"
#include "ModuleHelpers/NLP/FormalityChecker.h"
#include "libTargomanCommon/Configuration/tmplConfigurableArray.hpp"

using namespace Targoman::API::ModuleHelpers::NLP;

namespace Targoman {
namespace API {
namespace Modules {
namespace Translation {
namespace Classes {
namespace Targoman::API::MTModule::Classes {

using namespace Apps;
using namespace NLPLibs;
using namespace DBManager;
using namespace Common;
using namespace Common::Configuration;
//using namespace Common::Configuration;
using namespace AAA;
using namespace NLP;
//using namespace NLP;

TranslationDispatcher::~TranslationDispatcher() { ; }

QVariantMap TranslationDispatcher::doTranslation(const QJsonObject& _privInfo,
QString _text,
const TranslationDir_t& _dir,
const QString& _engine,
bool _useSpecialClass,
bool _detailed,
bool _detokenize,
int& _preprocessTime,
int& _translationTime) {
if (_detailed && Authorization::hasPriv(_privInfo, {TARGOMAN_PRIV_PREFIX + "Detailed"}) == false)
QVariantMap TranslationDispatcher::doTranslation(
INTFAPICALLBOOM_DECL &APICALLBOOM_PARAM,
const QJsonObject& _privInfo,
QString _text,
const TranslationDir_t& _dir,
const QString& _engine,
bool _useSpecialClass,
bool _detailed,
bool _detokenize,
int& _preprocessTime,
int& _translationTime
) {
//@TODO: ujncomment and fix source of privInfo
/*
if (_detailed && Authorization::hasPriv(APICALLBOOM_PARAM, _privInfo, {TARGOMAN_PRIV_PREFIX + "Detailed"}) == false)
throw exAuthorization("Not enought priviledges to get detailed translation response.");

QTime CacheLookupTime; CacheLookupTime.start();
QString CacheKey = QCryptographicHash::hash(QString("%1:%2:%3:%4:%5").arg(_useSpecialClass).arg(_engine, _dir.first, _dir.second, _text).toUtf8(),QCryptographicHash::Md4).toHex();
QVariantMap CachedTranslation = this->TranslationCache[CacheKey];
Expand Down Expand Up @@ -107,6 +114,7 @@ QVariantMap TranslationDispatcher::doTranslation(const QJsonObject& _privInfo,
CachedTranslation[RESULTItems::CACHE] = CacheLookupTime.elapsed();
}
return CachedTranslation;
*/
}

QString TranslationDispatcher::detectClass(const QString& _engine, const QString& _text, const QString& _lang) {
Expand Down Expand Up @@ -185,8 +193,9 @@ void TranslationDispatcher::addTranslationLog(quint64 _aptID, const QString& _en

void TranslationDispatcher::registerEngines() {
foreach (const QString& Key, this->TranslationServers.keys()) {
const tmplConfigurableArray<stuTrServerConfig>& ServersConfig =
this->TranslationServers.values(Key);
const Targoman::Common::Configuration::tmplConfigurableArray<stuTrServerConfig>& ServersConfig =
this->TranslationServers.values(Key);

for (size_t i=0; i<ServersConfig.size(); ++i) {
stuTrServerConfig Server = ServersConfig.at(i);
if (Server.Active.value() == false)
Expand Down Expand Up @@ -224,8 +233,4 @@ TranslationDispatcher::TranslationDispatcher() {
/********************************************/
intfTranslatorEngine::~intfTranslatorEngine() { ; }

}
}
}
}
}
} // namespace Targoman::API::MTModule::Classes
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
# along with Targoman. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
/**
@author S. Mehran M. Ziabary <ziabary@targoman.com>
* @author S. Mehran M. Ziabary <ziabary@targoman.com>
* @author Kambiz Zandi <kambizzandi@gmail.com>
*/
#ifndef TARGOMAN_API_CLASSES_TRANSLATIONDISPATCHER_H
#define TARGOMAN_API_CLASSES_TRANSLATIONDISPATCHER_H

#ifndef TARGOMAN_API_MODULES_MT_CLASSES_TRANSLATIONDISPATCHER_H
#define TARGOMAN_API_MODULES_MT_CLASSES_TRANSLATIONDISPATCHER_H

#include <QJsonObject>
#include "libTargomanCommon/tmplBoundedCache.hpp"
#include "libTargomanCommon/Configuration/tmplConfigurableMultiMap.hpp"
#include "intfTranslatorEngine.hpp"
#include "Interfaces/Server/APICallBoom.h"
using namespace Targoman::API::Server;

namespace Targoman {
namespace API {
namespace Modules {
namespace Translation {
namespace Classes {
namespace Targoman::API::MTModule::Classes {

static QString TARGOMAN_PRIV_PREFIX = "Targoman:can";
static QString TARGOMAN_QUOTA_PREFIX = "Targoman:";
Expand All @@ -53,33 +53,36 @@ class TranslationDispatcher
private:
struct stuTrServerConfig{
stuTrServerConfig(const QString& _basePath);
Common::Configuration::tmplConfigurable<QUrl> URL;
Common::Configuration::tmplConfigurable<QString> Class;
Common::Configuration::tmplConfigurable<QString> SourceLang;
Common::Configuration::tmplConfigurable<QString> DestLang;
Common::Configuration::tmplConfigurable<bool> SupportsIXML;
Common::Configuration::tmplConfigurable<bool> Active;
struct stuStatistics{
Targoman::Common::Configuration::tmplConfigurable<QUrl> URL;
Targoman::Common::Configuration::tmplConfigurable<QString> Class;
Targoman::Common::Configuration::tmplConfigurable<QString> SourceLang;
Targoman::Common::Configuration::tmplConfigurable<QString> DestLang;
Targoman::Common::Configuration::tmplConfigurable<bool> SupportsIXML;
Targoman::Common::Configuration::tmplConfigurable<bool> Active;

struct stuStatistics {
stuStatistics(const QString& _basePath);
Common::Configuration::tmplConfigurable<quint64> OkResponses;
Common::Configuration::tmplConfigurable<quint64> FailedResponses;
}Statistics;
Targoman::Common::Configuration::tmplConfigurable<quint64> OkResponses;
Targoman::Common::Configuration::tmplConfigurable<quint64> FailedResponses;
} Statistics;
};
static Common::Configuration::tmplConfigurableMultiMap<stuTrServerConfig> TranslationServers;
static Targoman::Common::Configuration::tmplConfigurableMultiMap<stuTrServerConfig> TranslationServers;

public:
static TranslationDispatcher& instance() {static TranslationDispatcher* Instance = nullptr; return *(Q_LIKELY(Instance) ? Instance : (Instance = new TranslationDispatcher));}
~TranslationDispatcher();

QVariantMap doTranslation(const QJsonObject& _privInfo,
QString _text,
const TranslationDir_t& _dir,
const QString& _engine,
bool _useSpecialClass,
bool _detailed, bool _detokenize,
int& _preprocessTime,
int& _translationTime
);
QVariantMap doTranslation(
INTFAPICALLBOOM_DECL &APICALLBOOM_PARAM,
const QJsonObject& _privInfo,
QString _text,
const TranslationDir_t& _dir,
const QString& _engine,
bool _useSpecialClass,
bool _detailed, bool _detokenize,
int& _preprocessTime,
int& _translationTime
);

QString tokenize(const QString& _text, const QString& _lang);
QString detokenize(const QString& _text, const QString& _lang);
Expand Down Expand Up @@ -116,10 +119,6 @@ class TranslationDispatcher
QTime LastCorrectionRuleUpdateTime;
};

} //namespace Targoman::API::MTModule::Classes

}
}
}
}
}
#endif // TARGOMAN_API_CLASSES_TRANSLATIONDISPATCHER_H
#endif // TARGOMAN_API_MODULES_MT_CLASSES_TRANSLATIONDISPATCHER_H
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,22 @@
# along with Targoman. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
/**
@author S. Mehran M. Ziabary <ziabary@targoman.com>
* @author S. Mehran M. Ziabary <ziabary@targoman.com>
* @author Kambiz Zandi <kambizzandi@gmail.com>
*/
#ifndef TARGOMAN_API_CLASSES_INTFTRANSLATORBRIDGE_HPP
#define TARGOMAN_API_CLASSES_INTFTRANSLATORBRIDGE_HPP

#ifndef TARGOMAN_API_MODULES_MT_CLASSES_INTFTRANSLATORBRIDGE_HPP
#define TARGOMAN_API_MODULES_MT_CLASSES_INTFTRANSLATORBRIDGE_HPP

#include "intfTranslatorEngine.hpp"

namespace Targoman {
namespace API {
namespace Modules {
namespace Translation {
namespace Classes {
namespace Targoman::API::MTModule::Classes {

class intfTranslatorBridge : public intfTranslatorEngine{
public:

};

}
}
}
}
}
#endif // TARGOMAN_API_CLASSES_INTFTRANSLATORBRIDGE_HPP
} //namespace Targoman::API::MTModule::Classes

#endif // TARGOMAN_API_MODULES_MT_CLASSES_INTFTRANSLATORBRIDGE_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,20 @@
# along with Targoman. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
/**
@author S. Mehran M. Ziabary <ziabary@targoman.com>
* @author S. Mehran M. Ziabary <ziabary@targoman.com>
* @author Kambiz Zandi <kambizzandi@gmail.com>
*/
#ifndef TARGOMAN_API_CLASSES_INTFTRANSLATORENGINE_HPP
#define TARGOMAN_API_CLASSES_INTFTRANSLATORENGINE_HPP

#ifndef TARGOMAN_API_MODULES_MT_CLASSES_INTFTRANSLATORENGINE_HPP
#define TARGOMAN_API_MODULES_MT_CLASSES_INTFTRANSLATORENGINE_HPP

#include <QString>
#include <QVariantMap>
#include <QUrl>
#include "libTargomanCommon/Macros.h"
#include "TranslationDefs.hpp"

namespace Targoman {
namespace API {
namespace Modules {
namespace Translation {
namespace Classes {
#include "MTDefs.hpp"

namespace Targoman::API::MTModule::Classes {

TARGOMAN_DEFINE_ENHANCED_ENUM(enuEngine,
NMT,
Expand Down Expand Up @@ -92,9 +89,6 @@ class intfTranslatorEngine{
stuEngineSpecs EngineSpecs;
};

}
}
}
}
}
#endif // TARGOMAN_API_CLASSES_INTFTRANSLATORENGINE_HPP
} //namespace Targoman::API::MTModule::Classes

#endif // TARGOMAN_API_MODULES_MT_CLASSES_INTFTRANSLATORENGINE_HPP
Loading