This class is responsible for parsing input like hi-there xx=yyy a=b c empty= f-oo=Append(bar, sss) ba_z=123 bing='a b c' baz="a b c d='a b' e" and giving you access to the fields, in this case. More...
#include <text-utils.h>
Public Member Functions | |
bool | ParseLine (const std::string &line) |
bool | GetValue (const std::string &key, std::string *value) |
bool | GetValue (const std::string &key, BaseFloat *value) |
bool | GetValue (const std::string &key, int32 *value) |
bool | GetValue (const std::string &key, std::vector< int32 > *value) |
bool | GetValue (const std::string &key, bool *value) |
bool | HasUnusedValues () const |
std::string | UnusedValues () const |
returns e.g. More... | |
const std::string & | FirstToken () const |
const std::string | WholeLine () |
Private Attributes | |
std::string | whole_line_ |
std::string | first_token_ |
std::map< std::string, std::pair< std::string, bool > > | data_ |
This class is responsible for parsing input like hi-there xx=yyy a=b c empty= f-oo=Append(bar, sss) ba_z=123 bing='a b c' baz="a b c d='a b' e" and giving you access to the fields, in this case.
FirstToken() == "hi-there", and key->value pairs:
xx->yyy, a->"b c", empty->"", f-oo->"Append(bar, sss)", ba_z->"123", bing->"a b c", baz->"a b c d='a b' e"
The first token is optional, if the line started with a key-value pair then FirstValue() will be empty.
Note: it can parse value fields with space inside them only if they are free of the '=' character. If values are going to contain the '=' character, you need to quote them with either single or double quotes.
Key values may contain -_a-zA-Z0-9, but must begin with a-zA-Z_.
Definition at line 205 of file text-utils.h.
|
inline |
Definition at line 228 of file text-utils.h.
References ConfigLine::first_token_.
Referenced by CompositeComponent::InitFromConfig(), kaldi::nnet3::ModifyNnetIvectorPeriod(), kaldi::nnet3::ReadEditConfig(), Nnet::RemoveRedundantConfigLines(), and kaldi::UnitTestConfigLineParse().
bool GetValue | ( | const std::string & | key, |
std::string * | value | ||
) |
Definition at line 427 of file text-utils.cc.
References ConfigLine::data_, and KALDI_ASSERT.
Referenced by LstmNonlinearityComponent::ConsolidateMemory(), PnormComponent::InitFromConfig(), DistributeComponent::InitFromConfig(), NormalizeComponent::InitFromConfig(), DropoutComponent::InitFromConfig(), RestrictedAttentionComponent::InitFromConfig(), ConvolutionComponent::InitFromConfig(), ElementwiseProductComponent::InitFromConfig(), BatchNormComponent::InitFromConfig(), StatisticsExtractionComponent::InitFromConfig(), TimeHeightConvolutionComponent::InitFromConfig(), LstmNonlinearityComponent::InitFromConfig(), StatisticsPoolingComponent::InitFromConfig(), AffineComponent::InitFromConfig(), TdnnComponent::InitFromConfig(), BackpropTruncationComponent::InitFromConfig(), MaxpoolingComponent::InitFromConfig(), BlockAffineComponent::InitFromConfig(), RepeatedAffineComponent::InitFromConfig(), NonlinearComponent::InitFromConfig(), ConstantComponent::InitFromConfig(), DropoutMaskComponent::InitFromConfig(), NaturalGradientAffineComponent::InitFromConfig(), GeneralDropoutComponent::InitFromConfig(), LinearComponent::InitFromConfig(), FixedAffineComponent::InitFromConfig(), SpecAugmentTimeMaskComponent::InitFromConfig(), SumGroupComponent::InitFromConfig(), FixedScaleComponent::InitFromConfig(), FixedBiasComponent::InitFromConfig(), NoOpComponent::InitFromConfig(), SumBlockComponent::InitFromConfig(), ClipGradientComponent::InitFromConfig(), PermuteComponent::InitFromConfig(), PerElementScaleComponent::InitFromConfig(), PerElementOffsetComponent::InitFromConfig(), ConstantFunctionComponent::InitFromConfig(), NaturalGradientPerElementScaleComponent::InitFromConfig(), ScaleAndOffsetComponent::InitFromConfig(), CompositeComponent::InitFromConfig(), UpdatableComponent::InitLearningRatesFromConfig(), Nnet::ProcessComponentConfigLine(), Nnet::ProcessComponentNodeConfigLine(), Nnet::ProcessDimRangeNodeConfigLine(), Nnet::ProcessInputNodeConfigLine(), Nnet::ProcessOutputNodeConfigLine(), kaldi::nnet3::ReadEditConfig(), Nnet::RemoveRedundantConfigLines(), and kaldi::UnitTestConfigLineParse().
Definition at line 440 of file text-utils.cc.
References kaldi::ConvertStringToReal(), ConfigLine::data_, and KALDI_ASSERT.
Definition at line 454 of file text-utils.cc.
References kaldi::ConvertStringToInteger(), ConfigLine::data_, and KALDI_ASSERT.
Definition at line 468 of file text-utils.cc.
References ConfigLine::data_, KALDI_ASSERT, and kaldi::SplitStringToIntegers().
Definition at line 485 of file text-utils.cc.
References ConfigLine::data_, and KALDI_ASSERT.
bool HasUnusedValues | ( | ) | const |
Definition at line 510 of file text-utils.cc.
References ConfigLine::data_.
Referenced by kaldi::nnet3::GenerateRandomSimpleComponent(), PnormComponent::InitFromConfig(), DistributeComponent::InitFromConfig(), NormalizeComponent::InitFromConfig(), DropoutComponent::InitFromConfig(), ConvolutionComponent::InitFromConfig(), ElementwiseProductComponent::InitFromConfig(), BatchNormComponent::InitFromConfig(), StatisticsExtractionComponent::InitFromConfig(), LstmNonlinearityComponent::InitFromConfig(), StatisticsPoolingComponent::InitFromConfig(), AffineComponent::InitFromConfig(), BackpropTruncationComponent::InitFromConfig(), MaxpoolingComponent::InitFromConfig(), BlockAffineComponent::InitFromConfig(), RepeatedAffineComponent::InitFromConfig(), NonlinearComponent::InitFromConfig(), ConstantComponent::InitFromConfig(), NaturalGradientAffineComponent::InitFromConfig(), LinearComponent::InitFromConfig(), FixedAffineComponent::InitFromConfig(), SumGroupComponent::InitFromConfig(), FixedScaleComponent::InitFromConfig(), FixedBiasComponent::InitFromConfig(), NoOpComponent::InitFromConfig(), SumBlockComponent::InitFromConfig(), ClipGradientComponent::InitFromConfig(), PermuteComponent::InitFromConfig(), PerElementScaleComponent::InitFromConfig(), PerElementOffsetComponent::InitFromConfig(), ConstantFunctionComponent::InitFromConfig(), NaturalGradientPerElementScaleComponent::InitFromConfig(), ScaleAndOffsetComponent::InitFromConfig(), CompositeComponent::InitFromConfig(), Nnet::ProcessComponentConfigLine(), Nnet::ProcessComponentNodeConfigLine(), Nnet::ProcessDimRangeNodeConfigLine(), Nnet::ProcessInputNodeConfigLine(), Nnet::ProcessOutputNodeConfigLine(), kaldi::nnet3::ReadEditConfig(), and kaldi::UnitTestConfigLineParse().
bool ParseLine | ( | const std::string & | line | ) |
Definition at line 343 of file text-utils.cc.
References ConfigLine::data_, ConfigLine::first_token_, kaldi::IsValidName(), KALDI_WARN, and ConfigLine::whole_line_.
Referenced by kaldi::nnet3::GenerateRandomSimpleComponent(), CompositeComponent::InitFromConfig(), kaldi::nnet3::ModifyNnetIvectorPeriod(), and kaldi::UnitTestConfigLineParse().
std::string UnusedValues | ( | ) | const |
returns e.g.
foo=bar xxx=yyy if foo and xxx were not consumed by one of the GetValue() functions.
Definition at line 518 of file text-utils.cc.
References ConfigLine::data_.
Referenced by kaldi::nnet3::GenerateRandomSimpleComponent(), ConvolutionComponent::InitFromConfig(), BatchNormComponent::InitFromConfig(), StatisticsExtractionComponent::InitFromConfig(), LstmNonlinearityComponent::InitFromConfig(), StatisticsPoolingComponent::InitFromConfig(), AffineComponent::InitFromConfig(), MaxpoolingComponent::InitFromConfig(), RepeatedAffineComponent::InitFromConfig(), NaturalGradientAffineComponent::InitFromConfig(), LinearComponent::InitFromConfig(), SumBlockComponent::InitFromConfig(), PermuteComponent::InitFromConfig(), PerElementScaleComponent::InitFromConfig(), PerElementOffsetComponent::InitFromConfig(), ScaleAndOffsetComponent::InitFromConfig(), CompositeComponent::InitFromConfig(), Nnet::ProcessComponentConfigLine(), Nnet::ProcessComponentNodeConfigLine(), Nnet::ProcessDimRangeNodeConfigLine(), Nnet::ProcessInputNodeConfigLine(), Nnet::ProcessOutputNodeConfigLine(), kaldi::nnet3::ReadEditConfig(), and kaldi::UnitTestConfigLineParse().
|
inline |
Definition at line 230 of file text-utils.h.
References ConfigLine::whole_line_.
Referenced by kaldi::nnet3::GenerateRandomSimpleComponent(), PnormComponent::InitFromConfig(), DistributeComponent::InitFromConfig(), NormalizeComponent::InitFromConfig(), DropoutComponent::InitFromConfig(), RestrictedAttentionComponent::InitFromConfig(), ConvolutionComponent::InitFromConfig(), ElementwiseProductComponent::InitFromConfig(), StatisticsExtractionComponent::InitFromConfig(), TimeHeightConvolutionComponent::InitFromConfig(), LstmNonlinearityComponent::InitFromConfig(), StatisticsPoolingComponent::InitFromConfig(), AffineComponent::InitFromConfig(), TdnnComponent::InitFromConfig(), BackpropTruncationComponent::InitFromConfig(), MaxpoolingComponent::InitFromConfig(), BlockAffineComponent::InitFromConfig(), RepeatedAffineComponent::InitFromConfig(), NonlinearComponent::InitFromConfig(), ConstantComponent::InitFromConfig(), NaturalGradientAffineComponent::InitFromConfig(), LinearComponent::InitFromConfig(), FixedAffineComponent::InitFromConfig(), SumGroupComponent::InitFromConfig(), FixedScaleComponent::InitFromConfig(), FixedBiasComponent::InitFromConfig(), NoOpComponent::InitFromConfig(), ClipGradientComponent::InitFromConfig(), PermuteComponent::InitFromConfig(), ConstantFunctionComponent::InitFromConfig(), NaturalGradientPerElementScaleComponent::InitFromConfig(), ScaleAndOffsetComponent::InitFromConfig(), CompositeComponent::InitFromConfig(), UpdatableComponent::InitLearningRatesFromConfig(), Nnet::ProcessComponentConfigLine(), Nnet::ProcessComponentNodeConfigLine(), Nnet::ProcessDimRangeNodeConfigLine(), Nnet::ProcessInputNodeConfigLine(), Nnet::ProcessOutputNodeConfigLine(), kaldi::nnet3::ReadEditConfig(), and Nnet::RemoveRedundantConfigLines().
|
private |
Definition at line 240 of file text-utils.h.
Referenced by ConfigLine::GetValue(), ConfigLine::HasUnusedValues(), ConfigLine::ParseLine(), and ConfigLine::UnusedValues().
|
private |
Definition at line 237 of file text-utils.h.
Referenced by ConfigLine::FirstToken(), and ConfigLine::ParseLine().
|
private |
Definition at line 233 of file text-utils.h.
Referenced by ConfigLine::ParseLine(), and ConfigLine::WholeLine().