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

add third param to base function, that represent stopWords array #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import guessLanguage from './tools/guess_language'
const defaults: IOptions = {
delimiters: ['\\s+'],
language: 'english',
stopWords: [],
}

export default function process(text: string, opts?: IOptions): string[] {
Expand Down
5 changes: 3 additions & 2 deletions src/lib/rake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import load from './tools/stoplist'
// can be used to tweak the algorithm or to use it without the defaults
export interface IOptions {
delimiters: string[]
language: languageName
language: languageName,
stopWords: [],
}

// the actual parameters for the RAKE algorithm
Expand All @@ -24,7 +25,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.stopWords
const parser = new Parser(stemmer, stopwords).process(wordArray)

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