Skip to main content
Deno 2 is finally here πŸŽ‰οΈ
Learn more

Seonbi client library for Deno

Latest version

Seonbi is an HTML preprocessor that makes typographic/orthographic adjustments on Korean text. See the website for details.

This directory contains a simple client library which manages and communicates with Seonbi HTTP API server. The transform() function and Seonbi class automatically downloads the Seonbi executable binary and runs the server under the hood.

Here’s an example code for one-shot transformation:

import { transform } from "https://deno.land/x/seonbi/mod.ts";

const input = "λ””λ…Έλ₯Ό ι€šν•΄ μ“°λŠ” μ„ λΉ„";
const output = transform(input);
console.log(output);  // λ””λ…Έλ₯Ό 톡해 μ“°λŠ” μ„ λΉ„

When there are multiple inputs to transform, makes a Seonbi instance and call its transform() method multiple times so that the server subprocess are not spawned needlessly more than once:

import { Seonbi } from "https://deno.land/x/seonbi/mod.ts";

const inputs = [
  "序詩",
  "ηœ‹ζΏ μ—†λŠ” 거리",
  "ε€ͺ初의 μ•„μΉ¨",
  "λ¬΄μ„œμš΄ ζ™‚ι–“",
  "눈 μ˜€λŠ” εœ°εœ–",
  "별 ν—€λŠ” λ°€",
  "μŠ¬ν”ˆ 族屬",
];
const seonbi = new Seonbi();
const outputs = await Promise.all(inputs.map(input => seonbi.transform(input)));
console.log(outputs);
/*
[
  "μ„œμ‹œ",
  "κ°„νŒ μ—†λŠ” 거리",
  "νƒœμ΄ˆμ˜ μ•„μΉ¨",
  "λ¬΄μ„œμš΄ μ‹œκ°„",
  "눈 μ˜€λŠ” 지도",
  "별 ν—€λŠ” λ°€",
  "μŠ¬ν”ˆ 쑱속",
]
*/