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

发布于 2024-07-27 15:55:30 字数 293 浏览 6 评论 0原文

我有一个带有 BLOB 列的表。 我想做的是让它能够挑选出单词并按顺序列出它们。

例如,如果它包含:

  • 鲍勃史密斯喜欢奶酪但喜欢阅读
  • 查理喜欢巧克力牛奶
  • 查尔喜欢漫画但也喜欢饼干

那么我会得到

  1. 喜欢

结果......这可能吗?如果可能的话如何?

我希望能够仅在 mysql 中完成此操作,但我也可以使用 php。

提前致谢, 肯尼

I've got a table with a BLOB column. 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

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.

Thanks in advance,
kenny

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

人心善变 2024-08-03 15:55:31

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

I've re-worked my code so I no longer need to do this... it seems impossible with standart setups

归途 2024-08-03 15:55:30

不要认为有任何内置的 MySQL 函数可以执行此操作,因此您可能最好使用 PHP 来使用 explode(' ', $myString)str_word_count( $myString, 1) 创建一个包含每个单词的数组。 然后循环遍历数组中的每个单词并对它们进行计数。

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. Then loop through each word in the array and count them.

野侃 2024-08-03 15:55:30

Sphinx Search (http://sphinxsearch.com/) 是一个在 mysql 中搜索全文的应用程序以及其他数据库和文件格式。 简而言之,它提供了与 mysql 表相关的搜索。

它的工具之一执行字数统计,下面是一个 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

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. In short, it offers search with relavence of mysql tables.

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:

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文