Sign in to follow this  
Followers 0
Sypher

Cleaning an array - Uniqueness

8 posts in this topic

#1 ·  Posted (edited)

Yes, me again with the arrays. They are really giving me headache's :)

In short:

I am using three arrays:

  • Search array (what to search for in the Available array)
  • Available array (searchable, with StringInStr.. This one saves to the ResultArray)
  • Result Array (result of the Search Array on the Available Array)
So far so good, the search is going as planned (finally).

The Search Array contains (1) entry per search. The Available one contains multiple similar entries.

For example. I search for "Heroes.S02E01", the Available one contains: "Heroes.S02E01.HDTV.XviD-XOR", "Heroes.S02E01.720p.HDTV.x264-CTU". So the resultarray contains both.

In order to make it easier to sort (720p over HR, HR over HDTV etc) i've added weights to it. This is working fine, and is stored in both the Available array as in the Result Array.

Still with me? Great!

So, the array contains multiple "same" search results, but with other scoring (which is stored in the 4th element ([3]) of the Result & Available array).

What i need to do is:

  • Find Duplicate names ([0])
  • Find the highest scoring of all of them ([3])
  • Remove the lowest ranking one from the list
I've tried a darn lot, used all the possible Dupecleaners i could find but that wasn't helping too much. I am using the Array2D UDF, if that might help.

I really hope you guys can help me out, as this is the final thing i have to do to finalize my program. Thanks a lot!

Edited by Sypher

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

You don't really explain what it is we are supposed to help you with (an example would be great), but there was a udf written recently that may help... do a search for _ArrayElement , I believe they made it handle 2D arrays, also there was an _ArrayMode in that same thread that may be what you are looking for.

Edit:

To make life easier: http://www.autoitscript.com/forum/index.ph...st&p=408426

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Well, as i stated before. I am using 1 search array, 1 content array and 1 resultarray. In the last one, the one with the results, there are multiple results of shows found in the 2nd array.

I already have created a function that gives each entry (based on the title of the file) a certain amount of points.

An example:

Show: Heroes.S02E01.HDTV.XviD-XOR

Link: .....

Score: 6

Show: Heroes.S02E01.720p.HDTV.x264-CTU

Link: .....

Score: 11

There are multiple results of the search for "Heroes.S02E01", and i only want to keep the ones (in the ResultArray) with the highest score.

I did see, and try, the scripts provided in the link you gave, but i can't seem to get it to work.

So what i could do is:

- Count how many times "Heroes.S02E01" occurs in the $ResultArray. This could be done with a for-loop in the $SearchArray (the array which contains the words i'm looking for)

- Find the highest score

- Get rid of the other ones or save the highest ones in a new Array.

I really could use some help with this :)

Share this post


Link to post
Share on other sites

So, i ended up with something like this:

Func CrossMatch()
    Dim $myshow = ""
    Dim $myscore = 0
    For $shID = 0 To UBound($AvailableShowArray) - 1
        $showname_tvNZB = $AvailableShowArray[$shID][0]
        $showlink_tvNZB = $AvailableShowArray[$shID][1]
        $showscore_tvNZB = $AvailableShowArray[$shID][2]
        For $myepID = 0 To UBound($SearchArray) - 1
            If StringInStr($showname_tvNZB, $SearchArray[$myepID], 0) Then
                ConsoleWrite("--> Adding " & $showname_tvNZB & " to the found list!" & @LF)
                If ($myshow == $SearchArray[$myepID]) Then
                    MsgBox(0, "DUPE", "Duplicate: " & $SearchArray[$myepID] & " - SCORE " & $showscore_tvNZB & "(" & $myscore & ")")
                    If ($myscore > $showscore_tvNZB) Then
                        MsgBox(0, "DUPE 2", "Dupe with higher score: " & $SearchArray[$myepID])
                    EndIf
                    $myscore = $showscore_tvNZB
                EndIf
                $myshow = $SearchArray[$myepID]
                _ArrayInsert2D ($FoundShowArray, _ArrayCreate($SearchArray[$myepID], $showname_tvNZB, $showlink_tvNZB, $showscore_tvNZB), 0)
                __ArraySort ($FoundShowArray)
            EndIf
        Next
    Next
EndFuncoÝ÷ ØZºÚ"µÍY
    ÌÍÛ^ÚÝÈOH ÌÍÔÙXÚ^VÉÌÍÛ^YQJH[
you can see my attempt into checking if the previous one was like the current one, and after that the score should be checked.

I hope this helps.

Share this post


Link to post
Share on other sites

What you may have to do is, each time you identify an entry to be added to the result, search for the candidate it should replace; if you have your result array sorted, you can use a binary search, to really speed things up. If you do not find a replacement candidate, insert your new entry, but if you do find a candidate, check the score and only replace it (via assignment) if the score of the new value is higher than the old one. Coding this algorithm is left as an exercise for the student :)


David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Share this post


Link to post
Share on other sites

Jay! I've got it figured out :) The way i've stated before is now working great.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0