19#include <enchant/enchant++.h>
28namespace LinguisticProcessing
30namespace MorphologicAnalysis
50 std::shared_ptr<AnalysisDict::AbstractAnalysisDictionary>
m_dictionary;
76 catch (enchant::Exception& e)
85 m_d->
m_dictionary = std::dynamic_pointer_cast<AbstractAnalysisDictionary>(res);
89 LERROR <<
"no param 'dictionary' in EnchantSpellingAlternatives group for language " << (int) m_d->
m_language;
90 throw InvalidConfiguration(
"no param 'dictionary' in EnchantSpellingAlternatives group for language ");
99 LINFO <<
"MorphologicalAnalysis: starting process EnchantSpellingAlternatives";
102 auto tokenList=std::dynamic_pointer_cast<AnalysisGraph>(analysis.
getData(
"AnalysisGraph"));
107 for (boost::tie(it,itEnd)=vertices(*g) ; it != itEnd ; it++)
109 LDEBUG <<
"EnchantSpellingAlternatives::process processing vertex " << *it;
110 Token* currentToken=tokenMap[*it];
124 LINFO <<
"MorphologicalAnalysis: ending process EnchantSpellingAlternatives";
143 || tokenStr.toUpper() == tokenStr)
147 std::vector<std::string> suggestions =
m_enchantDictionary->suggest(tokenStr.toUtf8().constData());
148 for (std::vector<std::string>::const_iterator it = suggestions.begin(); it != suggestions.end();it++)
150 LimaString correction = LimaString::fromUtf8((*it).c_str());
152 if ( correction.size() > 1 && correction != tokenStr )
160 LINFO <<
"EnchantSpellingAlternativesPrivate::setEnchantSpellingAlternatives correcting" << tokenStr <<
"into" << correction;
162 StringsPoolIndex idx=sp[correction];
#define ENCHANT_SPELLING_ALTERNATIVES_CLASSID
#define LIMA_EXCEPTION(X)
This macro writes the message X to a previously configured error stream before throwing a LimaExcepti...
boost::property_map< LinguisticGraph, vertex_data_t >::type VertexDataPropertyMap
LinguisticGraph::vertex_iterator LinguisticGraphVertexIt
boost::property_map< LinguisticGraph, vertex_token_t >::type VertexTokenPropertyMap
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, LinguisticVertexProperties > LinguisticGraph
Property to identify the chains in the graph.
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
std::string & getParamsValueAtKey(const std::string &key)
return a message when a 'param' was not found
Manage initialization of InitializableObjects using configuration module and parameters.
const InitializationParameters & getInitializationParameters() const
get Initialization Parameters
Use this exception to signal an error in one of the configuration files.
bool hasLingInfos() const
void parseLingInfos(AbstractDictionaryEntryHandler *handler) const
Holds morphosyntactic informations.
AlphaCapitalType getAlphaCapital() const
bool isAlphaPossessive() const
bool isAlphaHyphen() const
bool isAlphaConcatAbbrev() const
holds surface data of a token
void addOrthographicAlternatives(StringsPoolIndex alt)
const TStatus & status() const
const LimaString & stringForm() const
virtual ~EnchantSpellingAlternativesPrivate()
void setEnchantSpellingAlternatives(LinguisticAnalysisStructure::Token *token, LinguisticAnalysisStructure::MorphoSyntacticData *tokenData, FsaStringsPool &sp)
EnchantSpellingAlternativesPrivate()
std::shared_ptr< AnalysisDict::AbstractAnalysisDictionary > m_dictionary
enchant::Dict * m_enchantDictionary
LimaStatusCode process(AnalysisContent &analysis) const override
Process on data in analysisContent.
virtual ~EnchantSpellingAlternatives()
EnchantSpellingAlternatives()
void init(Common::XMLConfigurationFiles::GroupConfigurationStructure &unitConfiguration, Manager *manager) override
initialize with parameters from configuration file.
static const LinguisticResources & single()
const singleton accessor
static MediaticData & changeable()
singleton accessor
static void updateCurrentTime(const std::string &taskCategory=std::string(""))
store current time for new elapsed time computation
SimpleFactory< MediaProcessUnit, EnchantSpellingAlternatives > enchantSpellingAlternativesFactory(ENCHANT_SPELLING_ALTERNATIVES_CLASSID)
launch exception related to the configuration file parsing