pub fn parse(state: &State, input: &str) -> Action {
        let prepositions = state.config.allowed_prepositions.clone().prepositions;
        let determiners = state.config.allowed_determiners.clone().determiners;

        let command_tokens: Vec<String> = input
            .split(' ')
            .collect::<Vec<&str>>()
            .iter()
            .filter(|w| {
                let word: String = w.to_string().to_lowercase();
                !prepositions.contains(&word) && !determiners.contains(&word)
            })
            .map(|word| word.to_string())
            .collect::<Vec<String>>();
        if command_tokens.is_empty() {
            Action {
                item: None,
                movement: None,
                subject: None,
                verb: None,
                command_tokens: vec!["".to_string()],
                input: input.to_string(),
            }
        } else {
            parse_action(state, command_tokens, input)
        }
    }
/// Parses the action.
///
/// It will return an action struct with the
/// appropriate data.
/// This function tokenizes the input string
/// and drops any words contained in the prepositions
/// or determiners arrays.
/// If after filtering the input string nothing is left,
/// it returns an invalid action with all fields set to None.
Parses the action.
It will return an action struct with the
appropriate data.
This function tokenizes the input string
and drops any words contained in the prepositions
or determiners arrays.
If after filtering the input string nothing is left,
it returns an invalid action with all fields set to None.
Parses the action . It will return an action struct with the appropriate data . This function tokenizes the input string and drops any words contained in the prepositions or determiners arrays . If after filtering the input string nothing is left it returns an invalid action with all fields set to None .
pub fn parse(state: &State, input: &str) -> Action {
        let prepositions = state.config.allowed_prepositions.clone().prepositions;
        let determiners = state.config.allowed_determiners.clone().determiners;
        let command_tokens: Vec<String> = input
            .split(' ')
            .collect::<Vec<&str>>()
            .iter()
            .filter(|w| {
                let word: String = w.to_string().to_lowercase();
                !prepositions.contains(&word) && !determiners.contains(&word)
            })
            .map(|word| word.to_string())
            .collect::<Vec<String>>();
        if command_tokens.is_empty() {
            Action {
                item: None,
                movement: None,
                subject: None,
                verb: None,
                command_tokens: vec!["".to_string()],
                input: input.to_string(),
            }
        } else {
            parse_action(state, command_tokens, input)
        }
    }
pub fn parse ( state : & State , input : & str ) -> Action { let prepositions = state . config . allowed_prepositions . clone ( ) . prepositions ; let determiners = state . config . allowed_determiners . clone ( ) . determiners ; let command_tokens : Vec < String > = input . split ( ' ' ) . collect :: < Vec < & str > > ( ) . iter ( ) . filter ( | w | { let word : String = w . to_string ( ) . to_lowercase ( ) ; ! prepositions . contains ( & word ) && ! determiners . contains ( & word ) } ) . map ( | word | word . to_string ( ) ) . collect :: < Vec < String > > ( ) ; if command_tokens . is_empty ( ) { Action { item : None , movement : None , subject : None , verb : None , command_tokens : vec ! [ " " to_string ( ) ] , input : input . to_string ( ) , } } else { parse_action ( state , command_tokens , input ) } }
Parses the action.
Parses the action .
state
&State
input
&str
state
&State
input
&str