# jsns **Repository Path**: jtyoui/jsns ## Basic Information - **Project Name**: jsns - **Description**: 训练文本分析词语,发现新词 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: https://apidoc.gitee.com/tyoui/jsns - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2018-06-12 - **Last Updated**: 2022-04-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # **JSNS** [![tyoui](https://github.com/zhangwei0530/logo/blob/master/logo/photolog.png?raw=true)](http://www.tyoui.cn) [![](https://github.com/zhangwei0530/logo/blob/master/logo/logo.png?raw=true)](http://www.tyoui.cn) ## 这是一个无监督训练文本,发现新词的算法 [![](https://img.shields.io/badge/Java-1.8-green.svg)]() [![](https://img.shields.io/badge/BlogWeb-Tyoui-bule.svg)](http://www.tyoui.cn) [![](https://img.shields.io/badge/Email-tyoui@tyoui.cn-red.svg)]() ## Maven托管 :暂未托管成功 com.jtyoui jsns 18.5.10 ## 训练代码(文本是UTF-8格式) @Test public void analysis() { File file = new File("src/main/resources/西游记.txt"); Jsns jsns = new Jsns(10);//候选词最大为10 String data = jsns.readToString(file); String[] strings = jsns.clean(data); for (String s : strings) jsns.split(s); jsns.handle(); jsns.filter(200f, 0.5f, 30f); jsns.write(); } ## 对象属性 private String key;//候选词 private int total;//候选词出现的次数 private float frequency;//关键字出现的频率 private float solidify;//凝固程度 private float free;//自由程度 private float shift;//偏移度 private List leftWord = new ArrayList<>();//左邻字集合 private List rightWord = new ArrayList<>();//右邻字集合 private Map leftCount = new HashMap<>();//左邻字概率 private Map rightCount = new HashMap<>();//右邻字概率 ![](https://github.com/zhangwei0530/logo/blob/master/photo/snsg1.png?raw=true) ## 爬虫的新闻数据一部分截图(大概100M纯文本) ![](https://github.com/zhangwei0530/logo/blob/master/photo/snsg2.png?raw=true) ## 训练政治新闻后的结果 ![](https://github.com/zhangwei0530/logo/blob/master/photo/snsg.png?raw=true) ## 编程语言 [点击查看Python3版本](https://gitee.com/tyoui/snsg) [点击查看Java8版本](https://gitee.com/tyoui/jsns)