Source: global.ltTLID [edit]
[[. "cmd" = "global.luckySearchUsingMslive", "module" = "global", "description" = "A command to lucky search for a term using MSLive -> Example input: term='Adam Cheyer' ", "exec" = "var P; var tmp1; var context; context = NLUtil_InitContext(); //|| go to http://www.live.com context = NLUtil_GetUrl(context, "http://www.live.com", nil, nil); P = NLUtil_GetContext(context, `P`); //|| find all forms P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`form`, Elem(P, `form`) ); //|| field q is the term context = NLUtil_SetField(context, "q", term); //|| submit the form context = NLUtil_submitForm(context); P = NLUtil_GetContext(context, `P`); //|| find all links that come after options P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`a`, Elem(P, `a`) after Pat(P, `(?i)` + `option`)); //|| select the second link context = NLUtil_SetContext(context,NLUtil_LastType(context), Select(NLUtil_LastSet(context),1,2)); //|| click it context = NLUtil_clickLink(context); P = NLUtil_GetContext(context, `P`); context = NLUtil_SetContext(context, `P`, P); //|| return the page if Size(OPTIONALARGS) == 0 then NLUtil_LastValue(context); else context; end; ", "arglist" = "term" .], [. "cmd" = "global.findPerDiem", "module" = "global", "description" = "A command to lookup the Per Diem rate for a year, a city, and a state - year (string): A year (e.g. 2007) - city (string): A city (e.g. Oakland) - state (string): A state (e.g. California) - returns (string): Per diem in dollars as an integer value ", "exec" = "var P; var context; context = NLUtil_InitContext(); //|| go to http://www.gsa.gov/Portal/gsa/ep/contentView.do?programId=9704&channelId=-15943&ooid=16365&contentId=17943&pageTypeId=8203&contentType=GSA_BASIC&programPage=%2Fep%2Fprogram%2FgsaBasic.jsp&P=MTT context = NLUtil_GetUrl(context, "http://www.gsa.gov/Portal/gsa/ep/contentView.do?programId=9704&channelId=-15943&ooid=16365&contentId=17943&pageTypeId=8203&contentType=GSA_BASIC&programPage=%2Fep%2Fprogram%2FgsaBasic.jsp&P=MTT", nil, nil); P = NLUtil_GetContext(context, `P`); //|| how many forms are there P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`form`, Elem(P, `form`) ); //|| how many forms are there that contain "Rates for Fiscal Year" P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`form`, Elem(P, `form`) contain Pat(P, `(?i)` + `Rates for Fiscal Year`)); //|| field queryYear is the year context = NLUtil_SetField(context, "queryYear", year); //|| field queryState is the state context = NLUtil_SetField(context, "queryState", state); //|| submit the form context = NLUtil_submitForm(context); P = NLUtil_GetContext(context, `P`); //|| find all rows that contain the city P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`tr`, Elem(P, `tr`) contain Pat(P, `(?i)` + city)); //|| find all cells that are inside the row P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`td`, Elem(P, `td`) inside NLUtil_GetContext(context, `tr`)[0]); //|| select the third one context = NLUtil_SetContext(context,NLUtil_LastType(context), Select(NLUtil_LastSet(context),2,3)); //|| return it if Size(OPTIONALARGS) == 0 then NLUtil_LastValue(context); else context; end; ", "arglist" = "year,city,state" .], [. "cmd" = "global.findPhotos", "module" = "global", "description" = "A command to find photos for a term -> searches for images on Flickr -> Example inputs: term='flower' ", "exec" = "var P; var loopResult; var context; context = NLUtil_InitContext(); //|| go to http://www.flickr.com context = NLUtil_GetUrl(context, "http://www.flickr.com", nil, nil); P = NLUtil_GetContext(context, `P`); //|| find all forms P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`form`, Elem(P, `form`) ); //|| field q is the term context = NLUtil_SetField(context, "q", term); //|| submit the form context = NLUtil_submitForm(context); P = NLUtil_GetContext(context, `P`); //|| find all rows that contain the term P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`tr`, Elem(P, `tr`) contain Pat(P, `(?i)` + term)); //|| for every row loopResult = []; every tr in NLUtil_GetContext(context, `tr`) do tr; //|| find all images that are inside the row P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`img`, Elem(P, `img`) inside tr); //|| select the first one context = NLUtil_SetContext(context,NLUtil_LastType(context), Select(NLUtil_LastSet(context),0,1)); //|| end loop loopResult = loopResult + [NLUtil_LastValue(context)]; end; NLUtil_SetContext(context, NLUtil_LastType(context), loopResult); if Size(OPTIONALARGS) == 0 then NLUtil_LastSet(context); else context; end; ", "arglist" = "term" .], [. "cmd" = "global.findBooksBy", "module" = "global", "description" = "A command to find books by an author -> Example input: author='Michael Dahl' ", "exec" = "var P; var tmp1; var context; context = NLUtil_InitContext(); //|| go to http://www.amazon.com context = NLUtil_GetUrl(context, "http://www.amazon.com", nil, nil); P = NLUtil_GetContext(context, `P`); //|| find all links that contain Books P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`a`, Elem(P, `a`) contain Pat(P, `(?i)` + `Books`)); //|| select first link context = NLUtil_SetContext(context,NLUtil_LastType(context), Select(NLUtil_LastSet(context),0,1)); //|| click it context = NLUtil_clickLink(context); P = NLUtil_GetContext(context, `P`); context = NLUtil_SetContext(context, `P`, P); //|| find all forms P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`form`, Elem(P, `form`) ); //|| select first form context = NLUtil_SetContext(context,NLUtil_LastType(context), Select(NLUtil_LastSet(context),0,1)); //|| fill in field-keywords with the author context = NLUtil_SetField(context, "field-keywords", author); //|| submit form context = NLUtil_submitForm(context); P = NLUtil_GetContext(context, `P`); //|| return the page if Size(OPTIONALARGS) == 0 then NLUtil_LastValue(context); else context; end; ", "arglist" = "author" .], [. "cmd" = "global.findCheapestBook", "module" = "global", "description" = "A command to find cheapest book for a topic -> finds ref:cheapest matching amazon book, returns detail page to it. -> Example input: topic='Harry Potter' ", "exec" = "var P; var tmp1; var context; context = NLUtil_InitContext(); //|| go to http://www.amazon.com context = NLUtil_GetUrl(context, "http://www.amazon.com", nil, nil); P = NLUtil_GetContext(context, `P`); //|| find all forms P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`form`, Elem(P, `form`) ); //|| select the first one context = NLUtil_SetContext(context,NLUtil_LastType(context), Select(NLUtil_LastSet(context),0,1)); //|| field url is Books context = NLUtil_SetField(context, "url", `Books`); //|| field keywords is the topic context = NLUtil_SetField(context, "keywords", topic); //|| submit the form context = NLUtil_submitForm(context); P = NLUtil_GetContext(context, `P`); //|| find all forms that contain "sort by" P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`form`, Elem(P, `form`) contain Pat(P, `(?i)` + `sort by`)); //|| field sort is "Price: Low to High" context = NLUtil_SetField(context, "sort", `Price: Low to High`); //|| submit context = NLUtil_submitForm(context); P = NLUtil_GetContext(context, `P`); //|| find all links that contain "Buy" P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`a`, Elem(P, `a`) contain Pat(P, `(?i)` + `Buy`)); //|| select the first one context = NLUtil_SetContext(context,NLUtil_LastType(context), Select(NLUtil_LastSet(context),0,1)); //|| click it context = NLUtil_clickLink(context); P = NLUtil_GetContext(context, `P`); context = NLUtil_SetContext(context, `P`, P); //|| return the page if Size(OPTIONALARGS) == 0 then NLUtil_LastValue(context); else context; end; ", "arglist" = "topic" .], [. "cmd" = "global.findContactPage", "module" = "global", "description" = "A command to find contact page of an organization -> Example input: organization='stanford university' ", "exec" = "var P; var tmp1; var context; context = NLUtil_InitContext(); //|| go to http://www.google.com context = NLUtil_GetUrl(context, "http://www.google.com", nil, nil); P = NLUtil_GetContext(context, `P`); //|| find all forms P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`form`, Elem(P, `form`) ); //|| field q is the organization context = NLUtil_SetField(context, "q", organization); //|| submit form context = NLUtil_submitForm(context); P = NLUtil_GetContext(context, `P`); //|| find all links that contain the organization P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`a`, Elem(P, `a`) contain Pat(P, `(?i)` + organization)); //|| select first link context = NLUtil_SetContext(context,NLUtil_LastType(context), Select(NLUtil_LastSet(context),0,1)); //|| click it context = NLUtil_clickLink(context); P = NLUtil_GetContext(context, `P`); context = NLUtil_SetContext(context, `P`, P); //|| find all links that contain "Contact" P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`a`, Elem(P, `a`) contain Pat(P, `(?i)` + `Contact`)); //|| click it context = NLUtil_clickLink(context); P = NLUtil_GetContext(context, `P`); context = NLUtil_SetContext(context, `P`, P); if Size(OPTIONALARGS) == 0 then NLUtil_LastSet(context); else context; end; ", "arglist" = "organization" .], [. "cmd" = "global.findMovieTheaters", "module" = "global", "description" = "A command to find movie theaters for a zipcode -> look up theaters for zipcode from Yahoo. Returns list of words for each theater name.", "exec" = "var P; var loopResult; var theaters; var context; context = NLUtil_InitContext(); //|| go to http://movies.yahoo.com context = NLUtil_GetUrl(context, "http://movies.yahoo.com", nil, nil); P = NLUtil_GetContext(context, `P`); //|| find all forms that contain "Browse by Location" P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`form`, Elem(P, `form`) contain Pat(P, `(?i)` + `Browse by Location`)); //|| field z is the zipcode context = NLUtil_SetField(context, "z", zipcode); //|| submit the form context = NLUtil_submitForm(context); P = NLUtil_GetContext(context, `P`); //|| find all cells that directly contain "Add to My Favorite Theaters" P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`td`, Elem(P, `td`) directlycontain Pat(P, `(?i)` + `Add to My Favorite Theaters`)); //|| for every cell loopResult = []; every td in NLUtil_GetContext(context, `td`) do td; //|| find all words that are inside the cell P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`word`, Pat(P, `(\S)+\s`) inside td); //|| select all except for the last seven context = NLUtil_SetContext(context,NLUtil_LastType(context), Select(NLUtil_LastSet(context),0,Size(NLUtil_LastSet(context)) - 7)); loopResult = loopResult + [NLUtil_LastSet(context)]; end; NLUtil_SetContext(context, NLUtil_LastType(context), loopResult); //|| call them theaters theaters = NLUtil_LastSet(context); if Size(OPTIONALARGS) == 0 then NLUtil_LastSet(context); else context; end; ", "arglist" = "zipcode" .], [. "cmd" = "global.findPhone", "module" = "global", "description" = "A command to find phone for someone", "exec" = "var P; var tmp1; var context; context = NLUtil_InitContext(); //|| go to http://cee.ai.sri.com context = NLUtil_GetUrl(context, "http://cee.ai.sri.com", nil, nil); P = NLUtil_GetContext(context, `P`); //|| find all forms P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`form`, Elem(P, `form`) ); //|| field cee_login is "test" context = NLUtil_SetField(context, "cee_login", `test`); //|| submit context = NLUtil_submitForm(context); P = NLUtil_GetContext(context, `P`); //|| click on the Directory link P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`a`, Elem(P, `a`) contain Pat(P, `(?i)Directory`)); context = NLUtil_clickLink(context); P = NLUtil_GetContext(context, `P`); context = NLUtil_SetContext(context, `P`, P); //|| how many forms are there P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`form`, Elem(P, `form`) ); //|| field queryString is the person context = NLUtil_SetField(context, "queryString", person); //|| submit the form context = NLUtil_submitForm(context); P = NLUtil_GetContext(context, `P`); //|| find all tables P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`table`, Elem(P, `table`) ); //|| find all tables that contain the person P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`table`, Elem(P, `table`) contain Pat(P, `(?i)` + person)); //|| get the Phone for the person tmp1 = NLUtil_GetTableCell(context, `Phone`, person); if tmp1 != nil then context = NLUtil_SetContext(context,`td`,[tmp1]); end; if Size(OPTIONALARGS) == 0 then NLUtil_LastValue(context); else context; end; ", "arglist" = "person" .], [. "cmd" = "global.findPublications", "module" = "global", "description" = "A command to find publications for a project -> Example input: project='centibots' ", "exec" = "var P; var tmp1; var context; context = NLUtil_InitContext(); //|| go to http://www.google.com context = NLUtil_GetUrl(context, "http://www.google.com", nil, nil); P = NLUtil_GetContext(context, `P`); //|| fill in q with the project context = NLUtil_SetField(context, "q", project); //|| submit the form context = NLUtil_submitForm(context); P = NLUtil_GetContext(context, `P`); //|| submit the form context = NLUtil_submitForm(context); P = NLUtil_GetContext(context, `P`); //|| find all links that contain the project P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`a`, Elem(P, `a`) contain Pat(P, `(?i)` + project)); //|| select the first link context = NLUtil_SetContext(context,NLUtil_LastType(context), Select(NLUtil_LastSet(context),0,1)); //|| click it context = NLUtil_clickLink(context); P = NLUtil_GetContext(context, `P`); context = NLUtil_SetContext(context, `P`, P); //|| click on the publications link P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`a`, Elem(P, `a`) contain Pat(P, `(?i)publications`)); context = NLUtil_clickLink(context); P = NLUtil_GetContext(context, `P`); context = NLUtil_SetContext(context, `P`, P); //|| return the page if Size(OPTIONALARGS) == 0 then NLUtil_LastValue(context); else context; end; ", "arglist" = "project" .], [. "cmd" = "global.search", "module" = "global", "description" = "A command to search for a term -> Example input: term='SRI International' ", "exec" = "var context; context = NLUtil_InitContext(); //|| search Google for the term context = WubCall(`global.searchGoogle`,[term, context]); //|| return them if Size(OPTIONALARGS) == 0 then NLUtil_LastSet(context); else context; end; ", "arglist" = "term" .], [. "cmd" = "global.searchGoogle", "module" = "global", "description" = "A command to search google for a term", "exec" = "var P; var context; context = NLUtil_InitContext(); //|| go to http://www.google.com context = NLUtil_GetUrl(context, "http://www.google.com", nil, nil); P = NLUtil_GetContext(context, `P`); //|| find all forms P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`form`, Elem(P, `form`) ); //|| field q is the term context = NLUtil_SetField(context, "q", term); //|| submit the form context = NLUtil_submitForm(context); P = NLUtil_GetContext(context, `P`); //|| find all links that contain the term P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`a`, Elem(P, `a`) contain Pat(P, `(?i)` + term)); if Size(OPTIONALARGS) == 0 then NLUtil_LastSet(context); else context; end; ", "arglist" = "term" .], [. "cmd" = "global.luckySearch", "module" = "global", "description" = "A command to lucky search for a term -> search Google for a term, click the first result, return the page", "exec" = "var P; var tmp1; var context; context = NLUtil_InitContext(); //|| go to http://www.google.com context = NLUtil_GetUrl(context, "http://www.google.com", nil, nil); P = NLUtil_GetContext(context, `P`); //|| find all forms P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`form`, Elem(P, `form`) ); //|| field q is the term context = NLUtil_SetField(context, "q", term); //|| submit the form context = NLUtil_submitForm(context); P = NLUtil_GetContext(context, `P`); //|| find all links that contain the term P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`a`, Elem(P, `a`) contain Pat(P, `(?i)` + term)); //|| select the first one context = NLUtil_SetContext(context,NLUtil_LastType(context), Select(NLUtil_LastSet(context),0,1)); //|| click it context = NLUtil_clickLink(context); P = NLUtil_GetContext(context, `P`); context = NLUtil_SetContext(context, `P`, P); if Size(OPTIONALARGS) == 0 then NLUtil_LastSet(context); else context; end; ", "arglist" = "term" .]]