Jump to content

Help needed to tag words with score


kailash001

Recommended Posts

Hello guys, i need some help in assigning a score to a word according to its occurrence in a group of sentences.

[code=php:0]
$words="Hello, how are you?";
$sentences="Hello! I am fine. How about you? You look good.";

[/code]

now i'm trying to assign a score to each word in $words e.g Hello=1, how=1, are=0, you=2.

 

Link to comment
https://forums.phpfreaks.com/topic/222042-help-needed-to-tag-words-with-score/
Share on other sites

I'm not sure exactly how to do this, but I would approach it this way.

 

You would have to parse the string, and break up each of the individual words. Then you would need to compare each individual word to a db of words that you have. When a match is found, then pull the score for that word..

 

Might be an easier way, but I'm not sure?

 

Denno

I'm not sure exactly how to do this, but I would approach it this way.

 

You would have to parse the string, and break up each of the individual words. Then you would need to compare each individual word to a db of words that you have. When a match is found, then pull the score for that word..

 

Might be an easier way, but I'm not sure?

 

Denno

ok so i made some modifications

<?php
$words="Hello how are you";
$word_array = explode(" ", $words);

$paragraph="Hello! I am fine. How about you? You look good.";
$sencetences = strtok($paragraph, ".!?");  
?>

now i have all the words in an array and the sentences are separated. i don't want to compare the words from DB but check its occurrence in the paragraph then assign the score to it. the score is in fact the number of times it is repeated in the paragraph.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.