Yuchan5386 commited on
Commit
df8ae21
Β·
verified Β·
1 Parent(s): 55632cc

Update api.py

Browse files
Files changed (1) hide show
  1. api.py +0 -18
api.py CHANGED
@@ -372,26 +372,13 @@ def simple_intent_classifier(text):
372
  text = text.lower()
373
  greet_keywords = ["μ•ˆλ…•", "λ°˜κ°€μ›Œ", "이름", "λˆ„κ΅¬", "μ†Œκ°œ", "μ–΄λ””μ„œ μ™”", "정체", "λͺ‡ μ‚΄", "λ„ˆ 뭐야"]
374
  info_keywords = ["μ„€λͺ…", "정보", "무엇", "뭐야", "μ–΄λ””", "λˆ„κ΅¬", "μ™œ", "μ–΄λ–»κ²Œ", "μ’…λ₯˜", "κ°œλ…"]
375
- math_keywords = ["λ”ν•˜κΈ°", "λΉΌκΈ°", "κ³±ν•˜κΈ°", "λ‚˜λˆ„κΈ°", "루트", "제곱", "+", "-", "*", "/", "=", "^", "√", "계산", "λͺ‡μ΄μ•Ό", "μ–Όλ§ˆμ•Ό"]
376
  if any(kw in text for kw in greet_keywords):
377
  return "인사"
378
  elif any(kw in text for kw in info_keywords):
379
  return "μ •λ³΄μ§ˆλ¬Έ"
380
- elif any(kw in text for kw in math_keywords):
381
- return "μˆ˜ν•™μ§ˆλ¬Έ"
382
  else:
383
  return "μΌμƒλŒ€ν™”"
384
 
385
- def parse_math_question(text):
386
- text = text.replace("κ³±ν•˜κΈ°", "*").replace("λ”ν•˜κΈ°", "+").replace("λΉΌκΈ°", "-").replace("λ‚˜λˆ„κΈ°", "/").replace("제곱", "*2")
387
- text = re.sub(r'루트\s(\d+)', r'math.sqrt(\1)', text)
388
- try:
389
- result = eval(text)
390
- return f"정닡은 {result}μž…λ‹ˆλ‹€."
391
- except:
392
- return "계산할 수 μ—†λŠ” μˆ˜μ‹μ΄μ—μš”. λ‹€μ‹œ ν•œλ²ˆ 확인해 μ£Όμ„Έμš”!"
393
-
394
-
395
  def respond(input_text):
396
  # 1) μ‚¬μš©μž μž…λ ₯ 기얡에 μ €μž₯ (μ›ν•˜λ©΄)
397
  memory.add(input_text)
@@ -408,11 +395,6 @@ def respond(input_text):
408
  memory.add(response)
409
  return response
410
 
411
- if intent == "μˆ˜ν•™μ§ˆλ¬Έ":
412
- response = parse_math_question(input_text)
413
- memory.add(response)
414
- return response
415
-
416
  if intent == "μ •λ³΄μ§ˆλ¬Έ":
417
  keyword = re.sub(r"(에 λŒ€ν•΄|에 λŒ€ν•œ|에 λŒ€ν•΄μ„œ)?\s*(μ„€λͺ…ν•΄μ€˜|μ•Œλ €μ€˜|뭐야|κ°œλ…|μ •μ˜|정보)?", "", input_text).strip()
418
  if not keyword:
 
372
  text = text.lower()
373
  greet_keywords = ["μ•ˆλ…•", "λ°˜κ°€μ›Œ", "이름", "λˆ„κ΅¬", "μ†Œκ°œ", "μ–΄λ””μ„œ μ™”", "정체", "λͺ‡ μ‚΄", "λ„ˆ 뭐야"]
374
  info_keywords = ["μ„€λͺ…", "정보", "무엇", "뭐야", "μ–΄λ””", "λˆ„κ΅¬", "μ™œ", "μ–΄λ–»κ²Œ", "μ’…λ₯˜", "κ°œλ…"]
 
375
  if any(kw in text for kw in greet_keywords):
376
  return "인사"
377
  elif any(kw in text for kw in info_keywords):
378
  return "μ •λ³΄μ§ˆλ¬Έ"
 
 
379
  else:
380
  return "μΌμƒλŒ€ν™”"
381
 
 
 
 
 
 
 
 
 
 
 
382
  def respond(input_text):
383
  # 1) μ‚¬μš©μž μž…λ ₯ 기얡에 μ €μž₯ (μ›ν•˜λ©΄)
384
  memory.add(input_text)
 
395
  memory.add(response)
396
  return response
397
 
 
 
 
 
 
398
  if intent == "μ •λ³΄μ§ˆλ¬Έ":
399
  keyword = re.sub(r"(에 λŒ€ν•΄|에 λŒ€ν•œ|에 λŒ€ν•΄μ„œ)?\s*(μ„€λͺ…ν•΄μ€˜|μ•Œλ €μ€˜|뭐야|κ°œλ…|μ •μ˜|정보)?", "", input_text).strip()
400
  if not keyword: