On Thursday, 5 March 2020 at 11:31:43 UTC, mark wrote:
I've now got Martin Porter's own Java version, so I'll have a go at porting that to D myself.

I don't think that's necessary, the errors seem easy to fix.

src/porterstemmer.d(197,13): Error: cannot implicitly convert expression s.length of type ulong to int src/porterstemmer.d(222,9): Error: cannot implicitly convert expression cast(ulong)this.m_j + s.length of type ulong to int

These errors are probably because the code was only compiled on 32-bit targets where .length is of type `uint`, but you are compiling on 64-bit where .length is of type `ulong`. A quick fix is to simply cast the result like `cast(int) s.length` and `cast(int) (this.m_j + s.length)`, though a proper fix would be to change the types of variables to `long`, `size_t`, `auto` or `const` (depending on which is most appropriate).

src/porterstemmer.d(259,12): Error: function porterstemmer.PorterStemmer.ends(char[] s) is not callable using argument types (string) src/porterstemmer.d(259,12): cannot pass argument "sses" of type string to parameter char[] s

These errors are because `string` is `immutable(char)[]`, meaning the characters may not be modified, while the function accepts a `char[]` which is allowed to mutate the characters. I don't think the functions actually do that, so you can simply change `char[]` into `const(char)[]` so a string can be passed to those functions.

Reply via email to