Skip to content

Commit

Permalink
Checking bayes-star v0.1.0 (/Users/greg/Code/bayes-star/rust)
Browse files Browse the repository at this point in the history
error: expected expression, found `let` statement
  --> src/common/run.rs:65:5
   |
65 |     let train_result = do_training(&mut storage);
   |     ^^^

error: expected expression, found statement (`let`)
  --> src/common/run.rs:65:5
   |
65 |     let train_result = do_training(&mut storage);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: variable declaration using `let` is a statement

error[E0425]: cannot find function `train_on_example` in this scope
  --> src/common/run.rs:30:15
   |
30 |         match train_on_example(storage, &proposition, &backlinks) {
   |               ^^^^^^^^^^^^^^^^ not found in this scope
   |
help: consider importing this function
   |
1  | use crate::model::maxent::train_on_example;
   |

error[E0658]: `let` expressions in this position are unstable
  --> src/common/run.rs:65:5
   |
65 |     let train_result = do_training(&mut storage);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #53667 <rust-lang/rust#53667> for more information

warning: unused import: `super::choose::compute_backlinks`
 --> src/model/maxent.rs:8:5
  |
8 | use super::choose::compute_backlinks;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `initialize_weights`
  --> src/model/maxent.rs:11:58
   |
11 | use super::weights::{negative_feature, positive_feature, initialize_weights};
   |                                                          ^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
  --> src/common/run.rs:27:43
   |
27 |         let backlinks = compute_backlinks(storage, &proposition)?;
   |                         ----------------- ^^^^^^^ types differ in mutability
   |                         |
   |                         arguments to this function are incorrect
   |
   = note: expected mutable reference `&mut Storage`
                      found reference `&Storage`
note: function defined here
  --> src/model/choose.rs:74:8
   |
74 | pub fn compute_backlinks(
   |        ^^^^^^^^^^^^^^^^^
75 |     storage: &mut Storage,
   |     ---------------------

error[E0061]: this function takes 2 arguments but 1 argument was supplied
  --> src/common/run.rs:65:24
   |
65 |     let train_result = do_training(&mut storage);
   |                        ^^^^^^^^^^^ ------------ an argument of type `Box<(dyn LogicalModel + 'static)>` is missing
   |
note: function defined here
  --> src/common/run.rs:12:8
   |
12 | pub fn do_training(model:Box<dyn LogicalModel>, storage: &Storage) -> Result<(), Box<dyn Error>> {
   |        ^^^^^^^^^^^ ---------------------------  -----------------
help: provide the argument
   |
65 |     let train_result = do_training(/* Box<(dyn LogicalModel + 'static)> */, &mut storage);
  • Loading branch information
Greg committed Jan 10, 2024
1 parent c45c57c commit 4892aaf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion rust/src/common/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ pub trait PropositionProbability {
}

pub trait LogicalModel {
fn initialize_weight(implication:&Implication) -> Result<(), Box<dyn Error>>;
fn initialize_connection(&mut self, implication:&Implication) -> Result<(), Box<dyn Error>>;

fn train(
&mut self,
storage: &mut Storage,
proposition: &Proposition,
) -> Result<TrainStatistics, Box<dyn Error>>;
fn predict(
&self,
storage: &mut Storage,
evidence: &dyn PropositionProbability,
proposition: &Proposition,
Expand Down
12 changes: 8 additions & 4 deletions rust/src/common/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ use redis::Client;

use crate::model::{storage::Storage, inference::marginalized_inference_probability};
use crate::model::choose::compute_backlinks;
use super::interface::ScenarioMaker;
use super::interface::{ScenarioMaker, LogicalModel};


pub fn do_training(storage: &mut Storage) -> Result<(), Box<dyn Error>> {
fn create_model(model_name:&String) -> Result<Box<dyn LogicalModel>, Box<dyn Error>> {
todo!()
}
pub fn do_training(model:Box<dyn LogicalModel>, storage: &Storage) -> Result<(), Box<dyn Error>> {
trace!("do_training - Getting all implications");
let implications = storage.get_all_implications()?;
for implication in implications {
trace!("do_training - Processing implication: {:?}", implication);
initialize_weights(storage.get_redis_connection(), &implication)?;
model.initialize_connection( &implication)?;
}

trace!("do_training - Getting all propositions");
Expand Down Expand Up @@ -58,6 +60,8 @@ pub fn train_and_test(scenario_maker:&dyn ScenarioMaker) -> Result<(), Box<dyn E
let mut storage = Storage::new(connection).expect("Couldn't make storage");
let result = scenario_maker.setup_scenario(&mut storage);
info!("scenario result: {:?}", result);

let model =
let train_result = do_training(&mut storage);
info!("train result: {:?}", train_result);

Expand Down

0 comments on commit 4892aaf

Please sign in to comment.