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

sejong-morphemes

v0.4.37

Published

decode morphemes text into morphemes object, or encode morphemes object into morphemes text based on tags from sejong project

Downloads

11

Readme

NPM version Build Status Dependency Status Coverage percentage

한글 문장 및 어절을 세종계획 기반의 형태소로 태깅하기 위한 라이브러리

Install

$ npm install --save hangul-morphemes

Usage

var morphemesText = '정치가/NNG 모임/NNG+이/JC 새로/MA 구성/NNG+되/XS+ㄴ다/EF+./SF';
var morphemesObj = {
	text: '정치가 모임이 새로 구성된다.',
	words: [
		{
			text: '정치가',
			morphemes: [{text: '정치가', type: 'NNG'}]
		},
		{
			text: '모임이',
			morphemes: [{text: '모임', type: 'NNG'}, {text: '이', type: 'JC'}]
		},
		{
			text: '새로',
			morphemes: [{text: '새로', type: 'MA'}]
		},
		{
			text: '구성된다',
			morphemes: [{text: '구성', type: 'NNG'}, {text: '되', type: 'XS'}, {text: 'ㄴ다', type: 'EF'}, {text: '.', type: 'SF'}]
		}
	]
};

var morphemes = require('hangul-morphemes');
morphemes.initialize();

var Morpheme = morphemes.Morpheme;
var Word = morphemes.Word;
var Phrase = morphemes.Phrase;
var Sentence = morphemes.Sentence;

var sentence1 = new Sentence(morphemesText);
// sentence1.toString() === morphemesText
// sentence1.toJSON() == morphemesObj

var sentence2 = new Sentence();
var word1 = new Word('정치가/NNG');
var word2 = new Word('모임/NNG+이/JC');
var word3 = new Word('새로/MA');
var word4 = new Word('구성/NNG+되/XS+ㄴ다/EF+./SF');
sentence2.add(word1);
sentence2.add(word2);
sentence2.add(word3);
sentence2.add(word4);
// sentence2.toString() === morphemesText
// sentence2.toJSON() == morphemesObj

var word = new Word();
var morpheme1 = new Morpheme('모임', 'NNG');
var morpheme2 = new Morpheme('이', 'JC');
word.add(morpheme1);
word.add(morpheme2);
// word.toString() === word2.toString();
// word.toJSON() == word2.toJSON();

var phrase = new Phrase();
var structure = new SentenceStructure(sentence);
structure.connect(0, 1);
structure.connect(0, 3);
structure.disconnect(0, 1);

// 내장된 태그셋과 다른 태그셋을 이용하고자 할 때는
// initialize 함수에 사용하고자 하는 태그셋을 인자로 넘겨준다.
// alias를 지정하면 해당 태그에 대해 alias를 이용할 수 있다.
morphemes.initialize({
	morpheme: {
		tag: {
			ABC: 'abc',
			DEF: 'def'
		},
		alias: {
			'뮻': 'ABC',
			'뮤ㅊ': 'ABC',
			'ㅁㅠㅊ': 'ABC',
			'ㅇㄷㄹ': 'DEF'
		}
	},
	phrase: {
		tag: {},
		alias: {}
	}
});

// 태그는 기본적으로 영문 대문자로 가정한다.
// 소문자 태그를 사용하는 경우에는 alias를 지정해야 한다.
morphemes.initialize({
	morpheme: {
		tag: {
			root: '어근'
			modi: '한정자'
		},
		alias: {
			'ROOT': 'root',
			'MODI': 'modi'
		}
	}
});

License

MIT © Dongwon Lim