blueradiance commited on
Commit
bcc4b4f
·
verified ·
1 Parent(s): 4cabd11

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -102,13 +102,15 @@ def expand_variation_patterns(text: str, mapping: dict) -> str:
102
  👓 태그된 텍스트에서 성+이름+호칭+조사 형태를 다시 태깅
103
  """
104
  for tag, base in mapping.items():
105
- prefix = r'[\s\(\["\']*' # 유니코드 특수문자 제거한 정식 표현
106
  suffix = f"(?:{'|'.join(COMMON_SUFFIXES)})?"
107
  josa = f"(?:{'|'.join(COMMON_JOSA)})?"
108
  pattern = re.compile(rf'{prefix}{re.escape(base)}{suffix}{josa}', re.IGNORECASE)
 
109
  text = pattern.sub(lambda m: m.group(0).replace(base, tag), text)
110
  return text
111
 
 
112
  def boost_mapping_from_context(text: str, mapping: dict) -> dict:
113
  """
114
  📌 태깅된 텍스트에서 각 태그의 실제 확장된 표현 감지해 mapping 보정
 
102
  👓 태그된 텍스트에서 성+이름+호칭+조사 형태를 다시 태깅
103
  """
104
  for tag, base in mapping.items():
105
+ prefix = r'[\\s\\(\\["\\\']*' # 공백, 괄호, 따옴표 포함된 안전 패턴
106
  suffix = f"(?:{'|'.join(COMMON_SUFFIXES)})?"
107
  josa = f"(?:{'|'.join(COMMON_JOSA)})?"
108
  pattern = re.compile(rf'{prefix}{re.escape(base)}{suffix}{josa}', re.IGNORECASE)
109
+
110
  text = pattern.sub(lambda m: m.group(0).replace(base, tag), text)
111
  return text
112
 
113
+
114
  def boost_mapping_from_context(text: str, mapping: dict) -> dict:
115
  """
116
  📌 태깅된 텍스트에서 각 태그의 실제 확장된 표현 감지해 mapping 보정