wip
This commit is contained in:
parent
a471bf6855
commit
7f6973389f
21 changed files with 30682 additions and 236 deletions
1
backend/reconcile/src/tokenizer/mod.rs
Normal file
1
backend/reconcile/src/tokenizer/mod.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
pub mod token;
|
||||
26
backend/reconcile/src/tokenizer/token.rs
Normal file
26
backend/reconcile/src/tokenizer/token.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct Token {
|
||||
pub normalised: String,
|
||||
pub original: String,
|
||||
}
|
||||
|
||||
impl Token {
|
||||
pub fn new(normalised: String, original: String) -> Self {
|
||||
Token {
|
||||
normalised,
|
||||
original,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tokenize(text: &str) -> Vec<Token> {
|
||||
text.split_inclusive(|c: char| c.is_whitespace())
|
||||
.map(|s| Token::new(s.to_string(), s.to_string()))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Token {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.normalised == other.normalised
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue