forked from r.muellner/velum-raycast
Recheck project filenames and Word commenters
This commit is contained in:
@@ -9,6 +9,20 @@ export type BatchItem = { key: string; text: string };
|
||||
export type BatchSegment = BatchItem & { start: number; end: number };
|
||||
export type TextBatch = { text: string; segments: BatchSegment[] };
|
||||
|
||||
/** Filename separators look like spaces to NER, except inside known literal terms. */
|
||||
export function filenameScanText(stem: string, knownTerms: Iterable<string>): string {
|
||||
const protectedOffsets = new Set<number>();
|
||||
for (const term of knownTerms) {
|
||||
if (!term.includes("_")) continue;
|
||||
const escaped = term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
const pattern = new RegExp(`(?<![\\p{L}\\p{N}])${escaped}(?![\\p{L}\\p{N}])`, "giu");
|
||||
for (const match of stem.matchAll(pattern)) {
|
||||
for (let offset = match.index; offset < match.index + match[0].length; offset++) protectedOffsets.add(offset);
|
||||
}
|
||||
}
|
||||
return stem.replace(/_/g, (_character, offset: number) => protectedOffsets.has(offset) ? "_" : " ");
|
||||
}
|
||||
|
||||
/** Keep file boundaries while reducing many small text/path API calls to a few batches. */
|
||||
export function makeTextBatches(items: BatchItem[], limit = MAX_BATCH_CODEPOINTS): TextBatch[] {
|
||||
const batches: TextBatch[] = [];
|
||||
|
||||
@@ -112,6 +112,7 @@ export async function reviseProjectRun(args: {
|
||||
const { directory, run } = created;
|
||||
run.origin = previous.origin;
|
||||
run.revisedFrom = previous.id;
|
||||
run.commentAuthorCoverage = previous.commentAuthorCoverage;
|
||||
run.mapping = plan.mapping;
|
||||
run.matchModes = Object.fromEntries(Object.entries(previous.matchModes ?? {})
|
||||
.filter(([key]) => key in plan.mapping));
|
||||
|
||||
@@ -28,6 +28,8 @@ export type ProjectRun = {
|
||||
sourceInPlace?: boolean;
|
||||
/** Previous immutable snapshot when a project run was revised after creation. */
|
||||
revisedFrom?: string;
|
||||
/** Word comment authors were reviewed with the explicit author recognizer. */
|
||||
commentAuthorCoverage?: boolean;
|
||||
};
|
||||
|
||||
const DOCUMENTS = new Set([".docx", ".xlsx", ".pptx", ".pdf"]);
|
||||
|
||||
Reference in New Issue
Block a user