Skip to content

Add comment support to io methods#320

Merged
craffel merged 3 commits intomasterfrom
io-comments
Aug 25, 2019
Merged

Add comment support to io methods#320
craffel merged 3 commits intomasterfrom
io-comments

Conversation

@bmcfee
Copy link
Copy Markdown
Collaborator

@bmcfee bmcfee commented Aug 25, 2019

This pr fixes #319 by adding a comment= flag to (almost) all* data loaders. The semantics are as follows:

  • By default, any line starting with '#' is skipped.
  • A user can override the comment string with any regular expression. The regexp is constructed to only match at the beginning of the line. For example, calling with comment=';' uses the semicolon as a comment leader.
  • Comment skipping can be disabled by specifying comment=None. This is equivalent to the current default behavior, but I don't think it should be the default going forward. It's increasingly common for annotation tools to leave metadata in the resulting data file, and we should be encouraging of that pattern.
  • exceptions for wav (obviously) and pattern, the latter because the pattern format doesn't seem to have a common grammar for comments. The other formats implicitly use some flavor of CSV/TSV, which generally support comment strings.

@bmcfee bmcfee requested a review from craffel August 25, 2019 00:49
@bmcfee bmcfee self-assigned this Aug 25, 2019
Comment thread mir_eval/io.py
@craffel craffel merged commit 14ab136 into master Aug 25, 2019
@craffel
Copy link
Copy Markdown
Collaborator

craffel commented Aug 25, 2019

Thank you sir, always a pleasure.

@bmcfee bmcfee deleted the io-comments branch February 7, 2025 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IO functions do not skip comment lines

2 participants