Source: site.view [edit]
Function name: createTrainingFile
Arguments:
Description:
Page type: webl
Render function:   fullPageRender
Module: geneticFinance

Page source:

var db = Wub_GetDB("newsIndex");
var coll = Wub_GetCollection(db, "articles");

var num = 1;
var done = false;

Wub_DeleteData("gftraining");
var count = 0;

while !done do
   var dbobj = Wub_NewDBObject([. num=ToString(num) .]);
   var res = Wub_QueryDB(coll, dbobj, 1);
   if res == [] then
      done = true
   else
      if (res[0].score != "?") and (res[0].score != "-1") then
         var txt = res[0].text;
         if txt == "" then
            txt = Text(GetURL(res[0].link)) ? ""
         end;
         var content = res[0].title + res[0].snippet + txt;
         var line = `"` + res[0].score + `","` + Wub_ReplaceAll(content, `"`, `""`) + `"` + "\n";
         count = count + 1;
         Wub_AppendData("gftraining", line)
      end
   end;
   num = num + 1
end;

ToString(count) + " entries written to 'gftraining'";