diff --git a/docs/proc-uml.svg b/docs/proc-uml.svg index 34441a3..078e19c 100644 --- a/docs/proc-uml.svg +++ b/docs/proc-uml.svg @@ -1,88 +1 @@ -Regexid: numberregex: RegExpConstraintRegexlocation: LocationLocationBEFOREAFTERValueRegexRegexGroupid: numbervalueRegex?: ValueRegex | undefinedconstraintRegex: ConstraintRegex[]enabled: booleanCaptureAreaid: numberwidth: numberheight: numbertop: numberleft: numberregexGroups: RegexGroup[]enabled: booleanDesktopVideoStreamcurrentSelectedSource: ObjectdesktopCaptureSources: Object[]isLoadingScreensAndApplications: booleaninstance: DesktopVideoStreamfetchAllMediaStreams(): Promise<void>getDesktopCaptureSources(): Promise<void>getStreamSource(source: any): Promise<MediaStream>setCurrentSelectedSource(source: Object): voidsetIsLoadingScreensAndApplications(value: boolean): voidgetIsLoadingScreensAndApplications(): booleangetCurrentSelectedSource(): ObjectgetMainScreenSource(): ObjectgetOnlyScreenSources(): Object[]getOnlyApplicationSources(): Object[]getScreenAndApplicationSources(): Object[]getInstance(): DesktopVideoStreamRegexHandlerTesseractHandlerstream?: MediaStream | undefinedworker: Worker[]enabledCaptureAreas: CaptureArea[]Vigadmain(): void11*** \ No newline at end of file +ValueRegexRegexid: numberregex: RegExpmatching: Matchingslicing: Slicingsimilarity: SimilaritymatchesNum: numbersubstrings: { index: number; element: string; }[]lastBestMatch: { rating: number; match: { index: number; element: string;}; }lastRegex: RegExplastMatchesNum: numbergeneratedMatches: string[]getId(): numbergetRegex(): RegExpsetRegex(regex: string): voidgetMatching(): MatchingsetMatching(matching: Matching): voidgetSlicing(): SlicingsetSlicing(slicing: Slicing): voidgetSimilarity(): SimilaritysetSimilarity(similarity: Similarity): voidgetMatchesNum(): numbersetMatchesNum(matchesNum: number): voidgetSubstrings(): { index: number; element: string; }[]setSubstrings(substrings: { index: number; element: string; }[]): voidgetLastBestMatch(): { rating: number; match: { index: number; element: string;}; }genSubstrings(data: string): voidapplySimilarity(): voidgenMatches(max?: number): string[]getAllSubstrings(str: string): { index: number; element: string; }[]getBestMatch(data: string): { rating: number; match: { index: number; element: string;}; }repSimNumLet(str: string): stringrepSimLetNum(str: string): stringreplaceCharAt(str: string, index: number, replacement: string): stringindexOfFirst(data: string, before?: boolean): numberStringSimilaritycompareTwoStrings(first: string, second: string): numberfindBestMatch(mainString: string, targetStrings: string[]): { ratings: { target: string; rating: number; }[]; bestMatch: { target: string; rating: number; }; bestMatchIndex: number; }areArgsValid(mainString: string, targetStrings: string[]): booleanRegexHandlerinstance: RegexHandlerfindValue(data: string, valueRegex: ValueRegex, cRegexBefore?: ConstraintRegex | undefined, cRegexAfter?: ConstraintRegex | undefined): { rating: number; match: { index: number; element: string;}; }getInstance(): RegexHandlerbestMatch(data: string, genMatches: string[]): { target: string; rating: number; }approxMatching(substrings: { index: number; element: string; }[], regexMatches: string[]): { match: { index: number; element: string;}; rating: number; }MatchingEXACTAPPROXSlicingSUBSTRSPACESENTIRE_STRSimilarityNONENUM_LETLET_NUMConstraintRegexlocation: LocationgetLocation(): LocationsetLocation(location: Location): voidLocationBEFOREAFTERRegexGroupid: numbervalueRegex: ValueRegexconstraintRegex: ConstraintRegex[]enabled: booleangetValueRegex(): ValueRegexgetConstraintRegex(): ConstraintRegex[]CaptureAreaid: numberwidth: numberheight: numbertop: numberleft: numberregexGroups: RegexGroup[]enabled: booleangetId(): numbersetId(id: number): voidgetWidth(): numbersetWidth(width: number): voidgetHeight(): numbersetHeight(height: number): voidgetTop(): numbersetTop(top: number): voidgetLeft(): numbersetLeft(left: number): voidgetRegexGroups(): RegexGroup[]getStreamScales(stream: MediaStream, previewWidth: number, previewHeight: number): { width: number; height: number; left: number; top: number; }StreamHandlercurrentSelectedSource: MediaStreamdesktopCaptureSources: Object[]allMediaStreams: MediaStream[]isLoadingScreensAndApplications: booleaninstance: StreamHandlerfetchAllMediaStreams(): Promise<void>setIsLoadingScreensAndApplications(value: boolean): voidgetIsLoadingScreensAndApplications(): booleangetCurrentSelectedSource(): MediaStreamgetMediaStreamFromSource(source: any): Promise<MediaStream>getMainScreenSource(): Promise<Object>setDefaultVideoStream(): Promise<void>setCurrentSelectedSource(source: MediaStream): Promise<void>getAllMediaStreams(): Promise<MediaStream[]>populateMediaStreamsArray(source: any): Promise<void>getSpecificMediaStreams(index: number): Promise<MediaStream>getOnlyScreenSources(): Promise<Object[]>getOnlyApplicationSources(): Promise<Object[]>getScreenAndApplicationSources(): Promise<Object[]>getInstance(): StreamHandlerTesseractHandlerworker: Worker[]enabledCaptureAreas: CaptureArea[]running: booleaninstance: TesseractHandlerisRunning(): booleansetRunning(running: boolean): voidenableCaptureArea(ca: CaptureArea): Promise<void>addWorker(): Promise<void>removeWorker(): voidrun(stream: MediaStream, callback: Function, previewWidth: number, previewHeight: number): Promise<void>getInstance(): TesseractHandlerVigadstreamHandler: StreamHandlertesseractHandler: TesseractHandlerregexHandler: RegexHandlercaptureAreas: CaptureArea[]tesseractInterval: NodeJS.TimeoutintervalRunning: booleanpreviewWidth: numberpreviewHeight: numberinstance: VigadsetPreviewWidth(width: number): voidsetPreviewHeight(height: number): voidgetStreamHandlerInstance(): StreamHandleraddCaptureArea(width: number, height: number, top: number, left: number): numberdeleteCaptureArea(id: number): voidgetCaptureArea(id: number): CaptureAreagetAllCaptureAreas(): CaptureArea[]startTesseract(): voidstopTesseract(): voidgetInstance(): Vigad1111111***1111*1 \ No newline at end of file diff --git a/src/components/MainVideoStream.vue b/src/components/MainVideoStream.vue index 1af75bc..7d6bbe7 100644 --- a/src/components/MainVideoStream.vue +++ b/src/components/MainVideoStream.vue @@ -6,7 +6,9 @@ v-if="isRerendering" v-for="captureArea in captureAreas" :key="captureArea.getId()" - :stickSize="10" + :stickSize="7" + :minw="10" + :minh="10" contentClass="draggable-capture-area" :w="captureArea.getWidth()" :h="captureArea.getHeight()" diff --git a/src/proc/Vigad.ts b/src/proc/Vigad.ts index d5f0a51..a284cef 100644 --- a/src/proc/Vigad.ts +++ b/src/proc/Vigad.ts @@ -114,6 +114,8 @@ export class Vigad { this.regexHandler.findValue(value.data, regexGrp.getValueRegex(), regexGrp.getConstraintRegex()[1]); } else if (regexGrp.getConstraintRegex()[1].getRegex().toString() === "/(?:)/") { this.regexHandler.findValue(value.data, regexGrp.getValueRegex(), regexGrp.getConstraintRegex()[0]); + } else { + this.regexHandler.findValue(value.data, regexGrp.getValueRegex(), regexGrp.getConstraintRegex()[0], regexGrp.getConstraintRegex()[1]); } }); }, this.previewWidth, this.previewHeight); diff --git a/src/proc/regex/Regex.ts b/src/proc/regex/Regex.ts index 97f6df2..88e130e 100644 --- a/src/proc/regex/Regex.ts +++ b/src/proc/regex/Regex.ts @@ -101,6 +101,7 @@ export abstract class Regex { this.substrings = this.getAllSubstrings(data!); break; case Slicing.SPACES: + this.substrings = []; data.split(' ').forEach((element) => { this.substrings.push({ index: this.indexOfFirst(data), @@ -109,6 +110,7 @@ export abstract class Regex { }); break; case Slicing.ENTIRE_STR: + this.substrings = []; this.substrings.push({ index: 0, element: data }); break; } @@ -198,6 +200,7 @@ export abstract class Regex { }, }; } + return true; }); break; case Matching.APPROX: diff --git a/src/proc/regex/RegexHandler.ts b/src/proc/regex/RegexHandler.ts index b07c096..ea624db 100644 --- a/src/proc/regex/RegexHandler.ts +++ b/src/proc/regex/RegexHandler.ts @@ -31,6 +31,10 @@ export class RegexHandler { * @return {rating: number, match: {index: number, element: string}} */ public findValue(data:string, valueRegex: ValueRegex, cRegexBefore?: ConstraintRegex, cRegexAfter?: ConstraintRegex): {rating: number, match: {index: number, element: string}} { + + // replace all occurences of \n in data with spaces + data = data.replace(/\n/g, " "); + let constraintRegex: ConstraintRegex[] = []; if (typeof cRegexBefore !== 'undefined') { constraintRegex.push(cRegexBefore); @@ -66,13 +70,15 @@ export class RegexHandler { } // determine constraint indexes - let lowestHighIndex = 0; let highestLowIndex = 0; + let hLIPlus = 0; // highestLowIndex plus length of match + let lowestHighIndex = data.length; constraintRegex.forEach(regex => { switch (regex.getLocation()) { case "Before": - if (regex.getLastBestMatch().match.index > highestLowIndex) { + if (regex.getLastBestMatch().match.index >= highestLowIndex) { highestLowIndex = regex.getLastBestMatch().match.index; + hLIPlus = highestLowIndex + regex.getLastBestMatch().match.element.length; } break; case "After": @@ -82,10 +88,6 @@ export class RegexHandler { break; } }); - if (lowestHighIndex === 0) { - lowestHighIndex = data.length; - } - // set required substrings for value regex & apply similarity conversion if (highestLowIndex === 0 && lowestHighIndex === data.length) { // if no constraint regex if (valueRegex.getSlicing() === Slicing.SUBSTR && allSubstrings.length !== 0) { @@ -96,7 +98,8 @@ export class RegexHandler { valueRegex.genSubstrings(data); } } else { - valueRegex.genSubstrings(data.slice(highestLowIndex, lowestHighIndex)); + // this may be cached as well in the future, however performance optimization won't be as high + valueRegex.genSubstrings(data.slice(hLIPlus, lowestHighIndex)); } valueRegex.applySimilarity();