简体   繁体   English

如何通过mysql获取表中最流行的单词?

[英]How can I get the most popular words in a table via mysql?

I've got a table with a BLOB column. 我有一个带有BLOB列的表。 What I want to do is get it to be able to pick out words and list them in order. 我想要做的是让它能够挑选出单词并按顺序列出它们。

For example if it contained: 例如,如果它包含:

  • Bob Smith likes cheese but loves reading 鲍勃史密斯喜欢奶酪,但喜欢阅读
  • Charlie likes chocolate milk 查理喜欢巧克力牛奶
  • Charl loves manga but also likes cookies Charl喜欢漫画,但也喜欢饼干

Then I would get 然后我会得到

  1. likes 喜欢
  2. loves

as a result... is this possible and if so how? 结果......这是可能的,如果是这样的话怎么样?

I'd like to be able to do it in just mysql alone, but I can use php as well. 我希望能够仅在mysql中完成它,但我也可以使用php。

Thanks in advance, kenny 提前谢谢,肯尼

Don't think there is any built in MySQL function to do this so you are probably best using PHP to do the work for you using either explode(' ', $myString) or str_word_count($myString, 1) to create an array containing each word. 不要认为有任何内置的MySQL函数可以做到这一点所以你可能最好使用PHP为你做工作使用explode(' ', $myString)str_word_count($myString, 1)来创建一个包含每个字。 Then loop through each word in the array and count them. 然后循环遍历数组中的每个单词并计算它们。

Sphinx Search ( http://sphinxsearch.com/ ) is a application that does a lot around searching full text in mysql as well as other db's and file formats. Sphinx Search( http://sphinxsearch.com/ )是一个应用程序,可以在mysql以及其他数据库和文件格式中搜索全文。 In short, it offers search with relavence of mysql tables. 简而言之,它提供了相对于mysql表的搜索。

One of it's tools performs word counts, the following is a bash script to get it to output the most popular words in a database: 其中一个工具执行字数统计,以下是一个bash脚本,用于输出数据库中最常用的字词:

GET_TOP_X_STOP_WORDS=27
WORD_FREQ_FILE=~/wordfreq.txt
/usr/local/bin/indexer test1 --buildstops $WORD_FREQ_FILE $GET_TOP_X_STOP_WORDS --buildfreqs

我已经重新编写了代码,所以我不再需要这样做了......使用标准设置似乎是不可能的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM