is teenager and is adult in bko

OK. Here is a fun and short one. Let's encode "is-teenager" and "is-adult" in BKO.

If we had less than and greater than implemented, we could do it directly:
is-teenager |person: *> #=> |age: 13> <= age|_self> <= |age: 19>
is-adult |person: *> #=> age|_self> >= |age: 18>

Now, they are not currently implemented (but presumably will be one day), but we can still do it indirectly (as is often the case):
is-teenager |person: *> #=> do-you-know drop-below[13] drop-above[19] pop-float age |_self>
is-adult |person: *> #=> do-you-know drop-below[18] pop-float age|_self>

-- feed in some ages:
age |person: Emma> => |age: 12>
age |person: Fred> => |age: 17>
age |person: Sam> => |age: 18>
age |person: Liz> => |age: 19>
age |person: Jack> => |age: 20>

-- now test it:
sa: is-teenager |person: Emma>
|no>

sa: is-adult |person: Emma>
|no>

sa: is-teenager |person: Fred>
|yes>

sa: is-adult |person: Fred>
|no>

sa: is-teenager |person: Sam>
|yes>

sa: is-adult |person: Sam>
|yes>

sa: is-teenager |person: Liz>
|yes>

sa: is-adult |person: Liz>
|yes>

sa: is-teenager |person: Jack>
|no>

sa: is-adult |person: Jack>
|yes>

Simple and fun! Heaps more to come!

Update: as in the is-late example, we can use the in-range sigmoid for is-teenager too, instead of using drop-below and drop-above (and I think in-range is a tad easier to understand):
is-teenager |person: *> #=> do-you-know drop sigmoid-in-range[13,19] pop-float age |_self>



Home
previous: foaf vs sw
next: new function pretty print a table

updated: 19/12/2016
by Garry Morrison
email: garry -at- semantic-db.org