Permalink
Browse files

find keywords for certain terms

  • Loading branch information...
1 parent ea17e18 commit 5d8b8143a3aedf07eac7500f1cb079fdcb662125 @codepo8 codepo8 committed Jul 4, 2010
Showing with 47 additions and 0 deletions.
  1. +47 −0 keywordfinder/keywordfinder.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
+ <meta>
+ <sampleQuery>select * from {table} where keyword="oil spill" and region="us" and lang="en"</sampleQuery>
+ <author>Christian Heilmann</author>
+ <documentationURL>http://keywordfinder.org</documentationURL>
+ <description>Gives you the top 20 keywords for a certain keyword using Yahoo BOSS</description>
+ </meta>
+ <bindings>
+ <select itemPath="" produces="JSON">
+ <inputs>
+ <key id='term' type='xs:string' paramType='variable' required="true" />
+ <key id='region' type='xs:string' paramType='variable' required="true" />
+ <key id='lang' type='xs:string' paramType='variable' required="true" />
+ </inputs>
+ <execute><![CDATA[
+ var res = y.query("select resultset_web.keyterms from json where url='http://boss.yahooapis.com/ysearch/web/v1/"+encodeURIComponent(term)+"?appid=TX6b4XHV34EnPXW0sYEr51hP1pn5O8KAGs.LQSXer1Z7RmmVrZouz5SvyXkWsVk-&view=keyterms&count=50&region="+region+"&lang="+lang+"' | sanitize()").results;
+ var terms = res.ysearchresponse.resultset_web.keyterms.terms;
+ var t = [];
+ for each(i in terms){t.push(i);};
+ t = t.sort();
+ var count = 0;
+ var others = [];
+ for(i=0,j=t.length;i<j;i++){
+ if(t[i+1] && t[i+1]!=t[i]){
+ others.push([t[i],count]);
+ count = 0;
+ } else {
+ count++
+ }
+ }
+ others.sort(function(a, b) {return a[1] - b[1]});
+ others.reverse();
+ var out = <terms/>;
+ var str = [];
+ var all = others.length > 20 ? 20 : others.length;
+ for(var i=0;i<all;i++){
+ var t = others[i][0];
+ str.push(t);
+ };
+ str = str.join(',')
+ response.object = <keywords><search>{term}</search><language>{lang}</language><region>{region}</region><terms>{str}</terms></keywords>;
+ ]]></execute>
+ </select>
+ </bindings>
+
+</table>

0 comments on commit 5d8b814

Please sign in to comment.