English 中文(简体)
在PHP/MySQL数据库中作类似描述
原标题:Find Similar Descriptions in Database PHP/MySQL
  • 时间:2010-11-29 08:28:17
  •  标签:
  • php
  • mysql

We are building a help desk application for running our service company, and I am trying to figure out to assist the call center people in assigning a category based the problem description from the customer.

我的主要想法是,将客户所作的描述与先前的说明进行比较,并利用根据所分配的最普通类别在以前的服务呼吁中使用的类别。

关于如何这样做的想法?

我的描述是一个游说领域,因为有些描述很长。 我更希望找到一种办法,来做到这一点,需要最少的系统资源。

感谢任何投入:

迈克

最佳回答

如果你使用大型、 b干的系统,如果你不想用盐类代谢,那么我不会感到工作是正确的。 然而,这或许不会像你重新做的那样困难;如果是,我肯定会接受一个套头系统。 然而,这并不需要如此复杂。

在此,我将如何处理:

第一,建立一个有3个表格的数据库;一个是关于类别、标签和链接的数据库(类别和标签之间的联系)。

之后,创建一种PHP功能,即先形成一个阵列(先发制人功劳只是罚款),如果不存在的话,则推介新的(下级)。 例如:

<?php

// Pass the new description to this 
// function.
function getCategory($description)
{
    // Lowercase it all
    $description = strtolower($description);

    // Kill extra whitespace
    $description = trim($description);
    $description = preg_replace( ~ss+~ ,    , $description);

    // Kill anything that isn t a number or a letter
    // NOTE: This is untested, so just edit this however you d like to make it work. The
    // idea is to just eliminate everything that isn t a letter or number. Just don t take out
    // spaces; we need them!
    $descripton = trim($description, "!@#$%^&*()_+-=[]{};: "\

|<>?,./");

    // Now the description should just contain words with a single space in between them.
    // Let s break them up.
    $dict = explode(" ", $description);

    // And find the unique ones...
    $dict = array_unique($dict, SORT_STRING);

    // If you wanted to, you could trim either common words you specify,
    // or any words under, say, 4 characters. Up to you!

    return $dict;
}

?>

其次,充实你的数据库,说明你想要什么;使几类和某些方面混为一谈,然后将它们联系起来(如果你想要获得活力,将MySQL发动机转至InnoDB,并建立联系)。 使事情更快!

Table `Categories`
|-------------------------|
| Column: Category        |
| Rows:                   |
|   Food                  |
|   Animals               |
|   Plants                |
|                         |
|-------------------------|


Table `Tags`
|-------------------------|
|  Column: Tag            |
|  Rows:                  |
|    eat                  |
|    hamburger            |
|    meat                 |
|    leaf                 |
|    stem                 |
|    seed                 |
|    fur                  |
|    hair                 |
|    claws                |
|                         |
|-------------------------|

Table `Links`
|-------------------------|
| Columns: tag, category  |
| Rows:                   |
|  eat, Food              |
|  hamburger, Food        |
|  meat, Food             |
|  leaf, Food             |
|  leaf, Plant            |
|  stem, Plant            |
|  fur, Animals           |
|  ...                    |
|-------------------------|

通过利用MySQL InnoDB关系,链接表不会再占用任何空间,为此将设立浏览器;这是因为这些连接点是linked<>,以某种方式储存,并且都是通过参考储存的。 这将在数据库规模上缩小

现在,对Kcker而言,对数据库进行一盘 my,其步骤如下:

  1. For each category, sum up the tags belonging both to the category and the description dictionary (which we created in the earlier PHP function).
  2. Sort them from greatest to least
  3. Pull the top 1 or 3 or however many suggested categories you d like!

这将使你们得到最高对等数类别。 你们如何想制造MySQL的麻烦,是你们的。

虽然这似乎像许多机构一样,但确实是 t。 你们最多有3个表格,1个或2个PHP功能和少数MySQL查询。 数据库的大小只能与类别、标签和两者的提及(在联系表中;参考资料没有占用多少空间!)

更新数据库,简单地将数据贴在标签数据库中,并将其与你决定分配给说明的类别联系起来。 这将扩大贵国数据库的范围,并随着时间的推移,使贵国数据库更加符合你的描述(即更准确)。

如果您想得到真正详细的信息,请将duplicate<>>>>/em>各类别和标签联系起来,以建立某种加权标签制度,使你的系统更加准确。

问题回答

暂无回答




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...