-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ts
51 lines (46 loc) · 1.2 KB
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { extract_lines } from '@beenotung/tslib/string'
import { translate } from './client'
import debug from 'debug'
let log = debug('test')
log.enabled = true
let source_lang = 'en'
let target_lang = 'zh'
let text = `
The future of healthcare is here
For patients:
For providers:
`
async function main() {
let lines = extract_lines(text)
let label = 'translate ' + lines.length + ' items'
console.time(label)
await Promise.all(
lines.map(async src => {
let out = await translate({
text: src,
target_lang,
source_lang,
})
log({ src, out })
}),
)
console.timeEnd(label)
{
let src = `
Our virtual clinics empower patients to receive care anytime, anywhere, provided by our licensed therapists using XR technology
`
console.time('translate long text')
console.log(`${'='.repeat(8)} ${source_lang} ${'='.repeat(8)}`)
console.log(src)
console.log(`${'='.repeat(8)} ${target_lang} ${'='.repeat(8)}`)
let out = await translate({
text: src,
source_lang,
target_lang,
})
console.log(out)
console.log('='.repeat(8 + 4 + 8))
console.timeEnd('translate long text')
}
}
main().catch(e => console.error(e))