Skip to content

Commit

Permalink
doc: update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rollrat committed Mar 15, 2023
1 parent 62914b9 commit cb7fd3d
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,56 @@
# hakurei

## Namuwiki Parser

Dump download: https://mu-star.net/wikidb

### Extract Category

Most articles have categories.

```rs
fn main() {
let js = load_dump();
extract_category(js);
}
```

#### (Example) Find By Category

If you want to fetch `Article` rather than `Title`, modify the code appropriately.

```rs
fn find_by_category<'a>(js: &'a Vec<Article>, what: &str) -> Vec<&'a str> {
let mut result: Vec<&str> = Vec::new();

for x in js {
let category = x.categories();

if category.iter().any(|x| x.starts_with(what)) {
result.push(&x.title);
}
}

result.sort_by(|a, b| a.cmp(b));

result
}
```

### Title indexing

Before using, you must create title index file.

```rs
fn main() {
create_title_index();
}
```

```rs
fn main() {
let mut index = TitleIndex::load();

println!("{}", index.get("하쿠레이 신사").unwrap().text);
}
```

0 comments on commit cb7fd3d

Please sign in to comment.