Fixed #61 : SheerkaDebugManager: Add get_value()

Fixed #60 : Hash error when ReturnValue is a list of list
Fixed #59 : Implement smart_get()
Fixed #58 : SheerkaPromptCompleter: Cannot parse concept token
Fixed #57 : SheerkaPrompt: Add concept autocompletion
Fixed #56 : automatically backup command
Fixed #54 : I can record execution status
Fixed #53 : ConceptManager: modify_concept fails
This commit is contained in:
2021-04-09 15:47:32 +02:00
parent 6cda2686fb
commit dd3d8f4abe
37 changed files with 1055 additions and 191 deletions
+35
View File
@@ -0,0 +1,35 @@
# define adjectives
push_ontology("english")
def concept adjective
def concept color
set_isa(color, adjective)
def concept red
def concept blue
def concept orange
def concept yellow
def concept green
def concept indigo
def concept violet
def concept cyan
def concept magenta
def concept black
def concept white
def concept grey
set_isa(red, color)
set_isa(blue, color)
set_isa(orange, color)
set_isa(yellow, color)
set_isa(green, color)
set_isa(indigo, color)
set_isa(violet, color)
set_isa(cyan, color)
set_isa(magenta, color)
set_isa(black, color)
set_isa(white, color)
set_isa(grey, color)
def concept qualify x from bnf adjective x as set_attr(x, c:adjective:, adjective) ret x
def concept qualify x from bnf x 'is' adjective as set_attr(x, c:adjective:, adjective) ret x
+57
View File
@@ -0,0 +1,57 @@
# admin helpers
push_ontology("admin")
def concept explain as get_results(id=0, depth=2)
set_isa(c:explain:, __AUTO_EVAL)
def concept explain last as get_last_results(id=0, depth=2)
set_isa(c:explain last:, __AUTO_EVAL)
def concept explain x as get_results(id=x, depth=3)
set_isa(c:explain x:, __AUTO_EVAL)
def concept precedence a > precedence b as set_is_greater_than(__PRECEDENCE, a, b, 'Sya')
set_isa(c:precedence a > precedence b:, __AUTO_EVAL)
def concept x is a command as set_auto_eval(x, __AUTO_EVAL)
set_auto_eval(c:x is a command:)
def concept activate debug as set_debug(True)
set_auto_eval(c:activate debug:)
def concept deactivate debug as set_debug(False)
set_auto_eval(c:deactivate debug:)
def concept debug on as set_debug(True)
set_auto_eval(c:debug on:)
def concept debug off as set_debug(False)
set_auto_eval(c:debug off:)
def concept activate debug on x as debug_var(x)
set_auto_eval(c:activate debug on x:)
def concept debug x as debug_var(x)
set_auto_eval(c:debug x:)
def concept debug var x as debug_var(variable=x)
set_auto_eval(c:debug var x:)
def concept debug variable x as debug_var(variable=x)
set_auto_eval(c:debug variable x:)
def concept debug method x as debug_var(method=x)
set_auto_eval(c:debug method x:)
def concept deactivate debug on x as debug_var(x, enabled=False) where x
set_auto_eval(c:deactivate debug on x:)
def concept activate return values processing as set_var("sheerka.enable_process_return_values", True)
def concept deactivate return values processing as set_var("sheerka.enable_process_return_values", False)
set_auto_eval(c:activate return values processing:)
set_auto_eval(c:deactivate return values processing:)
def concept rule x where isinstance(x, int) as r:|x:
set_auto_eval(c:rule x:)
def concept rule x > rule y where isinstance(x, int) and isinstance(y, int) as set_is_greater_than(__PRECEDENCE, r:|x:, r:|y:, 'Rule')
set_auto_eval(c:rule x > rule y:)
def concept rule x is greatest where isinstance(x, int) as set_is_greatest(__PRECEDENCE, r:|x:, 'Rule')
set_auto_eval(c:rule x is greatest:)
def concept rule x < rule y where isinstance(x, int) and isinstance(y, int) as set_is_less_than(__PRECEDENCE, r:|x:, r:|y:, 'Rule')
set_auto_eval(c:rule x < rule y:)
def concept rule x is lesser where isinstance(x, int) as set_is_lesser(__PRECEDENCE, r:|x:, 'Rule')
set_auto_eval(c:rule x is lesser:)
+77
View File
@@ -0,0 +1,77 @@
# question
push_ontology("english")
def concept q from q ? as question(q) pre is_question()
set_is_lesser(__PRECEDENCE, q, 'Sya')
set_auto_eval(c:q:)
def concept the x ret memory(x)
def concept a x where 'x is a concept' ret x
def concept an x where 'x is a concept' ret x
set_is_greatest(__PRECEDENCE, c:the x:, 'Sya')
set_is_greatest(__PRECEDENCE, c:a x:, 'Sya')
set_is_greatest(__PRECEDENCE, c:an x:, 'Sya')
def concept "x is a concept" as isinstance(x, Concept) pre is_question()
# is a
def concept x is a y as set_isa(x, y) ret x
set_auto_eval(c:x is a y:)
def concept x is an y as set_isa(x, y) ret x
set_auto_eval(c:x is an y:)
def concept x is a y as isa(x,y) pre is_question()
# no need to auto eval as it's a question
def concept x is an y as isa(x,y) pre is_question()
# no need to auto eval as it's a question
# has a
def concept x has a y as set_hasa(x, y) ret x
set_auto_eval(c:x has a y:)
def concept x has an y as set_hasa(x, y) ret x
set_auto_eval(c:x has an y:)
def concept x has a y as hasa(x,y) pre is_question()
# no need to auto eval as it's a question
def concept x has an y as hasa(x,y) pre is_question()
# no need to auto eval as it's a question
# AND
def concept x and y as x and y pre is_question()
set_is_lesser(__PRECEDENCE, c:x and y:, 'Sya')
set_is_less_than(__PRECEDENCE, c:q:, c:x and y:, 'Sya')
# OR
def concept x or y as x or y pre is_question()
set_is_lesser(__PRECEDENCE, c:x or y:, 'Sya')
set_is_greater_than(__PRECEDENCE, c:x and y:, c:x or y:, 'Sya')
set_is_less_than(__PRECEDENCE, c:q:, c:x or y:, 'Sya')
# default
def concept male
def concept female
def concept man
man is a male
def concept woman
woman is a female
def concept human
man is a human
woman is a human
def concept boy
def concept boys
def concept girl
def concept girls
def concept shirt
# days of the week
def concept monday
def concept tuesday
def concept wednesday
def concept thursday
def concept friday
def concept saturday
def concept sunday
# questions
def concept what x is y pre is_question() where isa(x, adjective) as smart_get_attr(y, x)
def concept how is x pre is_question() as smart_get_attr(x, adjective)
+10
View File
@@ -0,0 +1,10 @@
#import admin
#import default
#import python
#import numbers
#import adjectives
+12
View File
@@ -0,0 +1,12 @@
#import admin
#import default
def concept one as 1
def concept two as 2
def concept number
def concept apple
def concept table
def concept location
def concept x is on y as set_attr(x, location, y)
+97
View File
@@ -0,0 +1,97 @@
# define numbers
push_ontology("english")
def concept one as 1
def concept two as 2
def concept three as 3
def concept four as 4
def concept five as 5
def concept six as 6
def concept seven as 7
def concept eight as 8
def concept nine as 9
def concept ten as 10
def concept eleven as 11
def concept twelve as 12
def concept thirteen as 13
def concept fourteen as 14
def concept fifteen as 15
def concept sixteen as 16
def concept seventeen as 17
def concept eighteen as 18
def concept nineteen as 19
def concept twenty as 20
def concept number
set_isa(one, number)
set_isa(two, number)
set_isa(three, number)
set_isa(four, number)
set_isa(five, number)
set_isa(six, number)
set_isa(seven, number)
set_isa(eight, number)
set_isa(nine, number)
set_isa(ten, number)
set_isa(eleven, number)
set_isa(twelve, number)
set_isa(thirteen, number)
set_isa(fourteen, number)
set_isa(fifteen, number)
set_isa(sixteen, number)
set_isa(seventeen, number)
set_isa(eighteen, number)
set_isa(nineteen, number)
set_isa(twenty, number)
def concept twenties from bnf twenty number where number < 10 as twenty + number
set_isa(twenties, number)
def concept thirty as 30
set_isa(thirty, number)
def concept thirties from bnf thirty number where number < 10 as thirty + number
set_isa(thirties, number)
def concept forty as 40
set_isa(forty, number)
def concept forties from bnf forty number where number < 10 as forty + number
set_isa(forties, number)
def concept fifty as 50
set_isa(fifty, number)
def concept fifties from bnf fifty number where number < 10 as fifty + number
set_isa(fifties, number)
def concept sixty as 60
set_isa(sixty, number)
def concept sixties from bnf sixty number where number < 10 as sixty + number
set_isa(sixties, number)
def concept seventy as 70
set_isa(seventy, number)
def concept seventies from bnf seventy number where number < 10 as seventy + number
set_isa(seventies, number)
def concept eighty as 80
set_isa(eighty, number)
def concept eighties from bnf eighty number where number < 10 as eighty + number
set_isa(eighties, number)
def concept ninety as 90
set_isa(ninety, number)
def concept nineties from bnf ninety number where number < 10 as ninety + number
set_isa(nineties, number)
def concept one hundred as 100
set_isa(one hundred, number)
def concept hundreds from bnf number=n1 'hundred' 'and' number=n2 where n1 < 10 and n2 < 100 as n1 * 100 + n2
set_isa(hundreds, number)
def concept hundreds from bnf number 'hundred' where number < 10 as number * 100
set_isa(last_created_concept(), number)
def concept thousands from bnf number 'thousand' where number < 1000 as number * 1000
set_isa(thousands, number)
def concept thousands from bnf number=n1 'thousand' 'and' number=n2 as n1 * 1000 + n2 where n1 < 1000 and n2 < 1000
set_isa(last_created_concept(), number)
# define basic operations on numbers
def concept plus from a plus b as a + b
def concept minus from a minus b as a - b
def concept multiplied from a multiplied by b as a * b
def concept divided from a divided by b as a * b
set_is_greater_than(__PRECEDENCE, multiplied, plus, 'Sya')
set_is_greater_than(__PRECEDENCE, divided, plus, 'Sya')
set_is_greater_than(__PRECEDENCE, multiplied, minus, 'Sya')
set_is_greater_than(__PRECEDENCE, divided, minus, 'Sya')
def concept quantity
def concept quantify x from bnf number x as set_attr(x, quantity, number) ret x
def concept how many x pre is_question() as get_attr(memory(x), quantity)
+6
View File
@@ -0,0 +1,6 @@
push_ontology("english")
def concept x is a string pre is_question() as isinstance(x, str)
def concept x is a integer pre is_question() as isinstance(x, int)
def concept x starts with y pre is_question() where x is a string as x.startswith(y)
def concept sha256 from bnf r'[a-f0-9]{64}'
def concept sha512 from bnf r'[a-f0-9]{128}'
+10
View File
@@ -0,0 +1,10 @@
#import full
push_ontology("test-adjective")
def concept size
def concept little
def concept girl
def concept little x as set_attr(x, size, little) ret x
def concept the x ret memory(x)
def concept how is x as get_attr(x, size)