about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander <alexanderkabua@gmail.com>2022-05-18 14:15:12 +0300
committerAlexander <alexanderkabua@gmail.com>2022-05-18 14:15:12 +0300
commite1b9f68ff7c16a9411add9beabcdbfa545d1679b (patch)
treebdba82fbc1ee9336a67d8c345aa558c4f249d0dd /src
parent2d5f9f3b8b90c47abfdc3f7c2ddd9c04bfb37616 (diff)
downloadcorrelation_rust-e1b9f68ff7c16a9411add9beabcdbfa545d1679b.tar.gz
add main file
Diffstat (limited to 'src')
-rw-r--r--src/main.rs34
-rw-r--r--src/parser.rs8
-rw-r--r--src/sample_json_file.json2
3 files changed, 39 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..781ee2b
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,34 @@
+use std::env;
+use correlation_rust::parser;
+use correlation_rust::correlations;
+fn main () {
+
+
+    let json_file = match env::args().nth(1){
+        Some(tmp_file) => {
+            let results = parser::JsonData::new(&tmp_file);
+
+
+            let parsed_x_vals:Vec<f64> = results.x_vals.split(",").map(|f|f.trim().parse::<f64>().unwrap()).collect();
+      
+
+
+            let computation = correlations::Compute::new(
+                ',',
+                "pearson",
+                &results.file_path,
+        &parsed_x_vals
+
+            ).compute();
+
+            //println!("{:?}",computation);
+
+        }
+        None => panic!("expected an arugment for the json file")
+    };
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/src/parser.rs b/src/parser.rs
index c42b268..57465a2 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -5,15 +5,15 @@ use serde::Deserialize;
 //#[serde(rename_all = "PascalCase")]
 
 pub struct JsonData {
-    file_path:String,
-    x_vals: String,
-    sample_values:String,
+    pub file_path:String,
+    pub x_vals: String,
+    pub sample_values:String,
 
 }
 
 
 impl JsonData {
-    fn new(json_file_path:&str) -> JsonData{
+    pub fn new(json_file_path:&str) -> JsonData{
 
 
     let mut  file = std::fs::File::open(json_file_path).unwrap();
diff --git a/src/sample_json_file.json b/src/sample_json_file.json
index a49c189..dcc3817 100644
--- a/src/sample_json_file.json
+++ b/src/sample_json_file.json
@@ -1,5 +1,5 @@
 {
-    "file_path":"/home/kabui/correlation_rust/src/matrix80.txt",
+    "file_path":"/home/kabui/correlation_rust/src/matrix_80.txt",
     "x_vals":"25.08439, 72.02225, 47.56293, 22.87893, 14.28721, 71.84655, 87.81991, 84.86824, 6.72478, 5.72373, 73.47078, 63.74703",
     "sample_values":"bxd1"
  }
\ No newline at end of file