SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Enthusiast ivanfx's Avatar
    Join Date
    May 2007
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    AdSense style app

    Hello,
    it's been bugging me for some time now how to make an AdSense (or ContextLink or any similar) style app.

    What it does is "read" your entire page (in which it's placed), make a list of all the words in it and look if any of these are listed in their DB. If it is, it places an ad based on it.

    Now, I'm not trying to run against Google But I would like to know is if anybody has an idea how to match (let's say) a 1000 words to a table with a (let's say) 1000 words? Running a 1000 queries and passing them out sounds a lot..

  2. #2
    PHP/Rails Developer Czaries's Avatar
    Join Date
    May 2004
    Location
    Central USA
    Posts
    806
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ivanfx View Post
    Now, I'm not trying to run against Google
    Why not? A bunch of similar ad networks have popped up after Google released AdSense, and most are still online and running. The "big dog" right now isn't always on top, you know .

  3. #3
    SitePoint Evangelist
    Join Date
    Aug 2004
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Tsearch2

    http://www.sai.msu.su/~megera/postgr...-V2-intro.html

    results aren't always the best .. but it allow you to specify weights of words... and its your responsiblity to make an algorithm to parse the search string and create weights.

  4. #4
    SitePoint Zealot
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What about, say, selecting bid data from a table where keywords bid on included 'abc' or 'def' or 'ghi' - i.e. the list of keywords mined from the current page - then ordering them by dollar value descending and limiting to a given number? Long queries, sure, but a single query.

  5. #5
    SitePoint Member
    Join Date
    Mar 2007
    Location
    Adelaide
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could store the contents of the web page in a fulltext search enabled table and then have a list of ads and their keywords.

    You can then go through all of your ads trying to match the queries against the web page table and link the ads up to each page. You then have a list of ads linked by relevancy to each page and you can order by highest bid or whatever.

    This of course requires reading the page before hand to store it in the database, and linking the ads before hand. The benefit of this though is, if it is for an ad system all the links will already be established each time an additional user views the page.

    So first you have to store the web page content (just the keywords) in a table, you would do this by using an XML type parser and just storing the content.

    Code SQL:
    $page_id = INSERT INTO pages(url, content) VALUES(url, $text content FROM webpage)

    Find ads to link up to the page (you can probably chain the queries here in to one if you mess around)

    Code SQL:
    INSERT INTO ad_links(ad_id, page_id, weight) SELECT a.id,$page_id,weight FROM ads a WHERE (SELECT MATCH(content) AGAINST(a.keywords) AS weight HAVING weight)

    To find an ad to display

    Code SQL:
    SELECT a.ad_content FROM pages p LEFT JOIN ad_links al ON al.page_id = p.id LEFT JOIN ads a ON a.id = al.ad_id ORDER BY a.bid,al.weight;

    This probably needs some work just thinking it up off the top of my head.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •