soojeongcrystal commited on
Commit
3341082
ยท
verified ยท
1 Parent(s): 5b8f710

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -16
app.py CHANGED
@@ -5,8 +5,6 @@ from sklearn.decomposition import LatentDirichletAllocation
5
  import re
6
  import warnings
7
  from collections import Counter
8
- from soynlp.noun import LRNounExtractor
9
- from soynlp.tokenizer import RegexTokenizer
10
  import traceback
11
 
12
  warnings.filterwarnings("ignore")
@@ -23,23 +21,14 @@ default_stopwords = set([
23
  "๋˜ํ•œ", "๊ทธ๋ž˜์„œ", "๊ทธ๋ฆฌ๊ณ ", "ํ•˜์ง€๋งŒ", "๊ทธ๋Ÿฌ๋‚˜", "๋”ฐ๋ผ์„œ", "๋•Œ๋ฌธ์—"
24
  ])
25
 
26
- @st.cache_resource
27
- def load_noun_extractor():
28
- return LRNounExtractor()
29
-
30
- noun_extractor = load_noun_extractor()
31
- tokenizer = RegexTokenizer()
32
 
33
  def extract_nouns(text):
34
  try:
35
- # ์ „์ฒด ํ…์ŠคํŠธ์— ๋Œ€ํ•ด ํ•œ ๋ฒˆ๋งŒ extract ๋ฉ”์„œ๋“œ ํ˜ธ์ถœ
36
- extracted = noun_extractor.extract(text)
37
- if extracted is None:
38
- st.warning("๋ช…์‚ฌ ์ถ”์ถœ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค.")
39
- return []
40
- # score๊ฐ€ 0๋ณด๋‹ค ํฐ ๋‹จ์–ด๋งŒ ์„ ํƒ
41
- nouns = [word for word, score in extracted.items() if score > 0]
42
- # 2์Œ์ ˆ ์ด์ƒ์˜ ๋ช…์‚ฌ๋งŒ ์„ ํƒ
43
  return [noun for noun in nouns if len(noun) > 1]
44
  except Exception as e:
45
  st.error(f"๋ช…์‚ฌ ์ถ”์ถœ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}")
 
5
  import re
6
  import warnings
7
  from collections import Counter
 
 
8
  import traceback
9
 
10
  warnings.filterwarnings("ignore")
 
21
  "๋˜ํ•œ", "๊ทธ๋ž˜์„œ", "๊ทธ๋ฆฌ๊ณ ", "ํ•˜์ง€๋งŒ", "๊ทธ๋Ÿฌ๋‚˜", "๋”ฐ๋ผ์„œ", "๋•Œ๋ฌธ์—"
22
  ])
23
 
24
+ def simple_noun_extractor(text):
25
+ pattern = r'\b[๊ฐ€-ํžฃ]{2,}\b'
26
+ nouns = re.findall(pattern, text)
27
+ return nouns
 
 
28
 
29
  def extract_nouns(text):
30
  try:
31
+ nouns = simple_noun_extractor(text)
 
 
 
 
 
 
 
32
  return [noun for noun in nouns if len(noun) > 1]
33
  except Exception as e:
34
  st.error(f"๋ช…์‚ฌ ์ถ”์ถœ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}")