Flutter Config toJson/fromJson (#1893)
This commit is contained in:
committed by
GitHub
parent
808587accd
commit
70742b69ec
@@ -11,6 +11,16 @@ class OnlinePunctuationModelConfig {
|
||||
this.provider = 'cpu',
|
||||
this.debug = true});
|
||||
|
||||
factory OnlinePunctuationModelConfig.fromJson(Map<String, dynamic> json) {
|
||||
return OnlinePunctuationModelConfig(
|
||||
cnnBiLstm: json['cnnBiLstm'],
|
||||
bpeVocab: json['bpeVocab'],
|
||||
numThreads: json['numThreads'],
|
||||
provider: json['provider'],
|
||||
debug: json['debug'],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OnlinePunctuationModelConfig(cnnBiLstm: $cnnBiLstm, '
|
||||
@@ -18,6 +28,16 @@ class OnlinePunctuationModelConfig {
|
||||
'provider: $provider, debug: $debug)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'cnnBiLstm': cnnBiLstm,
|
||||
'bpeVocab': bpeVocab,
|
||||
'numThreads': numThreads,
|
||||
'provider': provider,
|
||||
'debug': debug,
|
||||
};
|
||||
}
|
||||
|
||||
final String cnnBiLstm;
|
||||
final String bpeVocab;
|
||||
final int numThreads;
|
||||
@@ -30,11 +50,23 @@ class OnlinePunctuationConfig {
|
||||
required this.model,
|
||||
});
|
||||
|
||||
factory OnlinePunctuationConfig.fromJson(Map<String, dynamic> json) {
|
||||
return OnlinePunctuationConfig(
|
||||
model: OnlinePunctuationModelConfig.fromJson(json['model']),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OnlinePunctuationConfig(model: $model)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'model': model.toJson(),
|
||||
};
|
||||
}
|
||||
|
||||
final OnlinePunctuationModelConfig model;
|
||||
}
|
||||
|
||||
@@ -90,7 +122,7 @@ class OnlinePunctuation {
|
||||
final ans = p.toDartString();
|
||||
|
||||
SherpaOnnxBindings.sherpaOnnxOnlinePunctuationFreeText?.call(p);
|
||||
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user