TypeScript API Reference¶
This page documents the TypeScript API for the atsds package. The documentation is generated from the TypeScript source code.
1 2 3 4 5 6 7 8 9 10 | |
buffer_size¶
Gets the current buffer size, or sets a new buffer size and returns the previous value.
1 | |
Parameters:
size(optional): The new buffer size to set. If 0 or omitted, returns current size without modification.
Returns: The previous buffer size value.
Example:
1 2 | |
String_¶
Wrapper class for deductive system strings.
Constructor¶
1 | |
Parameters:
value: Initial value (string, buffer, or another String_)size(optional): Buffer capacity for internal storage
Methods¶
toString()¶
Convert the value to a string representation.
1 | |
data()¶
Get the binary representation of the value.
1 | |
size()¶
Get the size of the data in bytes.
1 | |
copy()¶
Create a deep copy of this instance.
1 | |
key()¶
Get a key representation for equality comparison.
1 | |
Example:
1 2 3 | |
Variable¶
Wrapper class for logical variables in the deductive system.
Constructor¶
1 | |
Parameters:
value: Initial value (string starting with backtick, buffer, or another Variable)size(optional): Buffer capacity for internal storage
Methods¶
Inherits all methods from String_, plus:
name()¶
Get the name of this variable (without the backtick prefix).
1 | |
Example:
1 2 3 | |
Item¶
Wrapper class for items (constants/functors) in the deductive system.
Constructor¶
1 | |
Methods¶
Inherits all methods from String_, plus:
name()¶
Get the name of this item.
1 | |
Example:
1 2 | |
List¶
Wrapper class for lists in the deductive system.
Constructor¶
1 | |
Methods¶
Inherits all methods from String_, plus:
length()¶
Get the number of elements in the list.
1 | |
getitem()¶
Get an element from the list by index.
1 | |
Example:
1 2 3 | |
Term¶
Wrapper class for logical terms in the deductive system. A term can be a variable, item, or list.
Constructor¶
1 | |
Methods¶
Inherits all methods from String_, plus:
term()¶
Extracts the underlying term and returns it as its concrete type.
1 | |
ground()¶
Ground this term using a dictionary to substitute variables with values.
1 | |
Parameters:
other: A term representing a dictionary (list of pairs)scope(optional): Scope string for variable scoping
Returns: The grounded term, or null if grounding fails.
Example:
1 2 3 4 5 6 | |
match()¶
Match two terms and return the unification result as a dictionary.
1 | |
Parameters:
other: The term to match with this term
Returns: A term representing the unification dictionary (list of tuples), or null if matching fails.
Example:
1 2 3 4 5 6 | |
rename()¶
Rename all variables in this term by adding prefix and suffix.
1 | |
Parameters:
prefix_and_suffix: A term with format((prefix) (suffix))
Returns: The renamed term, or null if renaming fails.
Example:
1 2 3 4 5 6 | |
Rule¶
Wrapper class for logical rules in the deductive system.
Constructor¶
1 | |
Methods¶
Inherits all methods from String_, plus:
length()¶
Get the number of premises in the rule.
1 | |
getitem()¶
Get a premise term by index.
1 | |
conclusion()¶
Get the conclusion of the rule.
1 | |
ground()¶
Ground this rule using a dictionary.
1 | |
match()¶
Match this rule with another rule using unification.
1 | |
Parameters:
other: The rule to match against (must be a fact without premises)
Returns: The matched rule, or null if matching fails.
Example:
1 2 3 4 5 6 7 | |
rename()¶
Rename all variables in this rule.
1 | |
Search¶
Search engine for the deductive system.
Constructor¶
1 | |
Parameters:
limit_size(optional): Size of the buffer for storing rules/facts (default: 1000)buffer_size(optional): Size of the buffer for internal operations (default: 10000)
Methods¶
set_limit_size()¶
Set the size of the buffer for storing final objects.
1 | |
set_buffer_size()¶
Set the buffer size for internal operations.
1 | |
reset()¶
Reset the search engine, clearing all rules and facts.
1 | |
add()¶
Add a rule or fact to the knowledge base.
1 | |
Returns: True if successfully added, false otherwise.
execute()¶
Execute the search engine with a callback for each inferred rule.
1 | |
Parameters:
callback: Function called for each candidate rule. Return false to continue, true to stop.
Returns: The number of rules processed.
Example:
1 2 3 4 5 6 7 8 | |
Complete Example¶
Here's a complete example demonstrating most of the TypeScript API:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |