하이쿠 검사기
텍스트가 전통 하이쿠의 5-7-5 음절 구조를 따르는지 줄별로 분석하여 확인합니다.
하이쿠 소개
하이쿠는 5-7-5 음절 패턴으로 따르는 3줄의 일본 시입니다. 음절 계산기는 영어 모음 그룹 휴리스틱을 사용하며 모든 단어에 대해 100% 정확하지 않을 수 있습니다.
이 도구 소개
하이쿠 체크는 당신의 텍스트가 전통적인 5-7-5 음수 구조의 하이쿠 시 형식을 따르는지 검증하는 유틸리티 도구입니다. 하이쿠는 수백 년 전부터 이어진 일본의 시 형식으로, 그 간결함과 우아함으로 알려져 있으며 음수 구성은 이 형식의 핵심 요소입니다. 이 도구는 각 줄을 독립적으로 분석하여 음수를 세고 상세한 피드백을 제공하므로, 당신의 작품이 고전적인 형식과 얼마나 잘 맞는지 정확히 확인할 수 있습니다.
하이쿠 체크를 사용하려면 3줄의 시를 입력 필드에 붙여넣고 분석 버튼을 클릭하면 됩니다. 도구는 각 줄의 음수를 표시하고 5-7-5 패턴과 일치하는지 표시합니다. 이는 하이쿠 창작을 배우고 있는 작가, 문학 수업에서 일본 시를 공부하는 학생, 또는 다른 사람과 공유하기 전에 작품을 다듬고 싶은 누구에게나 특히 유용합니다.
자주 묻는 질문
코드 구현
import re
def count_syllables(word: str) -> int:
"""Count syllables in an English word using vowel-group heuristic."""
word = word.lower().strip()
word = re.sub(r"[^a-z]", "", word)
if not word:
return 0
# Count vowel groups
count = len(re.findall(r"[aeiouy]+", word))
# Adjust for silent-e ending
if word.endswith("e") and count > 1:
count -= 1
return max(1, count)
def count_line_syllables(line: str) -> int:
words = re.findall(r"[a-zA-Z'-]+", line)
return sum(count_syllables(w) for w in words)
def check_haiku(text: str) -> dict:
lines = [l.strip() for l in text.strip().split("\n") if l.strip()]
if len(lines) != 3:
return {"valid": False, "error": f"Expected 3 lines, got {len(lines)}"}
counts = [count_line_syllables(line) for line in lines]
expected = [5, 7, 5]
valid = counts == expected
return {
"valid": valid,
"lines": [
{"text": lines[i], "syllables": counts[i], "expected": expected[i]}
for i in range(3)
],
}
haiku = """
An old silent pond
A frog jumps into the pond
Splash! Silence again
"""
result = check_haiku(haiku)
print(f"Valid haiku: {result['valid']}")
for line in result["lines"]:
status = "✓" if line["syllables"] == line["expected"] else "✗"
print(f" {status} {line['syllables']}/{line['expected']} syllables: {line['text']}")Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.