如何找出文本块中最常用的 2 个单词组合?
如何从一段文本中找出我最常用的两个单词?换句话说,是否有一个在线或离线(或代码)工具,我可以在其中复制和粘贴文本,并输出我最常用的两个词频,例如:
从最常用到最少:
“猫”2.9% “她说” 1.8% “去了” 1.2%
谢谢
How can I find out what the most common two words that I used right after each other are from a block of text? In other words is there a tool online or offline (or code) where I can copy and paste text and it outputs my most used two word frequency like:
From most used to least:
"the cat" 2.9%
"she said" 1.8%
"went to" 1.2%
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将文本分成两个单词对(使用 substr 和 strpos 来帮助您)
Chunk up the text into two word pairs (use substr and strpos to help you)
这很有趣,但我做了一些尝试,这应该让你开始,而不应该是你的答案。
这基本上是将单词分组为 2,将它们索引到数组中并递增找到的时间,最后转换为百分比:)
您可以在这里看到它:
This was fun, but i had a little go at it, this should get you started and should not be your answer.
This is basically grouping the words into 2's, indexing them into an array and incrementing the times there found, and finally converting into a percentage :)
You can see it live here: http://codepad.org/rcwpddW8