Re: converting to/from char[]/string

2020-03-05 Thread mark via Digitalmars-d-learn
On Thursday, 5 March 2020 at 13:31:14 UTC, Adam D. Ruppe wrote: On Thursday, 5 March 2020 at 11:03:30 UTC, mark wrote: I want to use the Porter stemming algorithm. There's a D implementation here: https://tartarus.org/martin/PorterStemmer/d.txt I think I (or ketmar and I stole it from him)

Re: converting to/from char[]/string

2020-03-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 5 March 2020 at 11:03:30 UTC, mark wrote: I want to use the Porter stemming algorithm. There's a D implementation here: https://tartarus.org/martin/PorterStemmer/d.txt I think I (or ketmar and I stole it from him) ported that very same file before:

Re: converting to/from char[]/string

2020-03-05 Thread mark via Digitalmars-d-learn
I suspect the problem is using .length rather than some other size property.

Re: converting to/from char[]/string

2020-03-05 Thread mark via Digitalmars-d-learn
I changed int to size_t and used const(char[]) etc. as suggested. It ran but crashed. Each crash was a range violation, so for each one I put in a guard so instead of if ( ... m_b[m_k]) I used if (m_k < m_b.length && ... m_b[m_k) I did this kind of fix in three places. The result is that

Re: converting to/from char[]/string

2020-03-05 Thread Dennis via Digitalmars-d-learn
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

Re: converting to/from char[]/string

2020-03-05 Thread mark via Digitalmars-d-learn
On Thursday, 5 March 2020 at 11:12:24 UTC, drug wrote: On 3/5/20 2:03 PM, mark wrote: [snip] Your code and errors seem to be not related. OK, it is probably that the D stemmer is 19 years old! I've now got Martin Porter's own Java version, so I'll have a go at porting that to D myself.

Re: converting to/from char[]/string

2020-03-05 Thread drug via Digitalmars-d-learn
On 3/5/20 2:03 PM, mark wrote: I want to use the Porter stemming algorithm. There's a D implementation here: https://tartarus.org/martin/PorterStemmer/d.txt The main public function's signature is: char[] stem(char[] p, int i, int j) But I work entirely in terms of strings (containing

converting to/from char[]/string

2020-03-05 Thread mark via Digitalmars-d-learn
I want to use the Porter stemming algorithm. There's a D implementation here: https://tartarus.org/martin/PorterStemmer/d.txt The main public function's signature is: char[] stem(char[] p, int i, int j) But I work entirely in terms of strings (containing individual words), so I want to add