pub fn read_to_wordmap(&mut self, wl: &mut WordMap) {
        //Create a string to read the file in
        let mut buffer = String::new();
        self.file.read_to_string(&mut buffer).expect("Could not read file");

        //Split the string from newlines, then split again from whitespaces
        for sentence in buffer.split("\n") {
            let words: Vec<&str> = sentence.split(' ').collect();

            //Add words to the WordMap
            for x in 0..words.len() - 1 {
                wl.add(words[x].to_string(), words[x + 1].to_string());
            }
        }
    }
//Read a file and insert its contents to a WordMap
// NOTE: This is highly inefficient for memory as all file content is stored at the same time.
// TODO: REWORK
Read a file and insert its contents to a WordMap
NOTE: This is highly inefficient for memory as all file content is stored at the same time.
TODO: REWORK
Read a file and insert its contents to a WordMap NOTE : This is highly inefficient for memory as all file content is stored at the same time . TODO : REWORK
pub fn read_to_wordmap(&mut self, wl: &mut WordMap) {
        //Create a string to read the file in
        let mut buffer = String::new();
        self.file.read_to_string(&mut buffer).expect("Could not read file");
        //Split the string from newlines, then split again from whitespaces
        for sentence in buffer.split("\n") {
            let words: Vec<&str> = sentence.split(' ').collect();
            //Add words to the WordMap
            for x in 0..words.len() - 1 {
                wl.add(words[x].to_string(), words[x + 1].to_string());
            }
        }
    }
pub fn read_to_wordmap ( & mut self , wl : & mut WordMap ) { //Create a string to read the file in let mut buffer = String :: new ( ) ; self . file . read_to_string ( & mut buffer ) . expect ( " " ) ; //Split the string from newlines, then split again from whitespaces for sentence in buffer . split ( " \n " ) { let words : Vec < & str > = sentence . split ( ' ' ) . collect ( ) ; //Add words to the WordMap for x in 0 .. words . len ( ) - 1 { wl . add ( words [ x ] . to_string ( ) , words [ x + 1 ] . to_string ( ) ) ; } } }
Read a file and insert its contents to a WordMap
NOTE: This is highly inefficient for memory as all file content is stored at the same time.
Read a file and insert its contents to a WordMap NOTE : This is highly inefficient for memory as all file content is stored at the same time .
&mut self
wl
&mut WordMap
&mut self
wl
&mut WordMap