korean-word-relay
끝말잇기 package for python
- 한국어 낱말 게임 끝말잇기를 쉽게 커스터마이징 할 수 있는 패키지
- 모델이 사용할 끝말잇기 단어 직접 선택 (난이도 조절 가능)
- 두음법칙 적용 (여부 선택)
- 이전 단어와 이어지지 않거나 이미 나왔던 단어 입력시 패배
Installation
Using pip:
pip install korean-word-relay
Usage
Quick Start
from korean_word_relay import WordRelay
word_relay = WordRelay()
word_relay.play()
result
--------------끝말잇기----------------
시작 단어: 파이썬
<< 썬샤인
>> 인간
<< 간택
>> 택시
<< 시리
>> 리그
<< 그대
>> 대략
<< 약관
>> 관람
<< 람보
>> 보도
<< 도로묵
------------------------------
no word to answer
YOU WIN!
Default optional parameter
word_relay = WordRelay(import_default=True, words_path=None, use_dueum=True, debug_print=True):
)
- import_default(boolean): If True, import candidates of korean words from '자주 쓰이는 한국어 낱말 모음 5800'
words_path(None|string): If given path(.txt), import candidates of words list from txt fileuse_dueum(boolean): If True, 두음법칙 is alloweddebug_print(boolean): If True, print warning message on console
Example format for words_path
words_path should be None or list of korean words in txt extension. For instance, word_list.txt should be
사랑
우정
믿음
.
.
여자친구
If you want to make game much difficult, get killing_words.txt from here.
Methods of WordRelay
word_relay = WordRelay()
# 주어진 낱말에 이어지는 단어 리턴
# set log_history=False if you don't want to add word in history
next_word = word_relay.get_next('성질') # next_word is None or 질X (예: 질문)
# 두 낱말이 이어지는지 여부 체크
is_continue = word_relay.check_continue('질문', '문지기') # is_continue == True
# 특정 낱말을 이미 나온말(history)에 추가
word_relay.add_history('문지기')
print(word_relay.history) # word_relay.history = ['질문', '문지기'], 질문 was added get_next above
# history 를 초기화
word_relay.reset()
print(word_relay.history) # word_relay.history = []
etc
Checking whether word is valid or not is not implemented in this project, since 1. criteria for valid language is keep changing, 2. including korean dictionary can make this package too big. You can implement your own code to check whether word is valid or not.
Metadata
Release files for korean-word-relay 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| korean_word_relay-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Release files / korean_word_relay-0.0.6-py3-none-any.whl
| Download URL | korean_word_relay-0.0.6-py3-none-any.whl |
|---|---|
| Size | 18.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3d95f01f25110782b29cb71301bb879624177197d669d3c08410ea9a89bfb222
|
|
BLAKE2b-256 checksum How to use checksums |
49069e2c11131e9163caa53c9ccff2574636c3b581b7bd134d051ecaa83b9054
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.4.2 requests/2.23.0 setuptools/49.3.1 requests-toolbelt/0.8.0 tqdm/4.48.2 CPython/3.8.10
|