Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs for vocab constructors. #81

Merged
merged 1 commit into from
Oct 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/chunks/vocab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ pub struct SimpleVocab {
}

impl SimpleVocab {
/// Construct a new simple vocabulary.
///
/// Words are assigned indices in the given order.
pub fn new(words: impl Into<Vec<String>>) -> Self {
let words = words.into();
let indices = create_indices(&words);
Expand Down Expand Up @@ -141,6 +144,11 @@ where
const BOW: char = '<';
const EOW: char = '>';

/// Construct a new `SubwordVocab`.
///
/// Words are assigned indices in the given order. NGrams in range `(min_n..max_n)` are
/// considered. The `indexer` is used to look up indices for the NGrams produced by this
/// `SubwordVocab`.
pub fn new(words: impl Into<Vec<String>>, min_n: u32, max_n: u32, indexer: I) -> Self {
let words = words.into();
let indices = create_indices(&words);
Expand Down