Hi Julien,
Might it be slightly neater to have sendRes return 5
fields instead of 4?
E.g. "sendRes(query, res, freqs, urls, redirectTargets)", where the new
"redirectTargets" field would be an array that
contained a NULL/empty entry when there was no redirect, or the redirect target when it
was a redirect? That way 'res' could
contain just the article's name, and the redirect target functionality could be kept
in a separate field.
Actually, even better would be to:
* change to JSON format (
http://www.json.org/ )
* omit the "http://en.wikipedia.org/wiki/" bit (and let the web UI add this
instead)
* use a different array for each element, rather than 3 different arrays for the different
fields (thus grouping all the fields for
one element together).
* use the [] notation instead of array notation (which is part of the JSON spec anyway).
In other words, using a real example, if the TcpQuery results for a search on
"cat" were changed from this current result:
sendRes("cat", new Array("Catholics → Roman Catholic Church",
"Catholic Archibishop → Bishop", "Catholic", "Catholic
Pope
→ Pope",
"CATV → Cable television", "Catalogue astrographique →
Star catalogue", "Catholic Encyclopedia", "Catalonia",
"Cattle",
"Catholicism"),
new Array("7505", "4484", "4200", "3269",
"2347", "2095", "1956", "1740", "1604",
"1527"), new
Array("http://en.wikipedia.org/wiki/Roman_Catholic_Church"urch",
"http://en.wikipedia.org/wiki/Bishop",
"http://en.wikipedia.org/wiki/Catholic",
"http://en.wikipedia.org/wiki/Pope",
"http://en.wikipedia.org/wiki/Cable_television",
"http://en.wikipedia.org/wiki/Star_catalogue",
"http://en.wikipedia.org/wiki/Catholic_Encyclopedia",
"http://en.wikipedia.org/wiki/Catalonia",
"http://en.wikipedia.org/wiki/Cattle",
"http://en.wikipedia.org/wiki/Catholicism"));
To this:
["cat",
["Catholics", 7505, "Roman Catholic Church"],
["Catholic Archibishop", 4484, "Bishop"],
["Catholic", 4200, ],
["Catholic", 3269, ],
["CATV", 2347, "Cable television"],
["Catalogue astrographique", 2095, "Star catalogue"],
["Catholic Encyclopedia", 1956, ],
["Catalonia", 1740, ],
["Cattle", 1604, ],
["Catholicism", 1527, ]
]
Then it would have the following benefits:
* Less data is transmitted (by my count approximately 840 bytes versus 322 bytes, or a
saving on 62%).
* The data can still be passed to an JS eval() to evaluate it.
* The redirects are in a different field, instead of merged into the first field.
* It's in a standard data format, so if other services wanted to talk to TcpQuery,
this would make that easier.
* To me, the second of those data formats seems simpler (but this may just be my personal
preference).
All the best,
Nick.