-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a96c8ec
commit 69421fe
Showing
3 changed files
with
70 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use documented::{Documented, DocumentedFields}; | ||
use graphannis::update::GraphUpdate; | ||
use serde::Deserialize; | ||
use struct_field_names_as_array::FieldNamesAsSlice; | ||
|
||
use super::Importer; | ||
const FILE_EXTENSIONS: [&str; 3] = ["csv", "tsv", "conll"]; | ||
Check failure on line 7 in src/importer/table.rs GitHub Actions / Static code analysis
|
||
|
||
/// Imports table-like CSV files. | ||
#[derive(Deserialize, Documented, DocumentedFields, FieldNamesAsSlice)] | ||
#[serde(default, deny_unknown_fields)] | ||
pub struct ImportTable { | ||
/// The provided character defines the column delimiter. The default value is tab. | ||
/// | ||
/// Example: | ||
/// ```toml | ||
/// [export.config] | ||
/// delimiter = ";" | ||
/// ``` | ||
#[serde(default = "default_delimiter")] | ||
delimiter: char, | ||
Check failure on line 21 in src/importer/table.rs GitHub Actions / Static code analysis
|
||
/// The provided character will be used for quoting values. If nothing is provided, all columns will contain bare values. If a character is provided, | ||
/// all values will be quoted. | ||
/// | ||
/// Example: | ||
/// ```toml | ||
/// [export.config] | ||
/// quote_char = "\"" | ||
/// ``` | ||
#[serde(default)] | ||
quote_char: Option<char>, | ||
} | ||
|
||
impl Default for ImportTable { | ||
fn default() -> Self { | ||
Self { | ||
delimiter: default_delimiter(), | ||
quote_char: None, | ||
} | ||
} | ||
} | ||
|
||
fn default_delimiter() -> char { | ||
'\t' | ||
} | ||
|
||
impl Importer for ImportTable { | ||
fn import_corpus( | ||
&self, | ||
input_path: &std::path::Path, | ||
Check failure on line 50 in src/importer/table.rs GitHub Actions / Static code analysis
|
||
step_id: crate::StepID, | ||
Check failure on line 51 in src/importer/table.rs GitHub Actions / Static code analysis
|
||
tx: Option<crate::workflow::StatusSender>, | ||
Check failure on line 52 in src/importer/table.rs GitHub Actions / Static code analysis
|
||
) -> Result<GraphUpdate, Box<dyn std::error::Error>> { | ||
todo!() | ||
} | ||
|
||
fn file_extensions(&self) -> &[&str] { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters