Include punctuation in regex.
This commit is contained in:
@@ -16,15 +16,6 @@ enum Error {
|
|||||||
Xml(#[from] quick_xml::Error),
|
Xml(#[from] quick_xml::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
fn title(s: &str) -> String {
|
|
||||||
let mut c = s.chars();
|
|
||||||
|
|
||||||
match c.next() {
|
|
||||||
None => String::new(),
|
|
||||||
Some(f) => f.to_uppercase().chain(c).collect(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let inputs = env::args().skip(1);
|
let inputs = env::args().skip(1);
|
||||||
|
|
||||||
@@ -112,6 +103,9 @@ fn main() -> Result<()> {
|
|||||||
let stdout = io::stdout();
|
let stdout = io::stdout();
|
||||||
let mut lock = stdout.lock();
|
let mut lock = stdout.lock();
|
||||||
|
|
||||||
|
let mut entries = entries.into_iter().collect::<Vec<_>>();
|
||||||
|
entries.sort_unstable_by_key(|(lang, _)| lang.to_639_3());
|
||||||
|
|
||||||
for (language, mut results) in entries.into_iter() {
|
for (language, mut results) in entries.into_iter() {
|
||||||
results.sort_unstable();
|
results.sort_unstable();
|
||||||
results.dedup();
|
results.dedup();
|
||||||
@@ -138,7 +132,13 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
for kind in ranges {
|
for kind in ranges {
|
||||||
match kind {
|
match kind {
|
||||||
Kind::Single(ch) => regex.push(ch),
|
Kind::Single(ch) => match ch {
|
||||||
|
'[' => regex.push_str(r"\["),
|
||||||
|
']' => regex.push_str(r"\]"),
|
||||||
|
'{' => regex.push_str(r"\{"),
|
||||||
|
'}' => regex.push_str(r"\}"),
|
||||||
|
_ => regex.push(ch),
|
||||||
|
},
|
||||||
Kind::Range(from, to) => {
|
Kind::Range(from, to) => {
|
||||||
regex.push(from);
|
regex.push(from);
|
||||||
regex.push('-');
|
regex.push('-');
|
||||||
@@ -198,6 +198,8 @@ impl PartialOrd for Kind {
|
|||||||
impl Ord for Kind {
|
impl Ord for Kind {
|
||||||
fn cmp(&self, other: &Kind) -> Ordering {
|
fn cmp(&self, other: &Kind) -> Ordering {
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
|
(Kind::Single('-'), Kind::Single(_)) => Ordering::Less,
|
||||||
|
(Kind::Single(_), Kind::Single('-')) => Ordering::Greater,
|
||||||
(Kind::Single(a), Kind::Single(b)) => a.cmp(&b),
|
(Kind::Single(a), Kind::Single(b)) => a.cmp(&b),
|
||||||
(Kind::Single(a), Kind::Range(b, _)) => a.cmp(&b),
|
(Kind::Single(a), Kind::Range(b, _)) => a.cmp(&b),
|
||||||
(Kind::Range(a, _), Kind::Single(b)) => a.cmp(&b),
|
(Kind::Range(a, _), Kind::Single(b)) => a.cmp(&b),
|
||||||
@@ -266,9 +268,11 @@ mod parse {
|
|||||||
}
|
}
|
||||||
Ok(Event::Start(ref e)) if e.name() == b"exemplarCharacters" => {
|
Ok(Event::Start(ref e)) if e.name() == b"exemplarCharacters" => {
|
||||||
parse = e.attributes().count() == 0
|
parse = e.attributes().count() == 0
|
||||||
|| e.attributes()
|
|| e.attributes().filter_map(Result::ok).any(|a| {
|
||||||
.filter_map(Result::ok)
|
a.key == b"type"
|
||||||
.any(|a| a.key == b"type" && a.value.as_ref() == b"auxiliary");
|
&& (a.value.as_ref() == b"auxiliary"
|
||||||
|
|| a.value.as_ref() == b"punctuation")
|
||||||
|
});
|
||||||
}
|
}
|
||||||
Ok(Event::End(ref e)) if e.name() == b"exemplarCharacters" && parse => {
|
Ok(Event::End(ref e)) if e.name() == b"exemplarCharacters" && parse => {
|
||||||
parse = false;
|
parse = false;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user