All Projects → scarletcho → KoLM

scarletcho / KoLM

Licence: GPL-3.0 license
Korean text normalization and language preparation package for LM in Kaldi-based ASR system

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to KoLM

Lingvo
Lingvo
Stars: ✭ 2,361 (+5032.61%)
Mutual labels:  lm, asr
Zeroth
Kaldi-based Korean ASR (한국어 음성인식) open-source project
Stars: ✭ 248 (+439.13%)
Mutual labels:  korean, asr
react-native-spokestack
Spokestack: give your React Native app a voice interface!
Stars: ✭ 53 (+15.22%)
Mutual labels:  asr
KoParadigm
KoParadigm: Korean Inflectional Paradigm Generator
Stars: ✭ 48 (+4.35%)
Mutual labels:  korean
AESRC2020
Data preperation scripts, training pipeline and baseline experiment results for the Interspeech 2020 Accented English Speech Recognition Challenge (AESRC).
Stars: ✭ 40 (-13.04%)
Mutual labels:  asr
kor-to-number.js
한글로 적힌 한국어 수사를 숫자로 변환하는 자바스크립트 라이브러리입니다.
Stars: ✭ 39 (-15.22%)
Mutual labels:  korean
website
라라벨 코리아의 홈페이지 소스입니다
Stars: ✭ 31 (-32.61%)
Mutual labels:  korean
uck
숫자 -> 한글 단위 변환 모듈
Stars: ✭ 27 (-41.3%)
Mutual labels:  korean
edit-distance-papers
A curated list of papers dedicated to edit-distance as objective function
Stars: ✭ 49 (+6.52%)
Mutual labels:  asr
avsr-tf1
Audio-Visual Speech Recognition using Sequence to Sequence Models
Stars: ✭ 76 (+65.22%)
Mutual labels:  asr
kospeech
Open-Source Toolkit for End-to-End Korean Automatic Speech Recognition leveraging PyTorch and Hydra.
Stars: ✭ 456 (+891.3%)
Mutual labels:  asr
myG2P
Myanmar (Burmese) Language Grapheme to Phoneme (myG2P) Conversion Dictionary for speech recognition (ASR) and speech synthesis (TTS).
Stars: ✭ 43 (-6.52%)
Mutual labels:  asr
opensource-voice-tools
A repo listing known open source voice tools, ordered by where they sit in the voice stack
Stars: ✭ 21 (-54.35%)
Mutual labels:  asr
Korean-OCR-Model-Design-based-on-Keras-CNN
Korean OCR Model Design(한글 OCR 모델 설계)
Stars: ✭ 34 (-26.09%)
Mutual labels:  korean
zsh-hangul
🇰🇷 한영 전환의 지옥에서 벗어나서 광명찾자!
Stars: ✭ 145 (+215.22%)
Mutual labels:  korean
ctc-asr
End-to-end trained speech recognition system, based on RNNs and the connectionist temporal classification (CTC) cost function.
Stars: ✭ 112 (+143.48%)
Mutual labels:  asr
hacktoberfestkorea
Hacktoberfest Korea site
Stars: ✭ 49 (+6.52%)
Mutual labels:  korean
hangul ipsum
한글 버전의 lorem ipsum 생성기
Stars: ✭ 17 (-63.04%)
Mutual labels:  korean
AlgorithmSet
대회용 Algorithm / DS 모음
Stars: ✭ 18 (-60.87%)
Mutual labels:  korean
TIL
[2020, 12, 12 ~ ing] Today I Learned
Stars: ✭ 18 (-60.87%)
Mutual labels:  korean

KoLM

한국어 언어모델 제작을 위한 파이썬 기반 한국어 텍스트처리 패키지입니다.

Key features

1) utils: 한국어 텍스트처리를 위한 기본 도구들

- 파일 관리  
	- 손쉬운 텍스트파일 읽기와 쓰기, 파일 통합  
- 인코딩 변환  
- 텍스트 처리  
	- 잉여적인 공백 정리  
	- TEI 헤더 제거  
	- 문장별 어절 목록 정리  

2) normalize: 텍스트 정규화

- 텍스트 정규화  
- 길게 이어진 코퍼스를 문장 단위로 자르기  
- 한글이 아닌 문자 삭제  
- 한국어로 된 줄글 외의 문자들 전사  
	- 한글 자모, 한자, 숫자, 알파벳, 영단어 읽기  

3) tag: 형태소와 의사형태소 생성

- 형태소 분석 (KoNLPy 및 Mecab 연동)  
- 형태소 분석 결과로부터 2가지 유형의 의사형태소(pseudo-morpheme) 생성  
	- 최소형태소 (모든 형태 경계를 분리해 가장 작게 잘린 단위; micro)  
	- 중간형태소 (체언과 조사만을 분리해 중간 크기로 잘린 단위 ; medium)  
	
	NB. 의사형태소 생성을 위해서는 형태소 분석이 완료된 텍스트가 필요합니다.
	    본 코드는 울산대 UTagger 형태소분석 아웃풋을 전제하여 의사형태소를 생성하기에,
	    입력되는 텍스트 파일이 UTagger 아웃풋과 다를 경우 추가적인 코드 수정 작업이 필요합니다.

4) lm & g2p: 언어모델 제작을 위한 발음정보 및 정제텍스트 생성

- 문자열로부터 발음열 생성(Grapheme-to-Phone; G2P)  
- 언어모델 제작을 위한 파일 생성  
	- 정제된 코퍼스 원문(textraw) 생성  
	- 발음사전(lexicon.txt) 생성  


Requirements

  • Python 2.7 or 3
  • Required Python packages:
    • KoNLPy, JPype1, korean, hanja, Mecab
    • [Note] The above packages are automatically installed as you install KoLM via pip


Installation

  • The latest version is available in PyPI:

      $ pip install kolm  
    

Tutorial: How to use KoLM

  • 말뭉치 정제 작업 가이드:

    • (1) 모든 텍스트를 UTF-8로 인코딩 변환
      • utils.convertEncoding
    • (2) 모든 텍스트를 하나로 이어붙여 저장하기
      • utils.stackFiles
    • (3) TEI 헤더 (또는 분석대상이 아닌 태그류) 제거
      • utils.removeHeader
    • (4) 텍스트 정규화
      • normalize.Knormalize
    • (5) 형태소분석
      • tag.morphTag
    • (6) 원문-형태소 대조를 통한 의사형태소 추출
      • tag.pseudomorph
    • (7) 정제텍스트(textraw)와 발음사전(lexicon.txt) 생성
      • lm.writeTextraw
      • lm.getUniqueWords
      • lm.writeLexicon
  • 구체적인 사용 예시 코드를 보려면 runKoLM.py 를 참조하세요.

1. utils

  • Start by importing every method in kolm.utils

      >> from kolm.utils import *  
    
  1. File management
    • readfileUTF8 (fname)

        # UTF-8 인코딩된 특정 파일(song15.txt)을 읽어들이기  
        >> readfileUTF8('song15.txt')  
      
    • writefile (body, fname)

        # mydir 내 모든 텍스트의 인코딩을 UTF-16에서 UTF-8로 변환하기  
        >> convertEncoding('mydir', 'utf-16', 'utf-8')  
      
    • stackFiles (path, stackFname, flist=[])

        # mydir 내 모든 텍스트를 한 파일로 모아 mystack.txt 로 저장하기  
        >> stackFiles('mydir', 'mystack.txt')  
      
        # mydir 내 특정 파일들(song1.txt, song2.txt, song15.txt)을 한 파일로 모아 mystack.txt 로 저장하기  
        >> stackFiles('mydir', 'mystack.txt', ['song1.txt', 'song2.txt', 'song15.txt'])		  
      

  1. Encoding
    • convertEncoding (path, encodingSource, encodingDest, flist=[])

        # mydir 내 모든 텍스트의 인코딩을 UTF-16에서 UTF-8로 변환  
        >> convertEncoding('mydir', 'utf-16', 'utf-8')  
          
        # mydir 내 특정 파일들(song1.txt, song2.txt, song15.txt)의 인코딩을 UTF-16에서 UTF-8로 변환  
        >> convertEncoding('mydir', 'utf-16', 'utf-8', ['song1.txt', 'song2.txt', 'song15.txt'])  
      

  1. Text management
    • tightenString (corpus)

        # 텍스트 리스트 내 잉여적인 공백 정리 및 삭제  
        >> tightenString(corpus)  
      
    • getEojeolList (sentlist)

        # 문장 리스트에서 어절 리스트 추출  
        >> getEojeolList(['짧은 문장을 넣었다', '새해 복', '집에 갔더니 밥이 없네')  
      
    • removeHeader (headeredfname)

        >> convertEncoding('mydir', 'utf-16', 'utf-8')  
      

2. normalize

  • Start by importing every method in kolm.normalize

      >> from kolm.normalize import *  
    
  1. Normalization
    • Knormalize (in_fname, out_fname)

        # Normalize a textfile  
        >> Knormalize(in_fname, out_fname)  
      
    • normalize (corpus)

        # Normalize a text list variable in workspace  
        >> normalize(corpus)  
      
    • bySentence (corpus)

        >> bySentence(corpus)  
      
    • removeNonHangul (line)

        >> removeNonHangul(line)  
      

  1. Character reading in Korean
    • Alphabets

      • readABC (line)

          >> readABC(line)  
        
      • readAlphabet (line)

          >> readAlphabet(line)  
        
    • Hanja (Chinese characters)

      • readHanja (line)

          >> readHanja(line)  
        
    • Hangul jamos (i.e. single letters which do not make a syllable)

      • readHangulLetter (line)

          >> readHangulLetter('ㅊ을 ㅈ으로 적었다')  
          치읓을 지읒으로 적었다  
        

  1. Number reading in Korean
    • readNumber (line)

        >> readNumber(line)  
      

3. tag

  • Start by importing every method in kolm.tag

      >> from kolm.tag import *  
    
  1. Morphemes
    • morphTag (in_fname, out_fname)

        # Mecab 형태소분석  
        >> morphTag(in_fname, out_fname)  
      

  1. Pseudo-morphemes
    • morph2pseudo (raw_sentlist, morph_sentlist, type)

        # 문장 리스트로부터 의사형태소(최소 크기) 문장 리스트 생성  
        >> morph2pseudo(raw_sentlist, morph_sentlist, 'micro')  
      
        # 문장 리스트로부터 의사형태소(중간 크기) 문장 리스트 생성  
        >> morph2pseudo(raw_sentlist, morph_sentlist, 'medium')  
      
    • pseudomorph (rawText, morphText, pseudoType)

        # 문장 하나로부터 의사형태소(최소 크기) 문장 생성  
        >> pseudomorph(rawText, morphText, 'micro')  
      
        # 문장 하나로부터 의사형태소(중간 크기) 문장 생성  
        >> pseudomorph(rawText, morphText, 'medium')  
      

4. lm

  • Start by importing every method in kolm.lm

      >> from kolm.lm import *  
    
  • writeTextraw (corpus)

      # 정제를 마친 단일 말뭉치 파일(textraw) 생성  
      >> writeTextraw(corpus)  
    
  • getUniqueWords (text_fname)

      # 고유 어절(또는 형태소; 말뭉치 상의 띄어쓰기된 단위를 의미)목록(wordlist.txt) 추출  
      >> getUniqueWords(text_fname)  
    
  • writeLexicon (text_fname)

      # 고유 어절목록에 G2P를 적용한 발음사전(lexicon.txt) 생성  
      >> writeLexicon(text_fname)  
    

5. g2p

  • Start by importing every method in kolm.g2p

      >> from kolm.g2p import *  
    
  1. Main
    • runKoG2P (hangeul_sequence, rulebook_path)

        # Run Korean G2P on a sequence  
        >> runKoG2P(hangeul_sequence, rulebook_path)  
      
    • runTest (rulebook, testset)

        # Run a test on a testset with a specific rulebook  
        >> runTest(rulebook, testset)  
      
    • readRules (pver, rulebook)

        >> readRules(pver, rulebook)  
      

  1. Auxiliaries
    • phone2prono (phones, rule_in, rule_out)

        >> phone2prono(phones, rule_in, rule_out)  
      
    • graph2prono (graph, rule_in, rule_out)

        >> graph2prono(graph, rule_in, rule_out)  
      
    • graph2phone (graphs)

        >> graph2phone(graphs)  
      
    • isHangul (charint)

        >> isHangul(charint)  
      
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].