vsdk 8.1.0
 
Loading...
Searching...
No Matches
Vsdk::Asr::DynamicModelabstract

Model with dynamic data added at runtime. More...

#include <DynamicModel.hpp>

Public Member Functions

virtual ~DynamicModel ()=default
 
auto name () const -> std::string const &
 Name of this particular instance.
 
void addData (std::string const &slotName, std::string value, std::vector< std::string > phoneticTranscriptions={})
 Adds data to slot slotName.
 
void addData (std::string const &slotName, char const *value, std::vector< std::string > phoneticTranscriptions={})
 
template<typename T >
void addData (std::string const &slotName, T &&t, std::vector< std::string > phoneticTranscriptions={})
 Overload that takes any value that's convertible to std::string through std::to_string()
 
void removeData (std::string const &slotName, std::string const &exactValue)
 Removes the value exactValue from slot slotName.
 
void removeData (std::string const &slotName, std::function< bool(std::string const &)> predicate)
 Removes every value that matches predicate from slot slotName.
 
void clearData ()
 Removes all values for every slot.
 
virtual void compile ()=0
 Mandatory step before applying the model on a recognizer.
 

Protected Member Functions

 DynamicModel (std::string name) noexcept
 
virtual void configure (nlohmann::json const &)
 

Protected Attributes

std::string _name
 
std::unordered_map< std::string, std::vector< std::vector< std::string > > > _data
 

Detailed Description

Model with dynamic data added at runtime.

Constructor & Destructor Documentation

◆ DynamicModel()

DynamicModel::DynamicModel ( std::string  name)
explicitprotectednoexcept

◆ ~DynamicModel()

virtual Vsdk::Asr::DynamicModel::~DynamicModel ( )
virtualdefault

Member Function Documentation

◆ name()

auto DynamicModel::name ( ) const -> std::string const &

Name of this particular instance.

◆ addData() [1/3]

void DynamicModel::addData ( std::string const &  slotName,
std::string  value,
std::vector< std::string >  phoneticTranscriptions = {} 
)

Adds data to slot slotName.

Combining all data for a given slot is equivalent to writing the following rule in your grammar:

<slotName>: "value_1" | "value_2" | ...;
Note
Adding the same value twice will overwrite the previous value and phonetic transcriptions. Empty values are ignored altogether.
Warning
Some engines do not support custom phonetic (either one or multiple), refer to the particular engine documentation for more information.

◆ addData() [2/3]

void DynamicModel::addData ( std::string const &  slotName,
char const *  value,
std::vector< std::string >  phoneticTranscriptions = {} 
)

◆ addData() [3/3]

template<typename T >
void Vsdk::Asr::DynamicModel::addData ( std::string const &  slotName,
T &&  t,
std::vector< std::string >  phoneticTranscriptions = {} 
)

Overload that takes any value that's convertible to std::string through std::to_string()

◆ removeData() [1/2]

void DynamicModel::removeData ( std::string const &  slotName,
std::string const &  exactValue 
)

Removes the value exactValue from slot slotName.

◆ removeData() [2/2]

void DynamicModel::removeData ( std::string const &  slotName,
std::function< bool(std::string const &)>  predicate 
)

Removes every value that matches predicate from slot slotName.

◆ clearData()

void DynamicModel::clearData ( )

Removes all values for every slot.

◆ compile()

virtual void Vsdk::Asr::DynamicModel::compile ( )
pure virtual

Mandatory step before applying the model on a recognizer.

◆ configure()

virtual void Vsdk::Asr::DynamicModel::configure ( nlohmann::json const &  )
protectedvirtual

Member Data Documentation

◆ _name

std::string Vsdk::Asr::DynamicModel::_name
protected

◆ _data

std::unordered_map<std::string, std::vector<std::vector<std::string> > > Vsdk::Asr::DynamicModel::_data
protected