label-studio-converter 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +33 -0
- package/README.md +351 -0
- package/dist/bash-complete.cjs +1296 -0
- package/dist/bash-complete.cjs.map +1 -0
- package/dist/bash-complete.d.cts +1 -0
- package/dist/bash-complete.d.ts +1 -0
- package/dist/bash-complete.js +1279 -0
- package/dist/bash-complete.js.map +1 -0
- package/dist/cli.cjs +1281 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1264 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +418 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +309 -0
- package/dist/index.d.ts +309 -0
- package/dist/index.js +377 -0
- package/dist/index.js.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../node_modules/.pnpm/tsup@8.5.1_jiti@2.4.2_postcss@8.5.6_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/esm_shims.js","../src/constants.ts","../src/lib/ppocr-label.ts","../src/lib/schema.ts","../src/lib/sort.ts","../src/commands/toLabelStudio/impl.ts","../src/lib/label-studio.ts","../src/commands/toPPOCR/impl.ts","../src/bin/bash-complete.ts","../src/app.ts","../package.json","../src/commands/toLabelStudio/command.ts","../src/commands/toPPOCR/commands.ts","../src/context.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","export const OUTPUT_BASE_DIR = './output';\n\nexport const DEFAULT_LABEL_NAME = 'Text';\nexport const DEFAULT_LABEL_STUDIO_FULL_JSON = true;\nexport const DEFAULT_CREATE_FILE_PER_IMAGE = false;\nexport const DEFAULT_CREATE_FILE_LIST_FOR_SERVING = true;\nexport const DEFAULT_FILE_LIST_NAME = 'files.txt';\nexport const DEFAULT_BASE_SERVER_URL = 'http://localhost:8081';\n\nexport const DEFAULT_PPOCR_FILE_NAME = 'Label.txt';\n\n// Vertical sorting options\nexport const SORT_VERTICAL_NONE = 'none';\nexport const SORT_VERTICAL_TOP_BOTTOM = 'top-bottom';\nexport const SORT_VERTICAL_BOTTOM_TOP = 'bottom-top';\nexport const DEFAULT_SORT_VERTICAL = SORT_VERTICAL_NONE;\n\n// Horizontal sorting options\nexport const SORT_HORIZONTAL_NONE = 'none';\nexport const SORT_HORIZONTAL_LTR = 'ltr';\nexport const SORT_HORIZONTAL_RTL = 'rtl';\nexport const DEFAULT_SORT_HORIZONTAL = SORT_HORIZONTAL_NONE;\n\nexport type VerticalSortOrder =\n | typeof SORT_VERTICAL_NONE\n | typeof SORT_VERTICAL_TOP_BOTTOM\n | typeof SORT_VERTICAL_BOTTOM_TOP;\n\nexport type HorizontalSortOrder =\n | typeof SORT_HORIZONTAL_NONE\n | typeof SORT_HORIZONTAL_LTR\n | typeof SORT_HORIZONTAL_RTL;\n","import { randomUUID } from 'node:crypto';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport sizeOf from 'image-size';\nimport { DEFAULT_LABEL_NAME } from '@/constants';\nimport {\n type FullOCRLabelStudio,\n type MinOCRLabelStudio,\n type PPOCRLabel,\n} from '@/lib/schema';\n\nexport type ToLabelStudioOptions = {\n imagePath: string;\n baseServerUrl: string;\n inputDir?: string;\n toFullJson?: boolean;\n taskId?: number;\n labelName?: string;\n};\n\nexport const ppocrToLabelStudio = async (\n data: PPOCRLabel,\n options: ToLabelStudioOptions,\n): Promise<FullOCRLabelStudio | MinOCRLabelStudio> => {\n const {\n imagePath,\n baseServerUrl,\n inputDir,\n toFullJson = true,\n taskId = 1,\n labelName = DEFAULT_LABEL_NAME,\n } = options || {};\n\n if (toFullJson) {\n return ppocrToFullLabelStudio(\n data,\n imagePath,\n baseServerUrl,\n inputDir,\n taskId,\n labelName,\n );\n } else {\n return ppocrToMinLabelStudio(\n data,\n imagePath,\n baseServerUrl,\n inputDir,\n labelName,\n );\n }\n};\n\nexport const ppocrToFullLabelStudio = (\n data: PPOCRLabel,\n imagePath: string,\n baseServerUrl: string,\n inputDir?: string,\n taskId: number = 1,\n labelName: string = DEFAULT_LABEL_NAME,\n): FullOCRLabelStudio => {\n const newBaseServerUrl =\n baseServerUrl.replace(/\\/+$/, '') + (baseServerUrl === '' ? '' : '/');\n\n const now = new Date().toISOString();\n\n // Get actual image dimensions from the image file\n let original_width = 1920;\n let original_height = 1080;\n\n // Resolve absolute path to image file\n const resolvedImagePath = inputDir ? join(inputDir, imagePath) : imagePath;\n\n if (!existsSync(resolvedImagePath)) {\n throw new Error(`Image file not found: ${resolvedImagePath}`);\n }\n\n const buffer = readFileSync(resolvedImagePath);\n const dimensions = sizeOf(buffer);\n if (!dimensions.width || !dimensions.height) {\n throw new Error(\n `Failed to read image dimensions from: ${resolvedImagePath}`,\n );\n }\n original_width = dimensions.width;\n original_height = dimensions.height;\n\n // Extract filename from imagePath for file_upload (just the filename)\n const fileName = imagePath.split('/').pop() || imagePath;\n\n // Group all PPOCRLabel items into a single task with one annotation\n const result: FullOCRLabelStudio = [\n {\n id: taskId,\n annotations: [\n {\n id: taskId,\n completed_by: 1,\n result: data\n .map((item) => {\n const { points } = item;\n\n // Generate a single ID for all three related annotations\n const annotationId = randomUUID().slice(0, 10);\n const polygonPoints = points.map(([x, y]) => [\n ((x ?? 0) / original_width) * 100,\n ((y ?? 0) / original_height) * 100,\n ]);\n\n // Create result items: polygon, labels, and textarea\n return [\n // 1. Polygon geometry only\n {\n original_width,\n original_height,\n image_rotation: 0,\n value: {\n points: polygonPoints,\n closed: true,\n },\n id: annotationId,\n from_name: 'poly',\n to_name: 'image',\n type: 'polygon',\n origin: 'manual',\n },\n // 2. Labels with polygon geometry\n {\n original_width,\n original_height,\n image_rotation: 0,\n value: {\n points: polygonPoints,\n closed: true,\n labels: [labelName],\n },\n id: annotationId,\n from_name: 'label',\n to_name: 'image',\n type: 'labels',\n origin: 'manual',\n },\n // 3. Textarea with polygon geometry and text\n {\n original_width,\n original_height,\n image_rotation: 0,\n value: {\n points: polygonPoints,\n closed: true,\n text: [item.transcription],\n },\n id: annotationId,\n from_name: 'transcription',\n to_name: 'image',\n type: 'textarea',\n origin: 'manual',\n },\n ];\n })\n .flat(),\n was_cancelled: false,\n ground_truth: false,\n created_at: now,\n updated_at: now,\n draft_created_at: now,\n lead_time: 0,\n prediction: {},\n result_count: data.length * 3,\n unique_id: randomUUID(),\n import_id: null,\n last_action: null,\n bulk_created: false,\n task: taskId,\n project: 1,\n updated_by: 1,\n parent_prediction: null,\n parent_annotation: null,\n last_created_by: null,\n },\n ],\n file_upload: fileName,\n drafts: [],\n predictions: [],\n data: { ocr: `${newBaseServerUrl}${imagePath}` },\n meta: {},\n created_at: now,\n updated_at: now,\n allow_skip: false,\n inner_id: taskId,\n total_annotations: 1,\n cancelled_annotations: 0,\n total_predictions: 0,\n comment_count: 0,\n unresolved_comment_count: 0,\n last_comment_updated_at: null,\n project: 1,\n updated_by: 1,\n comment_authors: [],\n },\n ];\n\n return result;\n};\n\nexport const ppocrToMinLabelStudio = (\n data: PPOCRLabel,\n imagePath: string,\n baseServerUrl: string,\n inputDir?: string,\n labelName: string = 'text',\n): MinOCRLabelStudio => {\n const newBaseServerUrl =\n baseServerUrl.replace(/\\/+$/, '') + (baseServerUrl === '' ? '' : '/');\n\n const now = new Date().toISOString();\n\n // Get actual image dimensions from the image file\n let original_width = 1920;\n let original_height = 1080;\n\n // Resolve absolute path to image file\n const resolvedImagePath = inputDir ? join(inputDir, imagePath) : imagePath;\n\n if (!existsSync(resolvedImagePath)) {\n throw new Error(`Image file not found: ${resolvedImagePath}`);\n }\n\n const buffer = readFileSync(resolvedImagePath);\n const dimensions = sizeOf(buffer);\n if (!dimensions.width || !dimensions.height) {\n throw new Error(\n `Failed to read image dimensions from: ${resolvedImagePath}`,\n );\n }\n original_width = dimensions.width;\n original_height = dimensions.height;\n\n return data.map((item, index) => {\n const { points } = item;\n\n // Calculate bbox from points\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (const point of points) {\n const [x, y] = point;\n if (x !== undefined && y !== undefined) {\n minX = Math.min(minX, x);\n minY = Math.min(minY, y);\n maxX = Math.max(maxX, x);\n maxY = Math.max(maxY, y);\n }\n }\n\n const width = maxX - minX;\n const height = maxY - minY;\n\n return {\n ocr: encodeURI(`${newBaseServerUrl}${imagePath}`),\n id: index + 1,\n bbox: [\n {\n x: minX,\n y: minY,\n width,\n height,\n rotation: 0,\n original_width,\n original_height,\n },\n ],\n label: [\n {\n points: points,\n closed: true,\n labels: [labelName],\n original_width,\n original_height,\n },\n ],\n transcription: [item.transcription],\n poly: [\n {\n points: points,\n closed: true,\n original_width,\n original_height,\n },\n ],\n annotator: 1,\n annotation_id: index + 1,\n created_at: now,\n updated_at: now,\n lead_time: 0,\n };\n });\n};\n","import z from 'zod';\n\nexport const FullOCRLabelStudioSchema = z.array(\n z.object({\n id: z.number(),\n annotations: z.array(\n z.object({\n id: z.number(),\n completed_by: z.number(),\n result: z.array(\n z.union([\n z.object({\n original_width: z.number(),\n original_height: z.number(),\n image_rotation: z.number(),\n value: z.object({\n x: z.number(),\n y: z.number(),\n width: z.number(),\n height: z.number(),\n rotation: z.number(),\n }),\n id: z.string(),\n from_name: z.string(),\n to_name: z.string(),\n type: z.string(),\n origin: z.string(),\n }),\n z.object({\n original_width: z.number(),\n original_height: z.number(),\n image_rotation: z.number(),\n value: z.object({\n x: z.number(),\n y: z.number(),\n width: z.number(),\n height: z.number(),\n rotation: z.number(),\n labels: z.array(z.string()),\n }),\n id: z.string(),\n from_name: z.string(),\n to_name: z.string(),\n type: z.string(),\n origin: z.string(),\n }),\n z.object({\n original_width: z.number(),\n original_height: z.number(),\n image_rotation: z.number(),\n value: z.object({\n x: z.number(),\n y: z.number(),\n width: z.number(),\n height: z.number(),\n rotation: z.number(),\n text: z.array(z.string()),\n }),\n id: z.string(),\n from_name: z.string(),\n to_name: z.string(),\n type: z.string(),\n origin: z.string(),\n }),\n z.object({\n original_width: z.number(),\n original_height: z.number(),\n image_rotation: z.number(),\n value: z.object({\n points: z.array(z.array(z.number())),\n closed: z.boolean(),\n }),\n id: z.string(),\n from_name: z.string(),\n to_name: z.string(),\n type: z.string(),\n origin: z.string(),\n }),\n z.object({\n original_width: z.number(),\n original_height: z.number(),\n image_rotation: z.number(),\n value: z.object({\n points: z.array(z.array(z.number())),\n closed: z.boolean(),\n labels: z.array(z.string()),\n }),\n id: z.string(),\n from_name: z.string(),\n to_name: z.string(),\n type: z.string(),\n origin: z.string(),\n }),\n z.object({\n original_width: z.number(),\n original_height: z.number(),\n image_rotation: z.number(),\n value: z.object({\n points: z.array(z.array(z.number())),\n closed: z.boolean(),\n text: z.array(z.string()),\n }),\n id: z.string(),\n from_name: z.string(),\n to_name: z.string(),\n type: z.string(),\n origin: z.string(),\n }),\n ]),\n ),\n was_cancelled: z.boolean(),\n ground_truth: z.boolean(),\n created_at: z.string(),\n updated_at: z.string(),\n draft_created_at: z.string(),\n lead_time: z.number(),\n prediction: z.object({}),\n result_count: z.number(),\n unique_id: z.string(),\n import_id: z.null(),\n last_action: z.null(),\n bulk_created: z.boolean(),\n task: z.number(),\n project: z.number(),\n updated_by: z.number(),\n parent_prediction: z.null(),\n parent_annotation: z.null(),\n last_created_by: z.null(),\n }),\n ),\n file_upload: z.string(),\n drafts: z.array(\n z.object({\n id: z.number(),\n user: z.string(),\n created_username: z.string(),\n created_ago: z.string(),\n result: z.array(\n z.union([\n z.object({\n original_width: z.number(),\n original_height: z.number(),\n image_rotation: z.number(),\n value: z.object({\n x: z.number(),\n y: z.number(),\n width: z.number(),\n height: z.number(),\n rotation: z.number(),\n }),\n id: z.string(),\n from_name: z.string(),\n to_name: z.string(),\n type: z.string(),\n origin: z.string(),\n }),\n z.object({\n original_width: z.number(),\n original_height: z.number(),\n image_rotation: z.number(),\n value: z.object({\n x: z.number(),\n y: z.number(),\n width: z.number(),\n height: z.number(),\n rotation: z.number(),\n labels: z.array(z.string()),\n }),\n id: z.string(),\n from_name: z.string(),\n to_name: z.string(),\n type: z.string(),\n origin: z.string(),\n }),\n z.object({\n original_width: z.number(),\n original_height: z.number(),\n image_rotation: z.number(),\n value: z.object({\n x: z.number(),\n y: z.number(),\n width: z.number(),\n height: z.number(),\n rotation: z.number(),\n text: z.array(z.string()),\n }),\n id: z.string(),\n from_name: z.string(),\n to_name: z.string(),\n type: z.string(),\n origin: z.string(),\n }),\n z.object({\n original_width: z.number(),\n original_height: z.number(),\n image_rotation: z.number(),\n value: z.object({\n points: z.array(z.array(z.number())),\n closed: z.boolean(),\n }),\n id: z.string(),\n from_name: z.string(),\n to_name: z.string(),\n type: z.string(),\n origin: z.string(),\n }),\n z.object({\n original_width: z.number(),\n original_height: z.number(),\n image_rotation: z.number(),\n value: z.object({\n points: z.array(z.array(z.number())),\n closed: z.boolean(),\n labels: z.array(z.string()),\n }),\n id: z.string(),\n from_name: z.string(),\n to_name: z.string(),\n type: z.string(),\n origin: z.string(),\n }),\n z.object({\n original_width: z.number(),\n original_height: z.number(),\n image_rotation: z.number(),\n value: z.object({\n points: z.array(z.array(z.number())),\n closed: z.boolean(),\n text: z.array(z.string()),\n }),\n id: z.string(),\n from_name: z.string(),\n to_name: z.string(),\n type: z.string(),\n origin: z.string(),\n }),\n ]),\n ),\n lead_time: z.number(),\n was_postponed: z.boolean(),\n import_id: z.null(),\n created_at: z.string(),\n updated_at: z.string(),\n task: z.number(),\n annotation: z.number(),\n }),\n ),\n predictions: z.array(z.unknown()),\n data: z.object({ ocr: z.string() }),\n meta: z.object({}),\n created_at: z.string(),\n updated_at: z.string(),\n allow_skip: z.boolean(),\n inner_id: z.number(),\n total_annotations: z.number(),\n cancelled_annotations: z.number(),\n total_predictions: z.number(),\n comment_count: z.number(),\n unresolved_comment_count: z.number(),\n last_comment_updated_at: z.null(),\n project: z.number(),\n updated_by: z.number(),\n comment_authors: z.array(z.unknown()),\n }),\n);\n\nexport const MinOCRLabelStudioSchema = z.array(\n z.object({\n ocr: z.string(),\n id: z.number(),\n bbox: z.array(\n z.object({\n x: z.number(),\n y: z.number(),\n width: z.number(),\n height: z.number(),\n rotation: z.number(),\n original_width: z.number(),\n original_height: z.number(),\n }),\n ),\n label: z.array(\n z.union([\n z.object({\n x: z.number(),\n y: z.number(),\n width: z.number(),\n height: z.number(),\n rotation: z.number(),\n labels: z.array(z.string()),\n original_width: z.number(),\n original_height: z.number(),\n }),\n z.object({\n points: z.array(z.array(z.number())),\n closed: z.boolean(),\n labels: z.array(z.string()),\n original_width: z.number(),\n original_height: z.number(),\n }),\n ]),\n ),\n transcription: z.array(z.string()),\n poly: z.array(\n z.object({\n points: z.array(z.array(z.number())),\n closed: z.boolean(),\n original_width: z.number(),\n original_height: z.number(),\n }),\n ),\n annotator: z.number(),\n annotation_id: z.number(),\n created_at: z.string(),\n updated_at: z.string(),\n lead_time: z.number(),\n }),\n);\n\nexport const PPOCRLabelSchema = z.array(\n z.object({\n transcription: z.string(),\n points: z.array(z.array(z.number())),\n dt_score: z.number(),\n }),\n);\n\nexport type FullOCRLabelStudio = z.infer<typeof FullOCRLabelStudioSchema>;\nexport type MinOCRLabelStudio = z.infer<typeof MinOCRLabelStudioSchema>;\nexport type PPOCRLabel = z.infer<typeof PPOCRLabelSchema>;\n","import type { HorizontalSortOrder, VerticalSortOrder } from '@/constants';\nimport {\n SORT_HORIZONTAL_LTR,\n SORT_HORIZONTAL_NONE,\n SORT_HORIZONTAL_RTL,\n SORT_VERTICAL_NONE,\n SORT_VERTICAL_TOP_BOTTOM,\n} from '@/constants';\nimport type { PPOCRLabel } from '@/lib/schema';\n\n// Tolerance for grouping bounding boxes into columns/rows\n// Boxes within this pixel distance are considered in the same column/row\nconst GROUPING_TOLERANCE = 50;\n\n/**\n * Calculate the bounding box center point from polygon points\n */\nfunction getBoundingBoxCenter(points: number[][]): {\n x: number;\n y: number;\n width: number;\n height: number;\n} {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for (const [x, y] of points) {\n if (x !== undefined && y !== undefined) {\n minX = Math.min(minX, x);\n minY = Math.min(minY, y);\n maxX = Math.max(maxX, x);\n maxY = Math.max(maxY, y);\n }\n }\n\n return {\n x: (minX + maxX) / 2,\n y: (minY + maxY) / 2,\n width: maxX - minX,\n height: maxY - minY,\n };\n}\n\n/**\n * Sort PPOCRLabel array based on bounding box positions\n * Supports both traditional reading order (top-bottom, then left-right)\n * and SinoNom reading order (right-left columns, top-bottom within each column)\n * @param annotations - Array of PPOCR annotations to sort\n * @param verticalSort - Vertical sort order: 'none', 'top-bottom', 'bottom-top'\n * @param horizontalSort - Horizontal sort order: 'none', 'ltr', 'rtl'\n * @returns Sorted array (or original array if both sorts are 'none')\n */\nexport function sortBoundingBoxes(\n annotations: PPOCRLabel,\n verticalSort: VerticalSortOrder,\n horizontalSort: HorizontalSortOrder,\n): PPOCRLabel {\n if (\n verticalSort === SORT_VERTICAL_NONE &&\n horizontalSort === SORT_HORIZONTAL_NONE\n ) {\n return annotations;\n }\n\n // Create a copy to avoid mutating the original array\n const sorted = [...annotations];\n\n // Detect if this is vertical text (SinoNom style) or horizontal text (Arabic/Hebrew style)\n // by checking if most boxes are taller than they are wide\n const isVerticalText =\n sorted.length > 0 &&\n (() => {\n const verticalCount = sorted.filter((ann) => {\n const center = getBoundingBoxCenter(ann.points);\n return center.height > center.width * 1.5; // At least 1.5x taller than wide\n }).length;\n return verticalCount > sorted.length / 2; // More than half are vertical\n })();\n\n // For RTL with vertical sorting and vertical text (SinoNom):\n // Group into columns first, then sort within each column\n if (\n horizontalSort === SORT_HORIZONTAL_RTL &&\n verticalSort !== SORT_VERTICAL_NONE &&\n isVerticalText\n ) {\n // Calculate centers for all annotations\n const annotationsWithCenters = sorted.map((ann) => ({\n annotation: ann,\n center: getBoundingBoxCenter(ann.points),\n }));\n\n // Group annotations into columns based on x-position\n const columns: (typeof annotationsWithCenters)[] = [];\n\n for (const item of annotationsWithCenters) {\n let addedToColumn = false;\n\n for (const column of columns) {\n // Check if this annotation belongs to an existing column\n const avgX =\n column.reduce((sum, c) => sum + c.center.x, 0) / column.length;\n if (Math.abs(item.center.x - avgX) < GROUPING_TOLERANCE) {\n column.push(item);\n addedToColumn = true;\n break;\n }\n }\n\n if (!addedToColumn) {\n columns.push([item]);\n }\n }\n\n // Sort columns right-to-left\n columns.sort((colA, colB) => {\n const avgXA = colA.reduce((sum, c) => sum + c.center.x, 0) / colA.length;\n const avgXB = colB.reduce((sum, c) => sum + c.center.x, 0) / colB.length;\n return avgXB - avgXA; // Right to left\n });\n\n // Sort within each column top-to-bottom or bottom-to-top\n for (const column of columns) {\n column.sort((a, b) => {\n return verticalSort === SORT_VERTICAL_TOP_BOTTOM\n ? a.center.y - b.center.y\n : b.center.y - a.center.y;\n });\n }\n\n // Flatten back to a single array\n return columns.flat().map((item) => item.annotation);\n }\n\n // For all other cases, use simple sort with priority\n sorted.sort((a, b) => {\n const centerA = getBoundingBoxCenter(a.points);\n const centerB = getBoundingBoxCenter(b.points);\n\n // Apply vertical sorting first (if specified)\n if (verticalSort !== SORT_VERTICAL_NONE) {\n const yDiff =\n verticalSort === SORT_VERTICAL_TOP_BOTTOM\n ? centerA.y - centerB.y\n : centerB.y - centerA.y;\n\n // If there's a significant difference in y-position, return that\n if (Math.abs(yDiff) > GROUPING_TOLERANCE) {\n return yDiff;\n }\n }\n\n // Apply horizontal sorting (if specified and y-positions are similar or not sorting vertically)\n if (horizontalSort !== SORT_HORIZONTAL_NONE) {\n return horizontalSort === SORT_HORIZONTAL_LTR\n ? centerA.x - centerB.x\n : centerB.x - centerA.x;\n }\n\n return 0;\n });\n\n return sorted;\n}\n","import { mkdir, readFile, readdir, writeFile } from 'fs/promises';\nimport { join } from 'path';\nimport chalk from 'chalk';\nimport {\n DEFAULT_BASE_SERVER_URL,\n DEFAULT_CREATE_FILE_LIST_FOR_SERVING,\n DEFAULT_CREATE_FILE_PER_IMAGE,\n DEFAULT_FILE_LIST_NAME,\n DEFAULT_LABEL_NAME,\n DEFAULT_LABEL_STUDIO_FULL_JSON,\n DEFAULT_SORT_HORIZONTAL,\n DEFAULT_SORT_VERTICAL,\n type HorizontalSortOrder,\n OUTPUT_BASE_DIR,\n type VerticalSortOrder,\n} from '@/constants';\nimport type { LocalContext } from '@/context';\nimport { ppocrToLabelStudio } from '@/lib/ppocr-label';\nimport { type PPOCRLabel, PPOCRLabelSchema } from '@/lib/schema';\nimport { sortBoundingBoxes } from '@/lib/sort';\n\ninterface CommandFlags {\n outDir?: string;\n defaultLabelName?: string;\n toFullJson?: boolean;\n createFilePerImage?: boolean;\n createFileListForServing?: boolean;\n fileListName?: string;\n baseServerUrl?: string;\n sortVertical?: string;\n sortHorizontal?: string;\n}\n\nexport async function convertToLabelStudio(\n this: LocalContext,\n flags: CommandFlags,\n ...inputDirs: string[]\n): Promise<void> {\n const {\n outDir = OUTPUT_BASE_DIR,\n defaultLabelName = DEFAULT_LABEL_NAME,\n toFullJson = DEFAULT_LABEL_STUDIO_FULL_JSON,\n createFilePerImage = DEFAULT_CREATE_FILE_PER_IMAGE,\n createFileListForServing = DEFAULT_CREATE_FILE_LIST_FOR_SERVING,\n fileListName = DEFAULT_FILE_LIST_NAME,\n baseServerUrl = DEFAULT_BASE_SERVER_URL,\n sortVertical = DEFAULT_SORT_VERTICAL,\n sortHorizontal = DEFAULT_SORT_HORIZONTAL,\n } = flags;\n\n // NOTE: Ensure baseServerUrl ends with a single slash, but keeps empty string\n // as is\n const newBaseServerUrl =\n baseServerUrl.replace(/\\/+$/, '') + (baseServerUrl === '' ? '' : '/');\n\n // Create output directory if it doesn't exist\n await mkdir(outDir, { recursive: true });\n\n for (const inputDir of inputDirs) {\n console.log(chalk.blue(`Processing input directory: ${inputDir}`));\n\n const files = await readdir(inputDir);\n\n for (const file of files) {\n if (!file.endsWith('.txt')) {\n continue;\n }\n\n const filePath = join(inputDir, file);\n console.log(chalk.gray(`Processing file: ${file}`));\n\n try {\n const fileData = await readFile(filePath, 'utf-8');\n const lines = fileData.trim().split('\\n');\n\n // Parse PPOCRLabelV2 format: <filename>\\t<json_array_of_annotations>\n // Group by filename since each line represents one image file with its annotations\n const imageDataMap = new Map<string, PPOCRLabel>();\n\n for (const line of lines) {\n const parts = line.split('\\t');\n\n if (parts.length !== 2) {\n throw new Error(`Invalid PPOCRLabelV2 format in line: ${line}`);\n }\n const [imagePath, annotationsStr] = parts;\n const annotations = JSON.parse(annotationsStr!);\n\n // Each annotation already has the structure: {transcription, points, dt_score}\n // Validate each annotation\n PPOCRLabelSchema.parse(annotations);\n\n imageDataMap.set(imagePath!, annotations);\n }\n\n // Convert each image's annotations to Label Studio format\n const allLabelStudioData = [];\n const fileList: string[] = [];\n let taskId = 1;\n\n for (const [imagePath, ppocrData] of imageDataMap.entries()) {\n // Sort annotations if requested\n const sortedPpocrData = sortBoundingBoxes(\n ppocrData,\n sortVertical as VerticalSortOrder,\n sortHorizontal as HorizontalSortOrder,\n );\n\n // Update imagePath to use baseServerUrl if createFileListForServing is enabled\n const finalImagePath = createFileListForServing\n ? encodeURI(`${newBaseServerUrl}${imagePath}`)\n : imagePath;\n\n const labelStudioData = await ppocrToLabelStudio(sortedPpocrData, {\n toFullJson,\n imagePath,\n baseServerUrl: newBaseServerUrl,\n inputDir,\n taskId,\n labelName: defaultLabelName,\n });\n\n if (toFullJson) {\n allLabelStudioData.push(labelStudioData[0]);\n } else {\n allLabelStudioData.push(...labelStudioData);\n }\n\n // Create individual file per image if requested\n if (createFilePerImage) {\n const imageBaseName = imagePath\n .replace(/\\//g, '_')\n .replace(/\\.[^.]+$/, '');\n const individualOutputPath = join(\n outDir,\n `${imageBaseName}_${toFullJson ? 'full' : 'min'}.json`,\n );\n await writeFile(\n individualOutputPath,\n JSON.stringify(\n toFullJson ? labelStudioData[0] : labelStudioData,\n null,\n 2,\n ),\n 'utf-8',\n );\n console.log(\n chalk.gray(\n ` ✓ Created individual file: ${individualOutputPath}`,\n ),\n );\n }\n\n // Add to file list for serving\n if (createFileListForServing) {\n fileList.push(finalImagePath);\n }\n\n taskId++;\n }\n\n // Write combined output file\n const baseName = file.replace('.txt', '');\n const outputPath = join(\n outDir,\n `${baseName}_${toFullJson ? 'full' : 'min'}.json`,\n );\n await writeFile(\n outputPath,\n JSON.stringify(allLabelStudioData, null, 2),\n 'utf-8',\n );\n\n console.log(chalk.green(`✓ Converted ${file} -> ${outputPath}`));\n\n // Create file list for serving if requested\n if (createFileListForServing && fileList.length > 0) {\n const fileListPath = join(outDir, fileListName);\n await writeFile(fileListPath, fileList.join('\\n'), 'utf-8');\n console.log(\n chalk.green(\n `✓ Created file list: ${fileListPath} (${fileList.length} files)`,\n ),\n );\n }\n } catch (error) {\n console.error(\n chalk.red(`✗ Failed to process ${file}:`),\n error instanceof Error ? error.message : error,\n );\n }\n }\n }\n\n console.log(chalk.green('\\n✓ Conversion completed!'));\n}\n","import * as turf from '@turf/turf';\nimport {\n type FullOCRLabelStudio,\n type MinOCRLabelStudio,\n type PPOCRLabel,\n} from '@/lib/schema';\n\nexport const labelStudioToPPOCR = async (\n data: FullOCRLabelStudio,\n baseImageDir?: string,\n): Promise<Map<string, PPOCRLabel>> => {\n const resultMap = new Map<string, PPOCRLabel>();\n\n for (const task of data) {\n // Extract image path from data.ocr (full path with URL) or file_upload (just filename)\n let imagePath = task.file_upload || '';\n if (task.data.ocr) {\n // Extract path from URL: http://localhost:8081/ch/image.jpg -> ch/image.jpg\n const urlPath = task.data.ocr.replace(/^https?:\\/\\/[^/]+\\//, '');\n imagePath = decodeURIComponent(urlPath);\n }\n\n // Apply baseImageDir if provided\n if (baseImageDir) {\n imagePath = `${baseImageDir}/${task.file_upload || imagePath.split('/').pop() || imagePath}`;\n }\n\n const imageAnnotations: PPOCRLabel = [];\n\n // Process each annotation in the task\n for (const annotation of task.annotations) {\n // Group result items by their ID to avoid duplicates\n // (polygon, labels, and textarea share the same ID)\n const groupedById = new Map<string, typeof annotation.result>();\n\n for (const resultItem of annotation.result) {\n const { id } = resultItem;\n if (!groupedById.has(id)) {\n groupedById.set(id, []);\n }\n groupedById.get(id)!.push(resultItem);\n }\n\n // Process each group of result items (with same ID)\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n for (const [_, resultItems] of groupedById) {\n let points: number[][] | undefined;\n let transcription = '';\n\n // Process all result items in this group to extract points and transcription\n for (const resultItem of resultItems) {\n // Extract points from different value types\n if ('points' in resultItem.value && resultItem.value.points) {\n // Polygon/polyline with percentage points - convert to absolute\n const { points: valuePoints } = resultItem.value;\n const { original_width, original_height } = resultItem;\n\n // Convert percentage coordinates to absolute pixels\n points = valuePoints.map(([x, y]) => [\n ((x ?? 0) * original_width) / 100,\n ((y ?? 0) * original_height) / 100,\n ]);\n } else if (\n 'x' in resultItem.value &&\n 'y' in resultItem.value &&\n 'width' in resultItem.value &&\n 'height' in resultItem.value\n ) {\n // Rectangle - convert to 4 corner points\n const { x, y, width, height } = resultItem.value;\n const { original_width, original_height } = resultItem;\n\n // Convert normalized values to absolute coordinates\n const absX = (x * original_width) / 100;\n const absY = (y * original_height) / 100;\n const absWidth = (width * original_width) / 100;\n const absHeight = (height * original_height) / 100;\n\n points = [\n [absX, absY],\n [absX + absWidth, absY],\n [absX + absWidth, absY + absHeight],\n [absX, absY + absHeight],\n ];\n }\n\n // Extract transcription from text field\n if (\n 'text' in resultItem.value &&\n Array.isArray(resultItem.value.text)\n ) {\n transcription = resultItem.value.text[0] || '';\n }\n }\n\n // If we have points, create a PPOCRLabel entry\n if (points && points.length > 0) {\n // Calculate dt_score based on polygon area\n let dt_score = 1.0;\n try {\n const firstPoint = points[0];\n if (firstPoint) {\n const polygon = turf.polygon([points.concat([firstPoint])]);\n const area = turf.area(polygon);\n dt_score = Math.min(1.0, Math.max(0.5, area / 10000));\n }\n } catch {\n dt_score = 0.8;\n }\n\n imageAnnotations.push({\n transcription,\n points,\n dt_score,\n });\n }\n }\n }\n\n if (imageAnnotations.length > 0) {\n resultMap.set(imagePath, imageAnnotations);\n }\n }\n\n return resultMap;\n};\n\nexport const minLabelStudioToPPOCR = async (\n data: MinOCRLabelStudio,\n baseImageDir?: string,\n): Promise<Map<string, PPOCRLabel>> => {\n const resultMap = new Map<string, PPOCRLabel>();\n\n for (const item of data) {\n // Extract image path from ocr URL\n let imagePath = item.ocr || '';\n if (imagePath) {\n // Extract path from URL: http://localhost:8081/ch/image.jpg -> ch/image.jpg\n imagePath = decodeURIComponent(\n imagePath.replace(/^https?:\\/\\/[^/]+\\//, ''),\n );\n }\n\n // Apply baseImageDir if provided\n if (baseImageDir) {\n imagePath = `${baseImageDir}/${imagePath.split('/').pop() || imagePath}`;\n }\n\n // Use poly if available, otherwise convert from bbox\n let points: number[][];\n\n if (item.poly.length > 0 && item.poly[0]) {\n const { points: polyPoints } = item.poly[0];\n points = polyPoints;\n } else if (item.bbox.length > 0 && item.bbox[0]) {\n const bbox = item.bbox[0];\n const { x, y, width, height } = bbox;\n\n // Convert bbox to 4 corner points\n points = [\n [x, y],\n [x + width, y],\n [x + width, y + height],\n [x, y + height],\n ];\n } else {\n // Skip if no geometry data\n continue;\n }\n\n // Get transcription text (not the URL)\n const transcription =\n item.transcription.length > 0 ? item.transcription[0] : '';\n\n // Calculate dt_score based on polygon area\n let dt_score = 1.0;\n try {\n const firstPoint = points[0];\n if (firstPoint) {\n const polygon = turf.polygon([points.concat([firstPoint])]);\n const area = turf.area(polygon);\n dt_score = Math.min(1.0, Math.max(0.5, area / 10000));\n }\n } catch {\n dt_score = 0.8;\n }\n\n const annotation = {\n transcription: transcription ?? '',\n points,\n dt_score,\n };\n\n // Group by image path\n if (!resultMap.has(imagePath)) {\n resultMap.set(imagePath, []);\n }\n resultMap.get(imagePath)!.push(annotation);\n }\n\n return resultMap;\n};\n","import { mkdir, readFile, readdir, writeFile } from 'fs/promises';\nimport { join } from 'path';\nimport chalk from 'chalk';\nimport {\n DEFAULT_PPOCR_FILE_NAME,\n DEFAULT_SORT_HORIZONTAL,\n DEFAULT_SORT_VERTICAL,\n type HorizontalSortOrder,\n OUTPUT_BASE_DIR,\n type VerticalSortOrder,\n} from '@/constants';\nimport type { LocalContext } from '@/context';\nimport { labelStudioToPPOCR, minLabelStudioToPPOCR } from '@/lib/label-studio';\nimport {\n type FullOCRLabelStudio,\n FullOCRLabelStudioSchema,\n type MinOCRLabelStudio,\n MinOCRLabelStudioSchema,\n PPOCRLabelSchema,\n} from '@/lib/schema';\nimport { sortBoundingBoxes } from '@/lib/sort';\n\ninterface CommandFlags {\n outDir?: string;\n fileName?: string;\n baseImageDir?: string;\n sortVertical?: string;\n sortHorizontal?: string;\n}\n\nconst isLabelStudioFullJSON = (\n data: unknown,\n): {\n isFull: boolean;\n data: FullOCRLabelStudio | MinOCRLabelStudio;\n} => {\n // Try parsing as full format array\n const parsedFull = FullOCRLabelStudioSchema.safeParse(data);\n if (parsedFull.success) {\n return { isFull: true, data: parsedFull.data };\n }\n\n // Try parsing as single full format object (wrap in array)\n if (!Array.isArray(data) && typeof data === 'object' && data !== null) {\n const parsedSingleFull = FullOCRLabelStudioSchema.safeParse([data]);\n if (parsedSingleFull.success) {\n return { isFull: true, data: parsedSingleFull.data };\n }\n }\n\n // Try parsing as min format\n const parsedMin = MinOCRLabelStudioSchema.safeParse(data);\n if (parsedMin.success) {\n return { isFull: false, data: parsedMin.data };\n }\n\n throw new Error('Input data is not valid Label Studio JSON format.');\n};\n\nexport async function convertToPPOCR(\n this: LocalContext,\n flags: CommandFlags,\n ...inputDirs: string[]\n): Promise<void> {\n const {\n outDir = `${OUTPUT_BASE_DIR}`,\n fileName = DEFAULT_PPOCR_FILE_NAME,\n baseImageDir,\n sortVertical = DEFAULT_SORT_VERTICAL,\n sortHorizontal = DEFAULT_SORT_HORIZONTAL,\n } = flags;\n\n // Create output directory if it doesn't exist\n await mkdir(outDir, { recursive: true });\n\n for (const inputDir of inputDirs) {\n console.log(chalk.blue(`Processing input directory: ${inputDir}`));\n\n const files = await readdir(inputDir);\n\n for (const file of files) {\n if (!file.endsWith('.json')) {\n continue;\n }\n\n const filePath = join(inputDir, file);\n console.log(chalk.gray(`Processing file: ${file}`));\n\n try {\n const fileData = await readFile(filePath, 'utf-8');\n const labelStudioData = JSON.parse(fileData);\n\n const { data, isFull } = isLabelStudioFullJSON(labelStudioData);\n\n // Convert based on format type\n const ppocrDataMap = isFull\n ? await labelStudioToPPOCR(data as FullOCRLabelStudio, baseImageDir)\n : await minLabelStudioToPPOCR(\n data as MinOCRLabelStudio,\n baseImageDir,\n );\n\n // Format output as PPOCR label format: image_path<tab>[{JSON array}]\n const outputLines: string[] = [];\n for (const [imagePath, annotations] of ppocrDataMap.entries()) {\n // Sort annotations if requested\n const sortedAnnotations = sortBoundingBoxes(\n annotations,\n sortVertical as VerticalSortOrder,\n sortHorizontal as HorizontalSortOrder,\n );\n\n // Validate each annotation group\n PPOCRLabelSchema.parse(sortedAnnotations);\n\n // Format as: image_path<tab>[{annotations}]\n const jsonArray = JSON.stringify(sortedAnnotations);\n outputLines.push(`${imagePath}\\t${jsonArray}`);\n }\n\n // Write to output file\n const baseName = file.replace('.json', '');\n const outputPath = join(outDir, `${baseName}_${fileName}`);\n await writeFile(outputPath, outputLines.join('\\n'), 'utf-8');\n\n console.log(chalk.green(`✓ Converted ${file} -> ${outputPath}`));\n } catch (error) {\n console.error(\n chalk.red(`✗ Failed to process ${file}:`),\n error instanceof Error ? error.message : error,\n );\n }\n }\n }\n\n console.log(chalk.green('\\n✓ Conversion completed!'));\n}\n","#!/usr/bin/env node\nimport { proposeCompletions } from '@stricli/core';\nimport { app } from '@/app';\nimport { buildContext } from '@/context';\n\n(async () => {\n const inputs = process.argv.slice(3);\n if (process.env.COMP_LINE?.endsWith(' ')) {\n inputs.push('');\n }\n await proposeCompletions(app, inputs, buildContext(process));\n try {\n for (const { completion } of await proposeCompletions(\n app,\n inputs,\n buildContext(process),\n )) {\n process.stdout.write(`${completion}\\n`);\n }\n } catch {\n // ignore\n }\n})();\n","import {\n buildInstallCommand,\n buildUninstallCommand,\n} from '@stricli/auto-complete';\nimport { buildApplication, buildRouteMap } from '@stricli/core';\nimport { description, version } from '@/../package.json';\nimport { toLabelStudioCommand } from '@/commands/toLabelStudio/command';\nimport { toPPOCRCommand } from '@/commands/toPPOCR/commands';\n\nconst routes = buildRouteMap({\n routes: {\n toLabelStudio: toLabelStudioCommand,\n toPPOCR: toPPOCRCommand,\n install: buildInstallCommand('label-studio-converter', {\n bash: '__label-studio-converter_bash_complete',\n }),\n uninstall: buildUninstallCommand('label-studio-converter', { bash: true }),\n },\n docs: {\n brief: description,\n hideRoute: {\n install: true,\n uninstall: true,\n },\n },\n});\n\nexport const app = buildApplication(routes, {\n name: 'label-studio-converter',\n versionInfo: {\n currentVersion: version,\n },\n});\n","{\n \"name\": \"label-studio-converter\",\n \"version\": \"1.0.0\",\n \"author\": \"DuckyMomo20012\",\n \"description\": \"Convert between Label Studio OCR format and PPOCRLabelv2 format\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/DuckyMomo20012/label-studio-converter.git\"\n },\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"files\": [\n \"dist\",\n \"liturgical\"\n ],\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"./package.json\": \"./package.json\"\n },\n \"bin\": {\n \"label-studio-converter\": \"./dist/cli.js\",\n \"__label-studio-converter_bash_complete\": \"./dist/bash-complete.js\"\n },\n \"scripts\": {\n \"prepare\": \"husky\",\n \"lint\": \"tsc\",\n \"build\": \"tsc && tsup\",\n \"test\": \"vitest\",\n \"test:ui\": \"vitest --ui\",\n \"test:run\": \"vitest run\",\n \"test:coverage\": \"vitest run --coverage\",\n \"check-exports\": \"attw --pack . --ignore-rules=cjs-resolves-to-esm\",\n \"prepublish\": \"pnpm run build && pnpm run check-exports && pnpm run lint\",\n \"postinstall\": \"npx @stricli/auto-complete@latest install label-studio-converter --bash __label-studio-converter_bash_complete\"\n },\n \"dependencies\": {\n \"@stricli/auto-complete\": \"1.2.4\",\n \"@stricli/core\": \"1.2.4\",\n \"@turf/turf\": \"7.3.1\",\n \"chalk\": \"5.6.2\",\n \"es-toolkit\": \"1.43.0\",\n \"image-size\": \"2.0.2\",\n \"zod\": \"4.2.1\"\n },\n \"devDependencies\": {\n \"@arethetypeswrong/cli\": \"0.18.2\",\n \"@babel/core\": \"7.28.5\",\n \"@commitlint/cli\": \"20.2.0\",\n \"@commitlint/config-conventional\": \"20.2.0\",\n \"@types/node\": \"24.10.4\",\n \"@typescript-eslint/eslint-plugin\": \"8.51.0\",\n \"@typescript-eslint/parser\": \"8.51.0\",\n \"@vitest/eslint-plugin\": \"1.6.4\",\n \"@vitest/ui\": \"4.0.16\",\n \"eslint\": \"9.39.2\",\n \"eslint-config-prettier\": \"10.1.8\",\n \"eslint-import-resolver-typescript\": \"4.4.4\",\n \"eslint-plugin-import\": \"2.32.0\",\n \"eslint-plugin-prettier\": \"5.5.4\",\n \"globals\": \"16.5.0\",\n \"husky\": \"9.1.7\",\n \"lint-staged\": \"16.2.7\",\n \"prettier\": \"3.7.4\",\n \"tsup\": \"8.5.1\",\n \"typescript\": \"5.9.3\",\n \"vitest\": \"4.0.16\"\n }\n}\n","import { buildCommand } from '@stricli/core';\nimport {\n DEFAULT_BASE_SERVER_URL,\n DEFAULT_CREATE_FILE_LIST_FOR_SERVING,\n DEFAULT_CREATE_FILE_PER_IMAGE,\n DEFAULT_FILE_LIST_NAME,\n DEFAULT_LABEL_NAME,\n DEFAULT_LABEL_STUDIO_FULL_JSON,\n OUTPUT_BASE_DIR,\n SORT_HORIZONTAL_LTR,\n SORT_HORIZONTAL_NONE,\n SORT_HORIZONTAL_RTL,\n SORT_VERTICAL_BOTTOM_TOP,\n SORT_VERTICAL_NONE,\n SORT_VERTICAL_TOP_BOTTOM,\n} from '@/constants';\n\nexport const toLabelStudioCommand = buildCommand({\n loader: async () => {\n const { convertToLabelStudio } = await import('./impl');\n return convertToLabelStudio;\n },\n parameters: {\n positional: {\n kind: 'array',\n parameter: {\n brief: 'Input directories containing PPOCRLabel files',\n parse: String,\n },\n minimum: 1,\n },\n flags: {\n outDir: {\n kind: 'parsed',\n brief: `Output directory. Default to \"${OUTPUT_BASE_DIR}\"`,\n parse: String,\n optional: true,\n },\n defaultLabelName: {\n kind: 'parsed',\n brief: `Default label name for text annotations. Default to \"${DEFAULT_LABEL_NAME}\"`,\n parse: String,\n optional: true,\n },\n toFullJson: {\n kind: 'boolean',\n brief: `Convert to Full OCR Label Studio format. Default to \"${DEFAULT_LABEL_STUDIO_FULL_JSON}\"`,\n optional: true,\n },\n createFilePerImage: {\n kind: 'boolean',\n brief: `Create a separate Label Studio JSON file for each image. Default to \"${DEFAULT_CREATE_FILE_PER_IMAGE}\"`,\n optional: true,\n },\n createFileListForServing: {\n kind: 'boolean',\n brief: `Create a file list for serving in Label Studio. Default to \"${DEFAULT_CREATE_FILE_LIST_FOR_SERVING}\"`,\n optional: true,\n },\n fileListName: {\n kind: 'parsed',\n brief: `Name of the file list for serving. Default to \"${DEFAULT_FILE_LIST_NAME}\"`,\n parse: String,\n optional: true,\n },\n baseServerUrl: {\n kind: 'parsed',\n brief: `Base server URL for constructing image URLs in the file list. Default to \"${DEFAULT_BASE_SERVER_URL}\"`,\n parse: String,\n optional: true,\n },\n sortVertical: {\n kind: 'parsed',\n brief: `Sort bounding boxes vertically. Options: \"${SORT_VERTICAL_NONE}\" (default), \"${SORT_VERTICAL_TOP_BOTTOM}\", \"${SORT_VERTICAL_BOTTOM_TOP}\"`,\n parse: String,\n optional: true,\n },\n sortHorizontal: {\n kind: 'parsed',\n brief: `Sort bounding boxes horizontally. Options: \"${SORT_HORIZONTAL_NONE}\" (default), \"${SORT_HORIZONTAL_LTR}\", \"${SORT_HORIZONTAL_RTL}\"`,\n parse: String,\n optional: true,\n },\n },\n },\n docs: {\n brief: 'Convert PPOCRLabel files to Label Studio format',\n },\n});\n","import { buildCommand } from '@stricli/core';\nimport {\n DEFAULT_PPOCR_FILE_NAME,\n OUTPUT_BASE_DIR,\n SORT_HORIZONTAL_LTR,\n SORT_HORIZONTAL_NONE,\n SORT_HORIZONTAL_RTL,\n SORT_VERTICAL_BOTTOM_TOP,\n SORT_VERTICAL_NONE,\n SORT_VERTICAL_TOP_BOTTOM,\n} from '@/constants';\n\nexport const toPPOCRCommand = buildCommand({\n loader: async () => {\n const { convertToPPOCR } = await import('./impl');\n return convertToPPOCR;\n },\n parameters: {\n positional: {\n kind: 'array',\n parameter: {\n brief: 'Input directories containing Label Studio files',\n parse: String,\n },\n minimum: 1,\n },\n flags: {\n outDir: {\n kind: 'parsed',\n brief: `Output directory. Default to \"${OUTPUT_BASE_DIR}\"`,\n parse: String,\n optional: true,\n },\n fileName: {\n kind: 'parsed',\n brief: `Output PPOCR file name. Default to \"${DEFAULT_PPOCR_FILE_NAME}\"`,\n parse: String,\n optional: true,\n },\n baseImageDir: {\n kind: 'parsed',\n brief:\n 'Base directory path to prepend to image filenames in output (e.g., \"ch\" or \"images/ch\")',\n parse: String,\n optional: true,\n },\n sortVertical: {\n kind: 'parsed',\n brief: `Sort bounding boxes vertically. Options: \"${SORT_VERTICAL_NONE}\" (default), \"${SORT_VERTICAL_TOP_BOTTOM}\", \"${SORT_VERTICAL_BOTTOM_TOP}\"`,\n parse: String,\n optional: true,\n },\n sortHorizontal: {\n kind: 'parsed',\n brief: `Sort bounding boxes horizontally. Options: \"${SORT_HORIZONTAL_NONE}\" (default), \"${SORT_HORIZONTAL_LTR}\", \"${SORT_HORIZONTAL_RTL}\"`,\n parse: String,\n optional: true,\n },\n },\n },\n docs: {\n brief: 'Convert Label Studio files to PPOCRLabel format',\n },\n});\n","import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport type { StricliAutoCompleteContext } from '@stricli/auto-complete';\nimport type { CommandContext } from '@stricli/core';\n\nexport interface LocalContext\n extends CommandContext, StricliAutoCompleteContext {\n readonly process: NodeJS.Process;\n // ...\n}\n\nexport function buildContext(process: NodeJS.Process): LocalContext {\n return {\n process,\n os,\n fs,\n path,\n };\n}\n"],"mappings":";;;;;;;;;;;;AACA,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAF9B;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAa,iBAEA,oBACA,gCACA,+BACA,sCACA,wBACA,yBAEA,yBAGA,oBACA,0BACA,0BACA,uBAGA,sBACA,qBACA,qBACA;AArBb;AAAA;AAAA;AAAA;AAAO,IAAM,kBAAkB;AAExB,IAAM,qBAAqB;AAC3B,IAAM,iCAAiC;AACvC,IAAM,gCAAgC;AACtC,IAAM,uCAAuC;AAC7C,IAAM,yBAAyB;AAC/B,IAAM,0BAA0B;AAEhC,IAAM,0BAA0B;AAGhC,IAAM,qBAAqB;AAC3B,IAAM,2BAA2B;AACjC,IAAM,2BAA2B;AACjC,IAAM,wBAAwB;AAG9B,IAAM,uBAAuB;AAC7B,IAAM,sBAAsB;AAC5B,IAAM,sBAAsB;AAC5B,IAAM,0BAA0B;AAAA;AAAA;;;ACrBvC,SAAS,kBAAkB;AAC3B,SAAS,YAAY,oBAAoB;AACzC,SAAS,YAAY;AACrB,OAAO,YAAY;AAHnB,IAoBa,oBAiCA,wBAwJA;AA7Mb;AAAA;AAAA;AAAA;AAIA;AAgBO,IAAM,qBAAqB,OAChC,MACA,YACoD;AACpD,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA,aAAa;AAAA,QACb,SAAS;AAAA,QACT,YAAY;AAAA,MACd,IAAI,WAAW,CAAC;AAEhB,UAAI,Y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AAW,SAAS,GAAG,GAAG;AACxC,WAAO,KAAK,EAAE;AAAA,EAChB;AACA,QAAM,mBAAmB,KAAK,QAAQ,aAAa,OAAO,CAAC;AAC3D,MAAI;AACF,eAAW,EAAE,WAAW,KAAK,MAAM;AAAA,MACjC;AAAA,MACA;AAAA,MACA,aAAa,OAAO;AAAA,IACtB,GAAG;AACD,cAAQ,OAAO,MAAM,GAAG,UAAU;AAAA,CAAI;AAAA,IACxC;AAAA,EACF,QAAQ;AAAA,EAER;AACF,GAAG;","names":["join","polygon","area","impl_exports","mkdir","readFile","readdir","writeFile","join","chalk","init_impl","convertToLabelStudio","buildCommand","convertToPPOCR","path","process"]}
|