Comments (5)
Do you really need voca
in this case? Doesn't split_whitespace
work for you?
let s = "Some sort, of a - sentence."
.split_whitespace()
.collect::<Vec<&str>>();
assert_eq!(s, ["Some", "sort,", "of", "a", "-", "sentence."]);
from voca_rs.
It does in almost all the cases. But I do have similar input to the one you showcased for split::words
like XmlHttpRequest
. Maybe I have to put something custom made together!
from voca_rs.
Could you please provide a test case to review, so I'd be able to think about the solution?
from voca_rs.
@sirwindfield Please consider the following code snippet, whether this solution works for you?
let s = "Some sort, of a - sentence using LazyLoad with XMLHttpRequest."
.split_whitespace()
.collect::<Vec<_>>();
let mut res = Vec::new();
for w in s {
if w._words().len() > 1 {
let vec = w._words();
for v in vec {
res.push(v);
}
} else {
res.push(w);
};
}
assert_eq!(
res,
[
"Some", "sort,", "of", "a", "-", "sentence", "using", "Lazy", "Load", "with", "XML",
"Http", "Request"
]
);
Please note that it drops the last point because of words()
function behavior; you need to cover such edge cases.
Another possible solution is to cut out the split::words
function and to rewrite it for your needs.
from voca_rs.
Closed as it's stalled (workaround has been proposed).
from voca_rs.
Related Issues (16)
- Review escape::escape_html HOT 1
- Add scientific numbers validation
- Add hex number validation -> 0xFF
- Rewrite: strip::strip_tags
- README.md example does not compile HOT 1
- strip_tags panic HOT 3
- Encode/decode URI? HOT 3
- panic stripping half-open directive HOT 11
- U+200D (zero-width joiner) breaks the parsing HOT 1
- Link text for is_blank is wrong in README HOT 1
- Refactoring: ASCII_LETTERS HOT 1
- Refactoring: ASCII_UPPERCASE HOT 1
- Refactoring: HEXDIGITS HOT 1
- Refactoring: OCTDIGITS HOT 1
- Refactoring: PRINTABLE HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from voca_rs.