react-native-scanbot-sdk
Version:
Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS
73 lines (67 loc) • 2.26 kB
text/typescript
/// Auto-generated with ScanbotSDKCodegenV3. Modifications will be overwritten.
/// Generated from rtu-ui-v2/schemas/textpattern/TextPatternScannerUIResult.yaml
import { SymbolBox, WordBox } from '../../text_pattern_scanner/TextPatternScannerTypes';
import { ToJsonConfiguration } from '../../utils/json/JsonSerializationTypes';
import { DeepPartial, PartiallyConstructible } from '../../utils/utils';
/**
Configuration of the generic text scanner RTU UI result.
*/
export class TextPatternScannerUiResult extends PartiallyConstructible {
/**
Raw recognized string.
*/
public readonly rawText: string;
/**
Boxes for each recognized word.
*/
public readonly wordBoxes: WordBox[];
/**
Boxes for each recognized symbol.
*/
public readonly symbolBoxes: SymbolBox[];
/**
Confidence of the recognition.
Default is 0.0
*/
public readonly confidence: number = 0.0;
/** @param source {@displayType `DeepPartial<TextPatternScannerUiResult>`} */
public constructor(source: DeepPartial<TextPatternScannerUiResult> = {}) {
super();
if (source.rawText !== undefined) {
this.rawText = source.rawText;
} else {
throw new Error('rawText must be present in constructor argument');
}
if (source.wordBoxes !== undefined) {
this.wordBoxes = source.wordBoxes.map((it: any) => {
return new WordBox(it);
});
} else {
throw new Error('wordBoxes must be present in constructor argument');
}
if (source.symbolBoxes !== undefined) {
this.symbolBoxes = source.symbolBoxes.map((it: any) => {
return new SymbolBox(it);
});
} else {
throw new Error('symbolBoxes must be present in constructor argument');
}
if (source.confidence !== undefined) {
this.confidence = source.confidence;
}
}
public serialize(
config: ToJsonConfiguration = new ToJsonConfiguration()
): DeepPartial<TextPatternScannerUiResult> {
return {
rawText: this.rawText,
wordBoxes: this.wordBoxes.map((it: any) => {
return it.serialize(config);
}),
symbolBoxes: this.symbolBoxes.map((it: any) => {
return it.serialize(config);
}),
confidence: this.confidence,
};
}
}