pub struct JsNSRMachine { /* private fields */ }Expand description
The Neural-Symbolic Recursive Machine - main Node.js interface
Implementations§
Source§impl JsNSRMachine
impl JsNSRMachine
Source§impl JsNSRMachine
impl JsNSRMachine
pub fn into_reference( val: JsNSRMachine, env: Env, ) -> Result<Reference<JsNSRMachine>>
pub fn into_instance(self, env: Env) -> Result<ClassInstance<JsNSRMachine>>
Source§impl JsNSRMachine
impl JsNSRMachine
Sourcepub fn with_config(config: JsNSRConfig) -> Self
pub fn with_config(config: JsNSRConfig) -> Self
Create with configuration
Sourcepub fn infer(&self, inputs: Vec<&JsGroundedInput>) -> Result<JsInferenceResult>
pub fn infer(&self, inputs: Vec<&JsGroundedInput>) -> Result<JsInferenceResult>
Perform inference on inputs
Sourcepub fn train(
&self,
examples: Vec<&JsTrainingExample>,
) -> Result<JsTrainingStats>
pub fn train( &self, examples: Vec<&JsTrainingExample>, ) -> Result<JsTrainingStats>
Train the machine on examples
Sourcepub fn evaluate(
&self,
examples: Vec<&JsTrainingExample>,
) -> Result<JsEvaluationResult>
pub fn evaluate( &self, examples: Vec<&JsTrainingExample>, ) -> Result<JsEvaluationResult>
Evaluate accuracy on test examples
Sourcepub fn add_symbol(&self, name: String) -> Result<u32>
pub fn add_symbol(&self, name: String) -> Result<u32>
Add a symbol to the vocabulary
Sourcepub fn get_symbol_name(&self, symbol_id: u32) -> Result<Option<String>>
pub fn get_symbol_name(&self, symbol_id: u32) -> Result<Option<String>>
Get a symbol’s name by ID
Sourcepub fn get_all_symbols(&self) -> Result<Vec<String>>
pub fn get_all_symbols(&self) -> Result<Vec<String>>
Get all symbol names
Sourcepub fn vocabulary_size(&self) -> Result<u32>
pub fn vocabulary_size(&self) -> Result<u32>
Get the vocabulary size
Sourcepub fn statistics(&self) -> Result<JsNSRStats>
pub fn statistics(&self) -> Result<JsNSRStats>
Get machine statistics
Sourcepub fn config(&self) -> Result<JsNSRConfig>
pub fn config(&self) -> Result<JsNSRConfig>
Get configuration
Sourcepub fn set_program(&self, symbol_id: u32, program: &JsProgram) -> Result<()>
pub fn set_program(&self, symbol_id: u32, program: &JsProgram) -> Result<()>
Set the program for a symbol This is essential for the deduction-abduction loop to work correctly
Sourcepub fn set_constant_program(
&self,
symbol_id: u32,
value: &JsSemanticValue,
) -> Result<()>
pub fn set_constant_program( &self, symbol_id: u32, value: &JsSemanticValue, ) -> Result<()>
Set a constant program for a symbol (convenience method) Creates a program that always returns the specified value
Sourcepub fn setup_classification_programs(&self) -> Result<()>
pub fn setup_classification_programs(&self) -> Result<()>
Automatically set up constant programs for all symbols Each symbol gets a program that returns SemanticValue::Symbol(symbol_name) This is useful for classification tasks
Trait Implementations§
Source§impl FromNapiMutRef for JsNSRMachine
impl FromNapiMutRef for JsNSRMachine
Source§unsafe fn from_napi_mut_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static mut Self>
unsafe fn from_napi_mut_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static mut Self>
Safety Read more
Source§impl FromNapiRef for JsNSRMachine
impl FromNapiRef for JsNSRMachine
Source§unsafe fn from_napi_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static Self>
unsafe fn from_napi_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static Self>
Safety Read more
Source§impl FromNapiValue for &JsNSRMachine
impl FromNapiValue for &JsNSRMachine
Source§unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: JsUnknown) -> Result<Self, Error>
Source§impl FromNapiValue for &mut JsNSRMachine
impl FromNapiValue for &mut JsNSRMachine
Source§unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: JsUnknown) -> Result<Self, Error>
Source§impl ToNapiValue for JsNSRMachine
impl ToNapiValue for JsNSRMachine
Source§unsafe fn to_napi_value(env: napi_env, val: JsNSRMachine) -> Result<napi_value>
unsafe fn to_napi_value(env: napi_env, val: JsNSRMachine) -> Result<napi_value>
Safety Read more
Source§impl TypeName for &JsNSRMachine
impl TypeName for &JsNSRMachine
Source§impl TypeName for &mut JsNSRMachine
impl TypeName for &mut JsNSRMachine
Source§impl TypeName for JsNSRMachine
impl TypeName for JsNSRMachine
Source§impl ValidateNapiValue for &JsNSRMachine
impl ValidateNapiValue for &JsNSRMachine
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Source§impl ValidateNapiValue for &mut JsNSRMachine
impl ValidateNapiValue for &mut JsNSRMachine
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Auto Trait Implementations§
impl Freeze for JsNSRMachine
impl RefUnwindSafe for JsNSRMachine
impl Send for JsNSRMachine
impl Sync for JsNSRMachine
impl Unpin for JsNSRMachine
impl UnsafeUnpin for JsNSRMachine
impl UnwindSafe for JsNSRMachine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more