-
Notifications
You must be signed in to change notification settings - Fork 10
/
run.py
35 lines (30 loc) · 890 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- coding: utf-8 -*-
# @Time : 2018/12/5 17:22
# @Author : Richer
# @File : run.py
import os,sys
from lib.tf_idf.get_idf import IDF
from bin.tfidf import TFIDF
class MAIN():
def __init__(self, model='tf-idf', file = ''):
self.model = model
self.base_path = os.getcwd()
self.idf_file = self.base_path + '/data/idf_out/idf.txt'
self.file = file
def main(self):
keywords = []
if self.model == 'tf-idf':
if not os.path.isfile(self.idf_file):
idfObj = IDF()
idfObj.idf()
else:
main = TFIDF(self.file)
keywords = main.key_abstract()
else:
# 还有一种方式
keywords = ''
return keywords
if __name__ == '__main__':
run = MAIN('tf-idf', 'test.txt')
keywords = run.main()
print(keywords)