Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ import guessLanguage from './tools/guess_language'
const defaults: IOptions = {
delimiters: ['\\s+'],
language: 'english',
blockwords: [],
}

export default function process(text: string, opts?: IOptions): string[] {
const options: IOptions = merge({}, defaults, opts)
if (!opts || !opts.language) {
options.language = guessLanguage(text)
}

if (!opts || !opts.blockwords) {
options.blockwords = []
}
const params = merge(options, { corpus: text })
const keywords = rake(params)
return keywords
Expand Down
2 changes: 1 addition & 1 deletion src/lib/rake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function rake(params: IParameters): string[] {

// step 2: loop through all words, generate ngrams/stems/phrases/metrics
const stemmer = new Stemmer(params.language)
const stopwords = load(params.language)
const stopwords = params.blockwords
const parser = new Parser(stemmer, stopwords).process(wordArray)

// step 3: build a co-occurence matrix for all words (-> stems)
Expand Down