Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. struct Span {
  2. pub begin: usize,
  3. pub end: usize,
  4. }
  5.  
  6. fn main() {
  7. let text = "the quick brown óf fox óf the end óf the world";
  8. let textstop = "óf the and of";
  9. let stopwords: Vec<_> = textstop.split_whitespace().collect();
  10. let mut spans: Vec<Span> = Vec::new();
  11. for word in &stopwords {
  12. let indexes: Vec<_> = text.match_indices(word).collect();
  13. let size = word.as_bytes().len();
  14. for (i, _) in &indexes {
  15. spans.push(Span {
  16. begin: *i,
  17. end: (*i + size),
  18. });
  19. }
  20. }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement