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

Link to comment
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

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.