Allow transforming graph before commands
This commit is contained in:
parent
ab7b7295ca
commit
c573f1b0b0
8 changed files with 134 additions and 17 deletions
|
|
@ -121,7 +121,7 @@ fn read_page_data(
|
|||
|
||||
for (target, start, len, flags) in page_links {
|
||||
if let Some((_, brood_i)) = title_lookup.get(&normalizer.normalize(&target)) {
|
||||
data.graph.edges.push(NodeIdx(*brood_i));
|
||||
data.graph.add_edge(NodeIdx(*brood_i));
|
||||
data.links.push(Link { start, len, flags });
|
||||
}
|
||||
}
|
||||
|
|
@ -139,7 +139,7 @@ pub struct Cmd {
|
|||
}
|
||||
|
||||
impl Cmd {
|
||||
pub fn run(self, brood_data: &Path) -> io::Result<()> {
|
||||
pub fn run(&self, brood_data: &Path) -> io::Result<()> {
|
||||
let normalizer = TitleNormalizer::new();
|
||||
|
||||
println!(">> First pass");
|
||||
|
|
@ -162,7 +162,7 @@ impl Cmd {
|
|||
drop(sift_data); // No longer needed
|
||||
|
||||
println!("> Checking consistency");
|
||||
data.graph.check_consistency();
|
||||
data.check_consistency();
|
||||
|
||||
println!(">> Export");
|
||||
println!(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use std::{io, path::Path};
|
||||
use std::io;
|
||||
|
||||
use crate::{
|
||||
algo::Dijkstra,
|
||||
|
|
@ -14,12 +14,9 @@ pub struct Cmd {
|
|||
}
|
||||
|
||||
impl Cmd {
|
||||
pub fn run(self, data: &Path) -> io::Result<()> {
|
||||
pub fn run(self, data: Data) -> io::Result<()> {
|
||||
let normalizer = TitleNormalizer::new();
|
||||
|
||||
println!(">> Import");
|
||||
let data = Data::read_from_file(data)?;
|
||||
|
||||
println!(">> Resolve articles");
|
||||
let start = util::resolve_title(&normalizer, &data, &self.start);
|
||||
let goal = util::resolve_title(&normalizer, &data, &self.goal);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use std::{collections::HashSet, io, path::Path};
|
||||
use std::{collections::HashSet, io};
|
||||
|
||||
use thousands::Separable;
|
||||
|
||||
|
|
@ -18,12 +18,9 @@ pub struct Cmd {
|
|||
}
|
||||
|
||||
impl Cmd {
|
||||
pub fn run(self, data: &Path) -> io::Result<()> {
|
||||
pub fn run(self, data: Data) -> io::Result<()> {
|
||||
let normalizer = TitleNormalizer::new();
|
||||
|
||||
println!(">> Import");
|
||||
let data = Data::read_from_file(data)?;
|
||||
|
||||
println!(">> Locate article");
|
||||
let mut node = util::locate_title(&normalizer, &data, &self.title);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue