Closed linas closed 4 years ago
This is addressed in PR https://github.com/MOZI-AI/annotation-scheme/pull/122
Several cases remain.
A pair of boolean flags used to indicate whether or not coding and non-coding RNA markup should be done is encoded as (ListLink (Concept "True") (Concept "True"))
... some minor performance gains, and some readability would be gains simply by using (TrueLink)
and (FalseLink)
instead.
A boolean flag to indicate whether protein interactions should be done, or not, is encoded as (NumberNode 0)
and (NumberNode 1)
. It's not immediately obvious that this is a boolean flag, until you carefully study the code. Using (TrueLink)
and (FalseLink)
would simplify things.
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.
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.)
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-rna
code.
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
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.
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...