LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
deeplima::lemmatization::impl::LemmatizationImpl Class Reference

#include <deeplima/lemmatization/impl/lemmatization_impl.h>

Inheritance diagram for deeplima::lemmatization::impl::LemmatizationImpl:
deeplima::RnnSeq2Seq deeplima::eigen_wrp::EigenMatrix< Eigen::MatrixXf > deeplima::lemmatization::eigen_impl::BiRnnSeq2SeqEigenInferenceForLemmatization deeplima::eigen_impl::BiRnnInferenceBase

Public Member Functions

 LemmatizationImpl ()
 LemmatizationImpl (size_t threads, size_t buffer_size_per_thread)
virtual ~LemmatizationImpl ()=default
virtual void load (const std::string &fn, const PathResolver &)
void init (size_t max_input_word_len, const std::vector< std::string > &class_names, const std::vector< std::vector< std::string > > &class_values)
bool is_fixed (std::shared_ptr< StdMatrix< uint8_t > > classes, size_t idx)
morph_model::morph_feats_t get_morph_feats (std::shared_ptr< StdMatrix< uint8_t > > classes, size_t idx) const
void predict (const std::u32string &form, std::shared_ptr< StdMatrix< uint8_t > > classes, size_t idx, std::u32string &target)
Public Member Functions inherited from deeplima::RnnSeq2Seq
std::shared_ptr< StdMatrix< uint8_t > > get_output ()
 RnnSeq2Seq ()
void init (uint32_t, uint32_t, uint32_t, uint32_t, uint32_t)
void load (const std::string &fn)
virtual ~RnnSeq2Seq ()
Public Member Functions inherited from deeplima::eigen_wrp::EigenMatrix< Eigen::MatrixXf >
 EigenMatrix ()
 EigenMatrix (int64_t max_time, int64_t max_feat)
void init (int64_t max_time, int64_t max_feat)
void set (uint64_t time, uint64_t feat, value_t value)
void set (uint64_t time, EigenMatrix< Eigen::MatrixXf > &src, uint64_t src_time)
value_t get (uint64_t time, uint64_t feat)
uint64_t size () const
uint64_t get_max_feat () const
const Eigen::MatrixXf & get_tensor () const
Public Member Functions inherited from deeplima::lemmatization::eigen_impl::BiRnnSeq2SeqEigenInferenceForLemmatization
virtual ~BiRnnSeq2SeqEigenInferenceForLemmatization ()=default
virtual size_t init_new_worker (size_t input_len, bool precomputed_input=false) override
virtual size_t get_precomputed_dim () const
virtual void precompute_inputs (const Eigen::MatrixXf &inputs, Eigen::MatrixXf &outputs, int64_t input_size) override
virtual void predict (size_t, const Eigen::MatrixXf &, int64_t, int64_t, int64_t, int64_t, std::shared_ptr< StdMatrix< uint8_t > > &, const std::vector< std::string > &) override
virtual void predict (size_t worker_id, const Eigen::MatrixXf &inputs, const Eigen::MatrixXf &input_feats, int64_t input_len, int64_t output_max_len, int64_t, std::vector< uint32_t > &output, const std::vector< std::string > &)
const std::vector< std::vector< std::string > > & get_classes () const
const std::vector< std::string > & get_class_names () const
const morph_model::morph_model_t & get_morph_model () const
const std::string & get_embd_fn (size_t idx) const
const std::vector< size_t > & get_fixed_upos () const
Public Member Functions inherited from deeplima::eigen_impl::BiRnnInferenceBase
virtual ~BiRnnInferenceBase ()=default
const uint_dicts_holder_t & get_input_uint_dicts () const
const std::vector< std::string > & get_input_uint_dicts_names () const
const str_dicts_holder_t & get_input_str_dicts () const
const std::vector< std::string > & get_input_str_dicts_names () const
const std::vector< std::vector< std::string > > & get_output_str_dicts () const
const std::vector< std::string > & get_output_str_dicts_names () const

Protected Attributes

size_t m_beam_size
size_t m_max_input_word_len = 0
 max word length the encoder workbench / vectorizer were sized for (see init)
EmbdVectorizer m_vectorizer
EmbdVectorizer m_feat_vectorizer
std::vector< size_t > m_feat2cls
std::vector< std::vector< uint64_t > > m_feat_value_map
 per feature of the lemmatization model, its value index for each value index of the tagger (matched by name: empty when the tagger lacks the feature).
size_t m_upos_feat_idx = std::numeric_limits<size_t>::max()
 the upos feature in m_feat_value_map
size_t m_upos_idx
 index in the features matrix of the upos line
std::vector< bool > m_fixed_upos
 index i is true if upos whose index is i is considered as fixed
Protected Attributes inherited from deeplima::eigen_wrp::EigenMatrix< Eigen::MatrixXf >
int64_t m_start_time
int64_t m_max_time
Eigen::MatrixXf m_tensor
Protected Attributes inherited from deeplima::lemmatization::eigen_impl::BiRnnSeq2SeqEigenInferenceForLemmatization
std::vector< std::string > m_class_names
std::vector< std::vector< std::string > > m_classes
std::vector< std::string > m_embd_fn
morph_model::morph_model_t m_morph_model
std::vector< size_t > m_fixed_upos
std::vector< std::shared_ptr< workbench_t > > m_workbenches
Protected Attributes inherited from deeplima::eigen_impl::BiRnnInferenceBase
std::vector< std::shared_ptr< Op_Base > > m_ops
std::vector< std::shared_ptr< param_base_t > > m_params
std::vector< std::vector< std::shared_ptr< Op_Base::workbench_t > > > m_wb
uint_dicts_holder_t m_input_uint_dicts
std::vector< std::string > m_input_uint_dicts_names
str_dicts_holder_t m_input_str_dicts
std::vector< std::string > m_input_str_dicts_names
std::vector< std::vector< std::string > > m_output_str_dicts
std::vector< std::string > m_output_str_dicts_names
std::vector< params_bilstm_spec_t > m_lstm
std::map< std::string, size_t > m_lstm_idx
std::vector< std::shared_ptr< params_multilayer_bilstm_spec_t > > m_multi_bilstm
std::map< std::string, size_t > m_multi_bilstm_idx
std::vector< params_linear_t< Eigen::MatrixXf, Eigen::VectorXf > > m_linear
std::map< std::string, size_t > m_linear_idx

Additional Inherited Members

Public Types inherited from deeplima::eigen_wrp::EigenMatrix< Eigen::MatrixXf >
typedef Eigen::MatrixXf matrix_t
typedef Eigen::MatrixXf::Scalar value_t
Public Types inherited from deeplima::lemmatization::eigen_impl::BiRnnSeq2SeqEigenInferenceForLemmatization
using Parent = deeplima::eigen_impl::BiRnnInferenceBase
Public Types inherited from deeplima::eigen_impl::BiRnnInferenceBase
typedef Eigen::MatrixXf Matrix
typedef Eigen::VectorXf Vector
typedef float Scalar
typedef Eigen::MatrixXf tensor_t
typedef EmbdUInt64FloatHolder uint_dicts_holder_t
typedef EmbdStrFloatHolder str_dicts_holder_t
Protected Types inherited from deeplima::eigen_impl::BiRnnInferenceBase
typedef params_bilstm_t< Eigen::MatrixXf, Eigen::VectorXf > params_bilstm_spec_t
typedef params_multilayer_bilstm_t< Eigen::MatrixXf, Eigen::VectorXf > params_multilayer_bilstm_spec_t
Protected Member Functions inherited from deeplima::eigen_wrp::EigenMatrix< Eigen::MatrixXf >
Eigen::MatrixXf & get_tensor ()
Protected Member Functions inherited from deeplima::lemmatization::eigen_impl::BiRnnSeq2SeqEigenInferenceForLemmatization
virtual void convert_from_torch (const std::string &fn) override
Protected Member Functions inherited from deeplima::eigen_impl::BiRnnInferenceBase
virtual void convert_dicts_and_embeddings (const nets::BiRnnClassifierImpl &src)

Detailed Description

Definition at line 26 of file lemmatization_impl.h.

Constructor & Destructor Documentation

◆ LemmatizationImpl() [1/2]

deeplima::lemmatization::impl::LemmatizationImpl::LemmatizationImpl ( )

Definition at line 13 of file lemmatization_impl.cpp.

◆ LemmatizationImpl() [2/2]

deeplima::lemmatization::impl::LemmatizationImpl::LemmatizationImpl ( size_t threads,
size_t buffer_size_per_thread )

Definition at line 18 of file lemmatization_impl.cpp.

◆ ~LemmatizationImpl()

virtual deeplima::lemmatization::impl::LemmatizationImpl::~LemmatizationImpl ( )
virtualdefault

Member Function Documentation

◆ get_morph_feats()

morph_model::morph_feats_t deeplima::lemmatization::impl::LemmatizationImpl::get_morph_feats ( std::shared_ptr< StdMatrix< uint8_t > > classes,
size_t idx ) const

Definition at line 139 of file lemmatization_impl.cpp.

◆ init()

void deeplima::lemmatization::impl::LemmatizationImpl::init ( size_t max_input_word_len,
const std::vector< std::string > & class_names,
const std::vector< std::vector< std::string > > & class_values )

Definition at line 41 of file lemmatization_impl.cpp.

◆ is_fixed()

bool deeplima::lemmatization::impl::LemmatizationImpl::is_fixed ( std::shared_ptr< StdMatrix< uint8_t > > classes,
size_t idx )
Returns
true if the upos at index
Parameters
idxis fixed in the features matrix
classes.The upos line in the matrix is given by the member m_upos_idx.

Definition at line 129 of file lemmatization_impl.cpp.

◆ load()

void deeplima::lemmatization::impl::LemmatizationImpl::load ( const std::string & fn,
const PathResolver &  )
virtual

Definition at line 28 of file lemmatization_impl.cpp.

◆ predict()

void deeplima::lemmatization::impl::LemmatizationImpl::predict ( const std::u32string & form,
std::shared_ptr< StdMatrix< uint8_t > > classes,
size_t idx,
std::u32string & target )

Definition at line 172 of file lemmatization_impl.cpp.

Member Data Documentation

◆ m_beam_size

size_t deeplima::lemmatization::impl::LemmatizationImpl::m_beam_size
protected

Definition at line 58 of file lemmatization_impl.h.

◆ m_feat2cls

std::vector<size_t> deeplima::lemmatization::impl::LemmatizationImpl::m_feat2cls
protected

Definition at line 63 of file lemmatization_impl.h.

◆ m_feat_value_map

std::vector<std::vector<uint64_t> > deeplima::lemmatization::impl::LemmatizationImpl::m_feat_value_map
protected

per feature of the lemmatization model, its value index for each value index of the tagger (matched by name: empty when the tagger lacks the feature).

A tagger trained on another corpus numbers its values otherwise

Definition at line 67 of file lemmatization_impl.h.

◆ m_feat_vectorizer

EmbdVectorizer deeplima::lemmatization::impl::LemmatizationImpl::m_feat_vectorizer
protected

Definition at line 62 of file lemmatization_impl.h.

◆ m_fixed_upos

std::vector<bool> deeplima::lemmatization::impl::LemmatizationImpl::m_fixed_upos
protected

index i is true if upos whose index is i is considered as fixed

Definition at line 73 of file lemmatization_impl.h.

◆ m_max_input_word_len

size_t deeplima::lemmatization::impl::LemmatizationImpl::m_max_input_word_len = 0
protected

max word length the encoder workbench / vectorizer were sized for (see init)

Definition at line 60 of file lemmatization_impl.h.

◆ m_upos_feat_idx

size_t deeplima::lemmatization::impl::LemmatizationImpl::m_upos_feat_idx = std::numeric_limits<size_t>::max()
protected

the upos feature in m_feat_value_map

Definition at line 69 of file lemmatization_impl.h.

◆ m_upos_idx

size_t deeplima::lemmatization::impl::LemmatizationImpl::m_upos_idx
protected

index in the features matrix of the upos line

Definition at line 71 of file lemmatization_impl.h.

◆ m_vectorizer

EmbdVectorizer deeplima::lemmatization::impl::LemmatizationImpl::m_vectorizer
protected

Definition at line 61 of file lemmatization_impl.h.


The documentation for this class was generated from the following files: