fix(desktop): add precise local OCR reading
This commit is contained in:
parent
59cdddbecb
commit
25fd3ac004
30 changed files with 626 additions and 15 deletions
|
|
@ -157,6 +157,64 @@ describe('선택 → 텍스트', () => {
|
|||
expect(selectionText(result, allWords(result), { singleLine: true })).toBe('日本語 OCR テスト次の行')
|
||||
})
|
||||
|
||||
it('selectionText_주소와기호가여러단어로인식된경우_좁은픽셀간격은공백없이잇는다', () => {
|
||||
const result = parseOcrEngineOutput({
|
||||
lang: 'ko',
|
||||
lines: [
|
||||
{
|
||||
words: [
|
||||
{ t: '"https', x: 10, y: 10, w: 63, h: 18.5 },
|
||||
{ t: '://api.example.com/v1/chat', x: 78, y: 10, w: 281.5, h: 18.5 },
|
||||
{ t: '?model=gpt-4&lang=ko', x: 363, y: 10, w: 216.5, h: 18.5 }
|
||||
]
|
||||
},
|
||||
{
|
||||
words: [
|
||||
{ t: 'user.name+tag@example.', x: 10, y: 50, w: 237.5, h: 18.5 },
|
||||
{ t: 'co.', x: 252, y: 58, w: 28.5, h: 10.5 },
|
||||
{ t: 'kr', x: 285.5, y: 54, w: 20, h: 14.5 }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
if (!result) throw new Error('no result')
|
||||
expect(selectionText(result, allWords(result))).toBe(
|
||||
'"https://api.example.com/v1/chat?model=gpt-4&lang=ko\nuser.name+tag@example.co.kr'
|
||||
)
|
||||
})
|
||||
|
||||
it('selectionText_일반단어사이의넓은픽셀간격_공백을유지한다', () => {
|
||||
const result = parseOcrEngineOutput({
|
||||
lang: 'ko',
|
||||
lines: [
|
||||
{
|
||||
words: [
|
||||
{ t: 'const', x: 10, y: 10, w: 53.5, h: 13.5 },
|
||||
{ t: 'url', x: 76, y: 9, w: 31.5, h: 14.5 }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
if (!result) throw new Error('no result')
|
||||
expect(selectionText(result, allWords(result))).toBe('const url')
|
||||
})
|
||||
|
||||
it('selectionText_자간이좁은일반문장_실제단어공백은유지한다', () => {
|
||||
const result = parseOcrEngineOutput({
|
||||
lang: 'en-US',
|
||||
lines: [
|
||||
{
|
||||
words: [
|
||||
{ t: 'hello', x: 10, y: 10, w: 25, h: 16 },
|
||||
{ t: 'world', x: 39, y: 10, w: 30, h: 16 }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
if (!result) throw new Error('no result')
|
||||
expect(selectionText(result, allWords(result))).toBe('hello world')
|
||||
})
|
||||
|
||||
it('selectionText_아무것도안고름_빈문자열', () => {
|
||||
expect(selectionText(sample(), [])).toBe('')
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue