前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【短文本聚类】TextCluster:短文本聚类预处理模块 Short text cluster

【短文本聚类】TextCluster:短文本聚类预处理模块 Short text cluster

作者头像
zenRRan
发布2019-12-09 17:21:11
1.7K0
发布2019-12-09 17:21:11
举报

阅读大概需要5分钟 跟随小博主,每天进步一丢丢

整理:AINLP

推荐Github上一个NLP相关的项目:RandyPen/TextCluster

项目地址,阅读原文可以直达,欢迎参与和Star: https://github.com/RandyPen/TextCluster 这个项目的作者是AINLP交流群里的昭鸣同学,该项目开源了一个短文本聚类工具,内存友好,速度不错,还不用尝试隐变量个数,欢迎使用。

以下来自该项目介绍页,点击阅读原文可以直达相关资源链接。

短文本聚类

项目介绍

短文本聚类是常用的文本预处理步骤,可以用于洞察文本常见模式、分析设计语义解析规范等。本项目实现了内存友好的短文本聚类方法。

依赖库

pip install tqdm jieba

使用方法

代码语言:javascript
复制
python cluster.py --infile ./data/infile \
--output ./data/output

具体参数设置可以参考cluster.py文件内_get_parser()函数参数说明,包含设置分词词典、停用词、匹配采样数、匹配度阈值等。

文件路径

代码语言:javascript
复制
TextCluster
|      README.md
|      LICENSE
|      cluster.py                    主要执行程序
|
|------utils                         公共功能模块
|    |    __init__.py
|    |    segmentor.py               分词器封装
|    |    similar.py                 相似度计算函数
|    |    utils.py                   文件处理模块
|
|------data
|    |    infile                     默认输入文本路径,用于测试中文模式
|    |    infile_en                  默认输入文本路径,用于测试英文模式
|    |    seg_dict                   默认分词词典
|    |    stop_words                 默认停用词路径

注:本方法仅面向短文本,长文本聚类可根据需求选用SimHash, LDA等其他算法。

Text Cluster

Introduction

Text cluster is a normal preprocess method to analysis text feature. This project implements a memory friendly method for short text cluster. For long text, it will be preferable to choose SimHash or LDA or others according to demand.

Requirements

pip install tqdm spacy

Usage

代码语言:javascript
复制
python cluster.py --infile ./data/infile_en \
--output ./data/output \
--lang en

File Structure

代码语言:javascript
复制
TextCluster
|      README.md
|      LICENSE
|      cluster.py                    main excutable function
|
|------utils                         utilities
|    |    __init__.py
|    |    segmentor.py               tokenizer wrapper
|    |    similar.py                 similarity calculator
|    |    utils.py                   file process module
|
|------data
|    |    infile                     default input file path, to test Chinese mode
|    |    infile_en                  default input file path, to test English mode
|    |    seg_dict                   default tokenizer dict path
|    |    stop_words                 default stop words path

Other Language

For other specific language, modify tokenizer wrapper in ./utils/segmentor.py.

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2019-12-04,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 深度学习自然语言处理 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 短文本聚类
    • 项目介绍
      • 依赖库
        • 使用方法
          • 文件路径
          • Text Cluster
            • Introduction
              • Requirements
                • Usage
                  • File Structure
                  • Other Language
                  相关产品与服务
                  NLP 服务
                  NLP 服务(Natural Language Process,NLP)深度整合了腾讯内部的 NLP 技术,提供多项智能文本处理和文本生成能力,包括词法分析、相似词召回、词相似度、句子相似度、文本润色、句子纠错、文本补全、句子生成等。满足各行业的文本智能需求。
                  领券
                  问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档