View Single Post
Old 05-01-2011, 07:35 AM   #243
drMerry
Addict
drMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmosdrMerry has become one with the cosmos
 
drMerry's Avatar
 
Posts: 293
Karma: 21022
Join Date: Mar 2011
Location: NL
Device: Sony PRS-650
I did not look into the code, so I do not know about difference in implementation.
But since this is an other function than the current duplicates, it maybe would have to be implemented different.
But since this option is not implemented, I think I'm 'spamming' this topic by telling my idea's.
But if you want to know:
Spoiler:
If the implementation is complete different from the current, it does not mean you have to rewrite old code. Just you have to add a new function. Because it is a duplicate scan, I would add it to this plugin, not to a new one.

For performance think of this:
Code:
Get a list of unique authors - authors[Author, isAuthFlag = true]
Get a list of unique titles - titles[Title, isAuthFlag = false]
^^^^My hash sets^^^^
Merge both lists - BasicList[Text, isAuthFlag, matchFlag = false]
Sort BasicList alphabetically (on text)
Iterate BasicList 
{
   if current isAuthFlag == next isAuthFlag 
   {
      functionRemove(id)
   }
   else if current Text matches next Text
   {
      set matchFlag true
      functionRemove(id+1)
      proceed with next
   }
   else
   {
      functionRemove(id)
   }
   if no next and no match
   {
      functionRemove(id)
   }
}
if BasicList.size > 0
{
   iterate BasicList
   {
      lookup text in titles
      Lookup authors of this book
      If match (using one of the already implemented functions (identical, sim, fuz, sound)
      {
         add book to matchlist
         remove id from BasicList
      }
      else
      {
         remove id from BasicList
      }
   }
}

functionRemove(id)
{
   if id.ismatch == false
   remove id from list
}
EDIT, during typing I changed some code inside my mind, I think in a few minutes the matchFlag has become obsolete.

Last edited by drMerry; 05-01-2011 at 07:40 AM. Reason: updated some 'sample code'
drMerry is offline   Reply With Quote