All Projects β†’ dahlia β†’ Seonbi

dahlia / Seonbi

Licence: lgpl-2.1
SmartyPants for Korean language

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to Seonbi

Pandoc
Universal markup converter
Stars: ✭ 24,250 (+31807.89%)
Mutual labels:  document, converter
Typescript Kr.github.io
πŸ‡°πŸ‡· TypeScript Handbook in Korean
Stars: ✭ 364 (+378.95%)
Mutual labels:  korean, document
I18n Generator
i18n json files generator for node, web browser and command line
Stars: ✭ 60 (-21.05%)
Mutual labels:  converter
Instatrack
Convert Instagram user ID to username & vice versa
Stars: ✭ 70 (-7.89%)
Mutual labels:  converter
Inspec tools
A command-line and ruby API of utilities, converters and tools for creating, converting and processing security baseline formats, results and data
Stars: ✭ 65 (-14.47%)
Mutual labels:  converter
Node Quill Converter
Convert HTML to a Quill Delta or a Quill Delta to HTML
Stars: ✭ 61 (-19.74%)
Mutual labels:  converter
Linkify Markdown
πŸš€ A cli tool which automatically add references to issues, pull requests, user mentions and forks to a markdown file.
Stars: ✭ 67 (-11.84%)
Mutual labels:  converter
Tsvoiceconverter
A Swift VoiceConverter between AMR format and WAV format
Stars: ✭ 58 (-23.68%)
Mutual labels:  converter
Neis Api
λΉ λ₯΄κ³  κ°€λ²Όμš΄ μ „κ΅­ 초, 쀑, 고등학ꡐ 급식 식단/학사일정 νŒŒμ„œ
Stars: ✭ 74 (-2.63%)
Mutual labels:  korean
Awesome Readme
A guide to writing an Awesome README. Read the full article in Towards Data Science.
Stars: ✭ 65 (-14.47%)
Mutual labels:  document
Fast Youtube To Mp3 Converter Api
Very Fast YouTube to MP3 & MP4 Converter API
Stars: ✭ 69 (-9.21%)
Mutual labels:  converter
Kor2vec
Library for Korean morpheme and word vector representation
Stars: ✭ 64 (-15.79%)
Mutual labels:  korean
Vse Formatdocumentonsave
Visual Studio - Format Document on Save
Stars: ✭ 61 (-19.74%)
Mutual labels:  document
Scanbot Sdk Example Android
Document scanning SDK example apps for the Scanbot SDK for Android.
Stars: ✭ 67 (-11.84%)
Mutual labels:  document
Gulp Apidoc
πŸ“„ RESTful web API Documentation Generator
Stars: ✭ 60 (-21.05%)
Mutual labels:  document
Gluon2pytorch
Gluon to PyTorch deep neural network model converter
Stars: ✭ 70 (-7.89%)
Mutual labels:  converter
Typescript Handbook Ko
TypeScript Handbook in Korean.
Stars: ✭ 60 (-21.05%)
Mutual labels:  korean
Cifar2png
Convert CIFAR-10 and CIFAR-100 datasets into PNG images
Stars: ✭ 64 (-15.79%)
Mutual labels:  converter
Json Ditto
Declarative JSON-to-JSON mapper .. shape-shift JSON files with Ditto πŸ‘»
Stars: ✭ 66 (-13.16%)
Mutual labels:  converter
Youtube Channel Name Converter
A Youtube Channel Name to ID Converter
Stars: ✭ 75 (-1.32%)
Mutual labels:  converter

Seonbi: SmartyPants for Korean language

(TL;DR: See the demo web app.)

Seonbi (μ„ λΉ„) is an HTML preprocessor that makes typographic adjustments to an HTML so that the result uses accurate punctuations according to the modern Korean orthography. (It's similar to what SmartyPants does for text written in English.)

It also transforms ko-Kore text (εœ‹ζΌ’ζ–‡ζ··η”¨; Korean mixed script) into ko-Hang text (ν•œκΈ€μ „μš©; Hangul-only script).

Seonbi provides a Haskell library, a CLI, and an HTTP API; any of them can perform the following transformations:

  • All hanja words (e.g., ζΌ’ε­—) into corresponding hangul-only words (e.g., ν•œμž)
  • Straight quotes and apostrophes (" & ') into curly quotes HTML entities (β€œ, ”, β€˜, & ’)
  • Three consecutive periods (... or 。。。) into an ellipsis entity (…)
  • Classical (Chinese-style) stops (。 & 、) into modern (English-style) stops (. & ,)
  • Pairs of less-than and greater-than inequality symbols (< & >) into pairs of proper angle quotes (γ€ˆ & 〉)
  • Pairs of two consecutive inequality symbols (<< & >>) into pairs of proper double angle quotes (γ€Š & 》)
  • A hyphen (-) or hangul vowel eu (γ…‘) surrounded by spaces, or two/three consecutive hyphens (-- or ---) into a proper em dash (β€”)
  • A less-than inequality symbol followed by a hyphen or an equality symbol (<-, <=) into arrows to the left (←, ⇐)
  • A hyphen or an equality symbol followed by a greater-than inequality symbol (->, =>) into arrows to the right (β†’, β‡’)
  • A hyphen or an equality symbol wrapped by inequality symbols (<->, <=>) into bi-directional arrows (↔, ⇔)

Since its transformations work in HTML-level, it also plays well with web markup languages like CommonMark, Markdown, and Textile. In a similar way to SmartyPants, it does not modify characters within several sensitive HTML elements like <pre>/<code>/<script>/<kbd>.

Installation

Seonbi provides official executable binaries for Linux (x86_64), macOS, and Windows (64-bit). You can download them from the releases page.

It is also distributed as a Docker image:

$ echo 'θ¨“ζ°‘ζ­£ιŸ³' | docker run -i dahlia/seonbi:latest seonbi
ν›ˆλ―Όμ •μŒ

If you want to use it as a Haskell library install the seonbi package using Stack or Cabal.

CLI

The seonbi command basically takes the input HTML as standard input, and then transforms it into the output HTML as standard output:

seonbi < input.html > output.html

You could pass a filename as an argument instead (and it is - by default):

seonbi input.html > output.html

There is -o/--output option as well:

seonbi -o output.html input.html

Although it automatically detects text encoding of the input file, you could explicitly specify -e/--encoding:

seobni -e euc-kr -o output.html input.html

Although there are several style options, e.g., -q/--quote, -c/--cite, -r/--render-hanja, in most cases, giving -p/--preset is enough:

echo 'εΉ³ε£€ ε†·ιΊ΅' | seonbi -p ko-kr  # 평양 냉면
echo 'εΉ³ε£€ ε†·ιΊ΅' | seonbi -p ko-kp  # 평양 랭면

Read -h/--help for details:

seonbi --help

HTTP API

The seonbi-api command starts an HTTP server that takes POST requests with an HTML source with transformation options, and responds with a transformed result HTML. You can decide a hostname and a port number with -H/--host and -p/--port options:

seonbi-api -H 0.0.0.0 -p 3800

The following is an example request:

POST / HTTP/1.1
Content-Type: application/json
Host: localhost:3800

{
  "preset": "ko-kr",
  "sourceHtml": "<p>ν•˜λŠ˜κ³Ό λ°”λžŒκ³Ό 별과 θ©©</p>"
}

The HTTP API server would respond like this:

HTTP/1.1 200 OK
Content-Type: application/json
Server: Seonbi/0.2.0

{
  "success": true,
  "resultHtml": "<p>ν•˜λŠ˜κ³Ό λ°”λžŒκ³Ό 별과 μ‹œ</p>"
}

If a web app needs to use the HTTP API server, CORS should be configured through --allow-origin/-o option:

seonbi-api -o https://example.com

To learn more about parameters interactively, try the demo web app.

Haskell API

All functions and types lie inside Text.Seonbi module and its submodules. The highest-level API is Text.Seonbi.Facade module.

See also the API docs or Hackage.

License

Distributed under LGPL 2.1 or later.

Etymology

Seonbi (μ„ λΉ„) means a classical scholar during Joseon periods (14c–19c). Today there's a meme that calls a person who feels morally superior or has elitism seonbi in the Korean internet. So seonbi and smarty pants have some things in common.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].