First install dependencies:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ jieba
Then use the following code:
import jieba.analyse
def tfidf_ana(content):
content_s = "".join(content).strip()
title_keys = jieba.analyse.extract_tags(content_s, topK=6, withWeight=False) # topK is the number of keywords expected to be obtained
title_keys = ','.join(title_keys)
return title_keys
# begin to test
data = tfidf_ana("2019年,复杂的外部环境、全球经济放缓的较大可能性,叠加中国经济前期不利因素的累积效应,经济下行"
"压力进一步凸显,但是变中危和机同生共存,紧扣重要战略机遇新内涵,做好“六稳”工作,变压力为加快推动"
"经济高质量发展的动力。一是进一步发展好对外贸易关系,推进新全球化,以经贸关系为主线稳定外部环境。"
"稳妥应对外部经济环境变化,稳步发展“一带一路”贸易畅通,积极参与全球经济和贸易治理体系变革与发展,"
"坚持维护WTO的多边机制,维护中国在外贸中的合理权益和地位。二是稳妥处置地方政府债务风险和衍生金融风险。"
"为地方政府“开前门、堵后门”,辅以金融政策支持,为之构建合理的债务处置出口;合理划分中央和地方各级政府的财权、"
"事权,使地方政府的事权和财权相匹配,并有资源能够化解已有的债务问题,使之成为中国经济发展的助推器,而非风险源。"
"三是加快经济的深化改革和扩大开放。我国经济韧性强健,产业门类齐全,人员技能熟练,经济纵深宽广,抗风险能力强大,"
"加快经济的深化改革和扩大开放,深化国资国企、财税金融、土地、市场准入、社会管理等领域改革,推动体制机制创新,"
"不仅能进一步激发全社会的发展活力,为实现“六稳”目标打下坚实的基础,还能吸引中国经济对国际社会的吸引力,"
"形成互惠互利,提升中国应对全球经济衰退风险的能力,提高中国在推进新型全球化进程中的权益。
print(data)
Read More:
- Extracting Data from XML (Using Python to Access Web Data)
- The range of Chinese Unicode encoding and the calculation of the number of Chinese and English words in text
- Tesseract OCR text recognition using tess4j encapsulation
- How to Solve paddleOCR recognition of curved text Error
- from keras.preprocessing.text import Tokenizer error: AttributeError: module ‘tensorflow.compat.v2‘ has..
- [Solved] cx_Oracle.DatabaseError: Error while trying to retrieve text for error ORA-01804
- AttributeError: lower not found (NLP extracted tfidf features)
- PIP Install Caused by SSLError(SSLError(1, ‘[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123)’))
- Python Use PIP to install pyinstaller Error [Solved]
- [Solved] Conda install Error: An HTTP error occurred when trying to retrieve this URL. HTTP errors are often…
- When sending an email, an error was reported: AttributeError:’list’ object has no attribute’encode’
- Python: How to parses HTML, extracts data, and generates word documents
- The PIP installation package was successful but the import failed
- [Solved] Original error was: No module named ‘numpy.core._multiarray_umath‘
- [zipfile] Python packages files as zip packages & decompresses them
- ValueError: Found array with dim 4. Estimator expected and ValueError: Expected 2D array, got 1D array i
- Typeerror in Python regular expression: expected string or bytes like object
- tensorflow2.3 InvalidArgumentError: jpeg::Uncompress failed [How to Solve]
- Python USES the PO design pattern for automated testing
- Python: Panda scramble data