|
1 | | -# stmr(1) [](https://travis-ci.org/wooorm/stmr.c) [](https://coveralls.io/r/wooorm/stmr.c?branch=master) |
| 1 | +# stmr([3](http://en.wikipedia.org/wiki/Man_page#Manual_sections)) [](https://travis-ci.org/wooorm/stmr.c) [](https://coveralls.io/r/wooorm/stmr.c?branch=master) |
2 | 2 |
|
3 | | -Martin Porter’s Stemming algorithm<sup>[1](http://tartarus.org/martin/PorterStemmer/)</sup>. |
| 3 | +Martin Porter’s Stemming algorithm<sup>[1](http://tartarus.org/martin/PorterStemmer/)</sup> as a C library. There’s also a CLI: [stmr(1)](https://github.com/wooorm/stmr). |
4 | 4 |
|
5 | | -In fact, this is just a refactored version of the [initial ANCI C implementation](http://tartarus.org/martin/PorterStemmer/c.txt), with a nice CLI. |
| 5 | +In fact, this is just a refactored version of the [initial ANCI C implementation](http://tartarus.org/martin/PorterStemmer/c.txt). |
6 | 6 |
|
7 | 7 | ## Installation |
8 | 8 |
|
9 | | -``` |
10 | | -$ make install |
11 | | -``` |
12 | | - |
13 | 9 | CLib: |
14 | | -``` |
| 10 | +```sh |
15 | 11 | $ clib install wooorm/stmr.c |
16 | 12 | ``` |
17 | 13 |
|
18 | | -## Usage |
19 | | - |
20 | | -``` |
21 | | - Usage: stmr [options] file |
| 14 | +Ore clone the repo. |
22 | 15 |
|
23 | | - Options: |
| 16 | +## Usage |
24 | 17 |
|
25 | | - -h, --help output usage information |
26 | | - -v, --version output version number |
27 | | - -e, --eval string output stemmed word |
| 18 | +### int stem(char *pointer, int start, int end); |
28 | 19 |
|
29 | | - Usage: |
| 20 | +```c |
| 21 | +#include <stdio.h> |
| 22 | +#include <string.h> |
| 23 | +#include "stmr.h" |
30 | 24 |
|
31 | | - # stem a word |
32 | | - $ stmr -e nationalism |
33 | | - # nation |
| 25 | +int |
| 26 | +main(int argc, char **argv) { |
| 27 | + char *word = argv[1]; |
34 | 28 |
|
35 | | - # print stems |
36 | | - $ stmr in.txt |
| 29 | + int end = stem(word, 0, strlen(word) - 1); |
37 | 30 |
|
38 | | - # write stems to out.txt |
39 | | - $ stmr in.txt > out.txt |
| 31 | + word[end + 1] = 0; |
40 | 32 |
|
41 | | - # stdin and stdout |
42 | | - $ echo "Internationalise" | stmr |
43 | | - # internationalis |
| 33 | + printf("%s", word); |
| 34 | +} |
44 | 35 | ``` |
45 | 36 |
|
46 | 37 | ## License |
47 | 38 |
|
48 | | -MIT © Titus Wormer |
| 39 | +MIT © [Titus Wormer](http://wooorm.com) |
0 commit comments