# tf-idf-keyword **Repository Path**: apple12345656/tf-idf-keyword ## Basic Information - **Project Name**: tf-idf-keyword - **Description**: Keyword extraction based on TF-IDF of specific corpus. 基于特定语料库的TF-IDF的中文关键词提取 - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 25 - **Forks**: 5 - **Created**: 2019-10-30 - **Last Updated**: 2025-07-11 ## Categories & Tags **Categories**: nature-language **Tags**: None ## README # 基于TF-IDF的中文关键词提取 ## requirements 默认环境python3,需要结巴分词器的支持 ```bash $ pip install jieba ``` ## IDF(逆文档频率)生成 用法: ```bash $ python gen_idf.py -i -o ``` - `-i ` : 语料库目录,程序会扫描目录下的所有文件 - `-o ` : 保存idf到指定文件 ## TF-IDF关键词提取 用法: ```bash $ python tfidf.py -i -d -t ``` - `-i ` : idf文件路径 - `-d ` : 所需处理文档路径 - `-t ` : 返回topK结果 ### 示例 ```bash $ python tfidf.py -i idf.txt -d test.txt -t 20 ``` 返回结果: ``` 核 处理器 服务器 系统核心 封装 系列 插槽 核心 主频 产品 伊斯坦布尔 英特尔 功耗 多处理器 低仅 折合 浮点运算 性能 构建 吹起 ``` > 注:该repo中提供的idf.txt由清华NLP组的新闻数据集训练获得。