snowballstem / snowball

Snowball compiler and stemming algorithms
https://snowballstem.org/
BSD 3-Clause "New" or "Revised" License
748 stars 173 forks source link

Migrate from older version #199

Closed c-seeger closed 1 month ago

c-seeger commented 1 month ago

I try to fix an old go project that uses snowball as a dependency and has the following line of code

var c = env.ByteIndexForHop(-(2))
if int32(env.LimitBackward) > c || c > int32(env.Limit) {
› break lab2
}
env.Cursor = int(c)

with env *snowballRuntime.Env the function env.ByteIndexForHop seems not to exist anymore and is breaking the code. Whats the proper way to migrate this code?

c-seeger commented 1 month ago

Since I have no clue what i'm doing here, i found the following commit introduced the change and was not marked as a major version change: https://github.com/snowballstem/snowball/commit/bb54ae9c9d1618439b6fb707c8a1c0b9364e74e9

If i understand it correctly the following change should work:

 if !env.Hop(-(2)) {
 › break lab2
 }
c-seeger commented 1 month ago

feel free to close the issue and leave it as some documentation in case if someone hits the same issue

ojwb commented 1 month ago

You should use the Go support code from the same snowball version you used to generate the Go stemmer sources. The interface to the Go support code is essentially an internal implementation detail, hence no major version bump for changes to its interface. If you do that you shouldn't need to mess around with manually adjusting the generated code (which is liable to be error prone).