Jump to content

Aggregating document list by score


API_PHP

Recommended Posts

I have 3 arrays, each containing a dynamically generated list of documents. (The list changes depending on what the user searches for)
    $list1['documentname']
    $list2['documentname']
    $list3['documentname']

Each array is multidimensional and contains other information such as description. 

$list1 = array('documentname','description') 

For example if I wanted to output the sixth document`s name and description I would write: 

echo $list1[5]['documentname'].$newline.$list1[5]['description'];

A particular document may be contained in all three lists or none of the lists. What I am trying to do is rank the documents by the documents total score using the following formula:

    $document_Score = (1/(60+rank_list1)) + (1/(60+rank_list2)) + (1/(60+rank_list3))

I am trying to think of a way of doing this but I am getting nowhere.  

 
If document a is ranked 1 in list1, 2 in list2, and 4 in list3, how do I apply the following formula and add the scores together. 
    $document_Score = (1/(60+1)) + (1/(60+2)) + (1/(60+4)) //score for document a

I know that I need to apply code based on whether $list1['documentname'] is equal to $list2['documentname'] etc but I have no idea how to implement this. Any tips or ideas would be appreciated.

 

Any ideas?

 

Thanks. 

Edited by API_PHP
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.