npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

open-korean-text-node

v2.2.0

Published

Nodejs binding for open-korean-text via java interface.

Downloads

8

Readme

open-korean-text-node

npm version Build Status

A nodejs binding for open-korean-text via node-java interface.

Dependency

Currently wraps open-korean-text 2.2.0

현재 이 프로젝트는 open-korean-text 2.2.0을 사용중입니다.

Requirement

Since it uses java code compiled with Java 8, make sure you have both Java 8 JDK and JRE installed.
For more details about installing java interface, see installation notes on below links.

이 프로젝트는 Java 8로 컴파일된 코드를 사용하기 때문에, Java 8 JDK/JRE가 설치되어 있어야 합니다.
Java interface의 설치에 관련된 더 자세한 사항은 아래 링크에서 확인하세요.

Installation

npm install --save open-korean-text-node

Usage

import OpenKoreanText from 'open-korean-text-node';
// or
const OpenKoreanText = require('open-korean-text-node').default;
  • See API section to get more informations.

Examples

API

OpenKoreanText

Tokenizing

OpenKoreanText.tokenize(text: string): Promise<IntermediaryTokens>;
OpenKoreanText.tokenizeSync(text: string): IntermediaryTokens;
  • text a target string to tokenize

Detokenizing

OpenKoreanText.detokenize(tokens: IntermediaryTokensObject): Promise<string>;
OpenKoreanText.detokenize(words: string[]): Promise<string>;
OpenKoreanText.detokenize(...words: string[]): Promise<string>;
OpenKoreanText.detokenizeSync(tokens: IntermediaryTokensObject): string;
OpenKoreanText.detokenizeSync(words: string[]): string;
OpenKoreanText.detokenizeSync(...words: string[]): string;
  • tokens an intermediary token object from tokenize
  • words an array of words to detokenize

Phrase Extracting

OpenKoreanText.extractPhrases(tokens: IntermediaryTokens, options?: ExcludePhrasesOptions): Promise<KoreanToken>;
OpenKoreanText.extractPhrasesSync(tokens: IntermediaryTokens, options?: ExcludePhrasesOptions): KoreanToken;
  • tokens an intermediary token object from tokenize or stem
  • options an object to pass options to extract phrases where
    • filterSpam - a flag to filter spam tokens. defaults to true
    • includeHashtag - a flag to include hashtag tokens. defaults to false

Normalizing

OpenKoreanText.normalize(text: string): Promise<string>;
OpenKoreanText.normalizeSync(text: string): string;
  • text a target string to normalize

Sentence Splitting

OpenKoreanText.splitSentences(text: string): Promise<Sentence[]>;
OpenKoreanText.splitSentencesSync(text: string): Sentence[];
  • text a target string to normalize
  • returns array of Sentence which includes:
    • text: string - the sentence's text
    • start: number - the sentence's start position from original string
    • end: number - the sentence's end position from original string

Custom Dictionary

OpenKoreanText.addNounsToDictionary(...words: string[]): Promise<void>;
OpenKoreanText.addNounsToDictionarySync(...words: string[]): void;
  • words words to add to dictionary

toJSON

OpenKoreanText.tokensToJsonArray(tokens: IntermediaryTokensObject, keepSpace?: boolean): Promise<KoreanToken[]>;
OpenKoreanText.tokensToJsonArraySync(tokens: IntermediaryTokensObject, keepSpace?: boolean): KoreanToken[];
  • tokens an intermediary token object from tokenize or stem
  • keepSpace a flag to omit 'Space' token or not, defaults to false

IntermediaryToken object

An intermediate token object required for internal processing.
Provides a convenience wrapper functionS to process text without using processor object

tokens.extractPhrases(options?: ExcludePhrasesOptions): Promise<KoreanToken>;
tokens.extractPhrasesSync(options?: ExcludePhrasesOptions): KoreanToken;
tokens.detokenize(): Promise<string>;
tokens.detokenizeSync(): string;
tokens.toJSON(): KoreanToken[];
  • NOTE: tokens.toJSON() method is equivalent with OpenKoreanText.tokensToJsonArraySync(tokens, false)

KoreanToken object

A JSON output object which contains:

  • text: string - token's text
  • stem: string - token's stem
  • pos: stirng - type of token. possible entries are:
    • Word level POS: Noun, Verb, Adjective, Adverb, Determiner, Exclamation, Josa, Eomi, PreEomi, Conjunction, NounPrefix, VerbPrefix, Suffix, Unknown
    • Chunk level POS: Korean, Foreign, Number, KoreanParticle, Alpha, Punctuation, Hashtag, ScreenName, Email, URL, CashTag
    • Functional POS: Space, Others
  • offset: number - position from original string
  • length: number - length of text
  • isUnknown: boolean