English 中文(简体)
根据其背景确定两个层次之间的百分比关系
原标题:Find a percentage relation between two string according to their context

I m 为html网页安装一个网络报废器。 问题是背景关系,因为我需要决定一线内容与非行内容之间的关系,因此我可以说,这些内容是相关的,还是不是背景观点:

页: 1

$str1 = "president obama visited Barcelona yesterday"; //politics context
$str2 = "Barcelona was defeated from Chelsea yesterday"; //sports context

页: 1

$str3 = "Obama s appearance on Late Night With Jimmy Fallon "; //media context
$str4 = "Late Night show with jimmy fallon"; //mdeia context

第一例

<>strong>$1 and $str2 are大体不同,因此,关系可能为10%

第二例

<>strong>$str3 and $str4 are in the same context (media)beit$3 about President obama and the $4 about Ji Fallon but both are related to end road show,So relation may be 90%

I m using the Porter-Stemmer algorithm to remove the common endings from words. What to do next?

问题回答

The keywords are string metrics, fuzzy matching...

查阅:

$exstr1=explode(" ", $str1);
$exstr2=explode(" ", $str2);
foreach( $exstr1 as $exitem)
{
     if (in_array($exitem, $exstr2 ) $match++;
      else $mis++;
}
$percent=$match/($match+$mis)*100;




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

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 = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...