Skip to content

Commit

Permalink
Merge pull request #71 from fergiemcdowall/inBrowser
Browse files Browse the repository at this point in the history
In browser
  • Loading branch information
eklem authored Jul 2, 2019
2 parents 0ab4d71 + 5291973 commit 99c699f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
47 changes: 34 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# stopword
`stopword` is a node module that allows you to strip stopwords from an
`stopword` is a module for node and the browser that allows you to strip stopwords from an
input text. [In natural language processing, "Stopwords" are words
that are so frequent that they can safely be removed from a text
without altering its
Expand All @@ -12,8 +12,28 @@ meaning.](https://en.wikipedia.org/wiki/Stop_words)
[![Build Status][travis-image]][travis-url]


## Demo

Live [stopword browser demo](http://fergiemcdowall.github.io/stopword/demo/).

## Usage

### Node.js
```javascript
sw = require('stopword')
// sw.removeStopwords and sw.[language code] now available
```

### Script tag method
```html
<script src="stopword.js"></script>

<script>
// sw.removeStopwords and sw.[language code] now available
</script>
```


### Default (English)
By default, `stopword` will strip an array of "meaningless" English words

Expand Down Expand Up @@ -47,6 +67,19 @@ const newString = sw.removeStopwords(oldString, [ 'even', 'a', 'custom', 'stopwo
## API
### removeStopwords
Returns an Array that represents the text with the specified stopwords removed.
* `text` An array of words
* `stopwords` An array of stopwords
```javascript
sw = require('stopword')
var text = sw.removeStopwords(text[, stopwords])
// text is now an array of given words minus specified stopwords
```
### &lt;language code&gt;
Arrays of stopwords for the following 32 languages are supplied:
Expand Down Expand Up @@ -97,18 +130,6 @@ norwegianStopwords = sw.no
#### Your language missing?
If you can't find a stopword file for your language, you can try creating one with [`stopword-trainer`](https://github.com/eklem/stopword-trainer). We're happy to help you in the process.
### removeStopwords
Returns an Array that represents the text with the specified stopwords removed.
* `text` An array of words
* `stopwords` An array of stopwords
```javascript
sw = require('stopword')
var text = sw.removeStopwords(text[, stopwords])
// text is now an array of given words minus specified stopwords
```
[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
[license-url]: LICENSE
Expand Down
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h1>Stopword demo</h1>
</div>

<div id="addContainer">
<h2>Add text with stopwords</h2>
<h2>Text with stopwords</h2>
<label for="text">Text: </label>
<input type="text" id="text" placeholder="Add some text" /><br />
</div>
Expand Down

0 comments on commit 99c699f

Please sign in to comment.