Need help implementing an algorithm in python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ech0

    #1

    Need help implementing an algorithm in python

    I would appreciate any help I can get in finding a solution to the
    following problem:

    =============== =============== =============== =============== ======

    Below is a diagram:


    THE PROBLEM

    Lets say we have 4 terms (purple represents the terms). Some terms in
    these 4 terms combine to to make keywords (if we get the words in these
    sub-terms they should equal to the keywords (e.g. terms ['kaiser
    chiefs', 'i predict a riot', 'album'] combined make keywords ['kaiser',
    'chiefs', 'i', 'predict', 'a', 'riot', 'album']). There will be terms
    leftover sometimes, not all terms are used.

    POSSIBLE ANSWER?

    How it searches for the answer is by combining terms from top to
    bottom, then checking to see if the keywords match the combined terms.

    We start by with 1 combination (combine two terms). In the diagram, it
    shows, t1 (term 1) combining with t2 then t3 then t4 (this is the red
    line). If it can't find a match, it continues. It shows t2 combining
    with t3 then t4 (dark green). If it can't find a match, it continues.
    It shows t3 combining with t4 (light green). If by then it can't find a
    match, we do the following:

    Now the above example was just 1 combination. It gets more complicated
    because we are going to have to keep increasing the number of
    combinations by 1 to find a match. We are going to keep doing this
    until combinations >= len(keywords). So now its two combinations. t1
    will combine with t2 and t3. Check if its a match. If not continue. t1
    will combine with t3 and t4. check if its a match. t2 will combine with
    t3 and t4. t3 and t4 can't combine by themselves because they are only
    two terms so we skip them (we already did 2 term combinations). After
    this if theres no match we do 3 combinations... all the way until
    combinations >= len(keywords).

    =============== =============== =============== =============== ======

    Here is what I have gotten so far:
    Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.


    I know exactly what to do its just I have no way of translating the
    thought into programming code. If anybody can help at all I would
    greatly appreciate it.

    Thanks.

  • gene tani

    #2
    Re: Need help implementing an algorithm in python


    ech0 wrote:[color=blue]
    > I would appreciate any help I can get in finding a solution to the
    > following problem:
    >
    > =============== =============== =============== =============== ======
    >
    > Below is a diagram:
    > http://www.muchographiks.com/algo.jpg
    >
    > THE PROBLEM
    >
    > Lets say we have 4 terms (purple represents the terms). Some terms in
    > these 4 terms combine to to make keywords (if we get the words in these
    > sub-terms they should equal to the keywords (e.g. terms ['kaiser
    > chiefs', 'i predict a riot', 'album'] combined make keywords ['kaiser',
    > 'chiefs', 'i', 'predict', 'a', 'riot', 'album']). There will be terms
    > leftover sometimes, not all terms are used.
    >
    > POSSIBLE ANSWER?
    >
    > How it searches for the answer is by combining terms from top to
    > bottom, then checking to see if the keywords match the combined terms.
    >
    > We start by with 1 combination (combine two terms). In the diagram, it
    > shows, t1 (term 1) combining with t2 then t3 then t4 (this is the red
    > line). If it can't find a match, it continues. It shows t2 combining
    > with t3 then t4 (dark green). If it can't find a match, it continues.
    > It shows t3 combining with t4 (light green). If by then it can't find a
    > match, we do the following:
    >
    > Now the above example was just 1 combination. It gets more complicated
    > because we are going to have to keep increasing the number of
    > combinations by 1 to find a match. We are going to keep doing this
    > until combinations >= len(keywords). So now its two combinations. t1
    > will combine with t2 and t3. Check if its a match. If not continue. t1
    > will combine with t3 and t4. check if its a match. t2 will combine with
    > t3 and t4. t3 and t4 can't combine by themselves because they are only
    > two terms so we skip them (we already did 2 term combinations). After
    > this if theres no match we do 3 combinations... all the way until
    > combinations >= len(keywords).
    >
    > =============== =============== =============== =============== ======
    >
    > Here is what I have gotten so far:
    > http://pastebin.com/450352
    >
    > I know exactly what to do its just I have no way of translating the
    > thought into programming code. If anybody can help at all I would
    > greatly appreciate it.
    >
    > Thanks.[/color]

    Be honest, is this a take-home final ?

    Comment

    • ech0

      #3
      Re: Need help implementing an algorithm in python

      I'm still in highschool. This is no homework. This is a personal
      project for me. I would normally do it myself but this one is just too
      complex, thats why I'm asking for help.

      Comment

      • ech0

        #4
        Re: Need help implementing an algorithm in python

        Just to point out... I came up with the algorithm. Which is why I can
        explain it so well. But implementing it into code is one well of a task.

        Comment

        • ech0

          #5
          Re: Need help implementing an algorithm in python

          wow. nevermind. i figured it out.

          Comment

          • Colin J. Williams

            #6
            Re: Need help implementing an algorithm in python

            ech0 wrote:[color=blue]
            > wow. nevermind. i figured it out.
            >[/color]
            I hope that you will share it with those of us who haven't figured it
            out yet.

            Colin W.

            Comment

            Working...