Skip to content

Commit

Permalink
Docs for vocab constructors.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebpuetz committed Oct 7, 2019
1 parent 66388fe commit 4372499
Showing 1 changed file with 8 additions and 0 deletions.
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

0 comments on commit 4372499

Please sign in to comment.