MOZI-AI / annotation-scheme

Human Gene annotation service backend
GNU General Public License v3.0
3 stars 4 forks source link

Use #t and #f not string "True" #84

Closed linas closed 4 years ago

linas commented 4 years ago

So if I do grep True annotation I find a dozen uses of (if (equal? prot "True") ...) and similar. Instead of using the string "True", just say #t and that way you can write (if prot ...) The idea being that in scheme, #t and #f denote true and false...

rekado commented 4 years ago

This is addressed in PR https://github.com/MOZI-AI/annotation-scheme/pull/122

linas commented 4 years ago

Several cases remain.

Neither of these mechanisms would be required, if the GroundedSchemaNodes weren't being used. There might be(?) a slight performance improvement (maybe? unclear) if instead, a GetLink was used to obtain all the groundings, and then plain-old srfi-1 map used to apply the desired functions. Please recall that (BindLink pattern rewrite-rule) is equivalent to applying the rewrite rule to (GetLink pattern), and this later form is ... sometimes easier to work with... although its a matter of taste, I guess. In this case, using the GroundedSchema forces you to encode #t and #f into some kind of atom, which you otherwise would not need to do.

linas commented 4 years ago

There are several other cases where the usage of GroundedSchemaNode forces string or number arguments to be passed as atoms. These can be found by how they are decoded:

(string-split (cog-name namespace) #\ )
(string->number (cog-name parent))

Some unknown (probably small-ish?) amount of performance is lost encoding and decoding these arguments (the first appears to be a list of strings; the second is just a number.)

linas commented 4 years ago

Most of the remaining cases are fixed in #149 and #156. The last remaining case is in find-rna which is easy to fix, but can't be done until #156 is merged.

... done, with #159 fixing the find-rnacode.

There's now only one place in functions.scm which uses Number to pass a boolean true/false value; this is find-protein and filter-pathway ... fixed in #168

linas commented 4 years ago

Closing; all instances are fixed. ... well, filter-pathway still uses 0 and 1 instead of #t and #f but I'm not gonna mess with that.