def 심정(self): tr = TextRank(window=5, coef=1) stopword = set([('있', 'VV'), ('하', 'VV'), ('되', 'VV'), ('없', 'VV')]) tr.load( RawTaggerReader('x.txt'), lambda w: w not in stopword and (w[1] in ('NNG', 'NNP', 'VV', 'VA'))) tr.build() kw = tr.extract(0.4) if kw is None: return "모름" else: return kw
def 처지(self): tr = TextRank() from konlpy.tag import Komoran tagger = Komoran() stopword = set([('있', 'VV'), ('하', 'VV'), ('되', 'VV')]) tr.loadSents( RawSentenceReader('x.txt'), lambda sent: filter( lambda x: x not in stopword and x[1] in ('NNG', 'NNP', 'VV', 'VA'), tagger.pos(sent))) tr.build() ranks = tr.rank() if tr.summarize(0.4) is None: return "모름" else: return tr.summarize(0.4)
from textrank import TextRank, RawSentenceReader from konlpy.tag import Kkma import sys filename = sys.argv[1] rate = float(sys.argv[2]) tr = TextRank() #print('Load...') from konlpy.tag import Komoran tagger = Komoran() stopword = set([('있', 'VV'), ('하', 'VV'), ('되', 'VV') ]) tr.loadSents(RawSentenceReader(filename), lambda sent: filter(lambda x:x not in stopword and x[1] in ('NNG', 'NNP', 'VV', 'VA'), tagger.pos(sent))) #print('Build...') tr.build() ranks = tr.rank() #for k in sorted(ranks, key=ranks.get, reverse=True)[:100]: #print("\t".join([str(k), str(ranks[k]), str(tr.dictCount[k])])) sentence = '%s.' % (tr.summarize(rate).split('. ')[0]) kkma = Kkma() print(sentence) print(list(x[0] for x in (list(filter(lambda x: x[1][0] == 'N', kkma.pos(sentence))))))