Skip to content

Commit

Permalink
Dev (#7)
Browse files Browse the repository at this point in the history
* feat: requirements

* feat: modify docker

* feat: 꼬임

* feat: docker ignore

* feat: pronounce rule

* feat: 겹받침 (#6)
  • Loading branch information
ssoxong authored Nov 13, 2024
1 parent 33ab1c9 commit 71a7b48
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
15 changes: 9 additions & 6 deletions crud/pronounce.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ def analysis_gugaeumhwa(text, dec):
if len(r)!=3: continue
if i+1>=len(dec): continue
if not (r[2]=='ㄷ' or r[2]=='ㅌ'): continue
print(r)
if (text[i+1]=='이' or text[i+1]=='히'):
gugaeumhwa.append(text[i:i+2])

return gugaeumhwa

def analysis_beumhwa(text, dec):
beumhwa=[]
payeoleum = ['ㅂ','ㄷ','ㄱ']
payeoleum = ['ㅂ','ㄷ','ㄱ', 'ㅍ','ㄼ','ㅄ','ㅅ','ㅆ','ㅈ','ㅊ','ㅎ','ㄲ','ㅋ','ㄺ']
beeum = ['ㄴ','ㅁ']
for i, r in enumerate(dec):
r = [col for col in r if col.strip()]
Expand All @@ -50,7 +49,8 @@ def analysis_yueumhwa(text, dec):
for i, r in enumerate(dec):
r = [col for col in r if col.strip()]
if len(r)!=3: continue
if i+1>len(dec): continue
if i+1>=len(dec): continue


if r[2]=='ㄹ' and dec[i+1][0]=='ㄴ':
yueumhwa.append(text[i:i+2])
Expand All @@ -73,6 +73,7 @@ def analysis_yeoneumhwa(text, dec):
fdec = crud.difficulty.decomposition(forward)
fdec = [col for col in fdec[-1] if col.strip()]
if len(fdec)!=3: continue
if fdec[2]=='ㅇ': continue
yeoneumhwa.append(forward+word)
# 받침 뒤에 ㅏ, ㅓ, ㅗ, ㅜ, ㅟ로 시작하는 실질 형태소가 오는 경우

Expand Down Expand Up @@ -103,6 +104,7 @@ def anaylsis_gyeonumhwa(text, dec):
# 용언의 어간 받침 ㄴ, ㅁ 뒤 ㄱ, ㄷ, ㅅ, ㅈ
# VV(동사)[2]
for i, (word, tag) in enumerate(pos):

if tag == 'VV':
wdec = crud.difficulty.decomposition(word)
if wdec[-1][2] not in ['ㄴ','ㅁ']: continue
Expand All @@ -114,10 +116,10 @@ def anaylsis_gyeonumhwa(text, dec):
# 관형사형 어미 -(으)ㄹ 뒤 ㄱ, ㄷ, ㅂ, ㅅ, ㅈ
# ETM
for i, (word, tag) in enumerate(pos):
print(tag)
if 'ETM' in tag:
wdec = crud.difficulty.decomposition(word)
if wdec[-1][2] not in ['ㄹ']: continue
if wdec[-1][0]!='ㅇ' or wdec[-1][2] != 'ㄹ': continue

sdec = crud.difficulty.decomposition(pos[i+1][0])

if sdec[0][0] not in n1list: continue
Expand All @@ -138,7 +140,8 @@ def doubleb_analysis(text, dec):

# 받침 ㄱ,ㄷ,ㅂ 뒤 ㄱㄷㅂㅅㅈ
if r[2] in doubleblist:
doubleb.append(text[i:i+2])
doubleb.append(text[i])


return doubleb

Expand Down
11 changes: 9 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel, Field
from typing import Dict
import os
from dotenv import load_dotenv
import json
Expand All @@ -26,10 +27,16 @@ class ClaudeRequest(BaseModel):
age: int = Field(default=11)
rule: PronounceRule
count: int = Field(default=5)


@app.post("/phonological_rules")
async def analysis_pronounce(text: str):
return crud.pronounce.analysis_pronounce_crud(text)
async def analysis_pronounce(text: Dict[int, str]):
analysis = {}
for n, t in text.items():
if not t:
raise HTTPException(status_code=400, detail="text에 빈 문자열이 포함되어 있습니다.")
analysis[n]=crud.pronounce.analysis_pronounce_crud(t)
return analysis

@app.post("/claude")
async def generate_claude(request: ClaudeRequest):
Expand Down

0 comments on commit 71a7b48

Please sign in to comment.