这个例子展示了如何使用单词想象文本数据云。
文本分析工具箱的功能延伸wordcloud
(MATLAB)功能。它增加了支持创建金宝app直接从字符串数组和创建云词云从bag-of-words模型和LDA的话题。
加载示例数据。该文件factoryReports.csv
包含工厂的报告,包括每个事件的文本描述和分类标签。
文件名=“factoryReports.csv”;台= readtable(文件名,“TextType”,“字符串”);
提取的文本数据描述
列。
textData = tbl.Description;textData (1:10)
ans =10 x1字符串“项目是偶尔陷入扫描仪卷。”"Loud rattling and banging sounds are coming from assembler pistons." "There are cuts to the power when starting the plant." "Fried capacitors in the assembler." "Mixer tripped the fuses." "Burst pipe in the constructing agent is spraying coolant." "A fuse is blown in the mixer." "Things continue to tumble off of the belt." "Falling items from the conveyor belt." "The scanner reel is split, it will soon begin to curve."
创建一个词云的报告。
图wordcloud (textData);标题(“工厂报告”)
比较报告中的词和标签“泄漏”
和“机械故障”
。创建词云为每一个标签的报告。指定字的颜色是蓝色和红色分别为每个词云。
图标签= tbl.Category;次要情节(1、2、1)idx = = =标签“泄漏”;wordcloud (textData (idx),“颜色”,“蓝”);标题(“泄漏”次要情节(1、2、2)idx = = =标签“机械故障”;wordcloud (textData (idx),“颜色”,“红色”);标题(“机械故障”)
比较报告中的词和紧迫性“低”,“中”,“高”。
图= tbl.Urgency紧迫性;次要情节(1、3、1)idx = = =紧迫性“低”;wordcloud (textData (idx));标题(“紧迫性:低”次要情节(1、3、2)idx = = =紧迫性“媒介”;wordcloud (textData (idx));标题(“紧迫性:媒介”次要情节(1,3,3)idx = = =紧迫性“高”;wordcloud (textData (idx));标题(“紧迫性:高”)
比较报告中的词和成本报告数百美元成本的报告发表在成千上万的美元。创建的词云报告为每个这些数量分别与突出颜色蓝色和红色。
成本= tbl.Cost;idx =成本> 100;图wordcloud (textData (idx),“HighlightColor”,“蓝”);标题(“成本> 100美元”)
idx =成本> 1000;图wordcloud (textData (idx),“HighlightColor”,“红色”);标题(“成本> 1000美元”)
wordcloud
|tokenizedDocument
|bagOfWords