Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug crashes on certain inputs #4

Open
katelee168 opened this issue Jul 15, 2014 · 8 comments
Open

Bug crashes on certain inputs #4

katelee168 opened this issue Jul 15, 2014 · 8 comments

Comments

@katelee168
Copy link

Ex: "eeb"

Though .Stem checks for words shorter than 3 letters before steps 1-4 execute. By the time it reaches step5a eeb becomes e and there is an index out of bounds error.

@reiver
Copy link
Owner

reiver commented Jul 16, 2014

I cannot reproduce your error. Could you please provide some sample code to reproduce the error?


It created a test to try to reproduce this, but cannot.

The test I created (which passes for me) is:

func TestStemStringEeb(t *testing.T) {

    expected := "eeb"

    s := "eeb"
    actual := StemString(s)
    if expected != actual {
        t.Errorf("Input: [%s] -> Actual: [%s]. Expected: [%s]", s, actual, expected)
    }
}

@smhanov
Copy link

smhanov commented Oct 14, 2014

I also get this. I came here to let you know.

The input string that causes the crash for me is "eed"

runtime.panic(0x9415a0, 0xe94bbc)
/usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
github.com/reiver/go-porterstemmer.step5a(0xc20847e090, 0x1, 0x4, 0x0, 0x0, 0x0)
/home/smhanov/canbuy/src/github.com/reiver/go-porterstemmer/porterstemmer.go:792 +0x174
github.com/reiver/go-porterstemmer.StemWithoutLowerCasing(0xc20847e090, 0x1, 0x4, 0x0, 0x0, 0x0)
/home/smhanov/canbuy/src/github.com/reiver/go-porterstemmer/porterstemmer.go:896 +0x196
github.com/reiver/go-porterstemmer.Stem(0xc20847e090, 0x3, 0x4, 0x0, 0x0, 0x0)
/home/smhanov/canbuy/src/github.com/reiver/go-porterstemmer/porterstemmer.go:868 +0xd2
github.com/reiver/go-porterstemmer.StemString(0xc2082d54e8, 0x3, 0x0, 0x0)
/home/smhanov/canbuy/src/github.com/reiver/go-porterstemmer/porterstemmer.go:839 +0x74
dexter.(_searchIndex).stem(0xc208029110, 0xc2082d54c0, 0x35, 0x0, 0x0, 0x0)
/home/smhanov/canbuy/src/dexter/search.go:177 +0x2c0
dexter.(_searchIndex).Add(0xc208029110, 0x1a497a, 0xc2082d5440, 0x35, 0x8f24e0, 0xc208153e00)
/home/smhanov/canbuy/src/dexter/search.go:273 +0xf5
main.func·040(0xc208153e00)
/home/smhanov/canbuy/src/canbuy/main.go:363 +0x6f
main.(*BuyDatabase).Listings(0xc208038110, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/home/smhanov/canbuy/src/canbuy/database.go:220 +0x1dd8
main.StartDex()
/home/smhanov/canbuy/src/canbuy/main.go:368 +0x113
created by main.main
/home/smhanov/canbuy/src/canbuy/main.go:432 +0x4ba

Crash is here:
func step5a(s []rune) []rune {

// Initialize.
    lenS := len(s)
    result := s


// Do it!
    if 'e' == s[lenS-1] {
        lenSuffix := 1

        subSlice := s[:lenS-lenSuffix]

        m := measure(subSlice)

        if 1 < m {
            result = subSlice
>>>>>>>>>>>>>>>>>>>         } else if c := subSlice[len(subSlice)-1] ; 1 == m && !( hasConsonantVowelConsonantSuffix(subSlice) && 'w' != c && 'x' != c && 'y' != c)  {
            result = subSlice
        }
    }


// Return.
    return result

}

@katelee168
Copy link
Author

Yes, anything that is three letters and starts with ee does it for me. Unfortunately, I don't have access to the code I was using this for anymore, so I don't have the error message, but if I recall correctly, it was as smhanov stated.

mschoch added a commit to mschoch/go-porterstemmer that referenced this issue Oct 20, 2014
originally reported in identified by reiver#4
@mschoch mschoch mentioned this issue Oct 20, 2014
@mschoch
Copy link
Contributor

mschoch commented Oct 20, 2014

The test case I added shows that the following inputs result in a panic:

--- FAIL: TestStemFuzz (13.02 seconds)
    porterstemmer_fuzz_test.go:24: StemString panicked for input 'eed'
    porterstemmer_fuzz_test.go:24: StemString panicked for input 'eeds'
    porterstemmer_fuzz_test.go:24: StemString panicked for input 'eing'
    porterstemmer_fuzz_test.go:24: StemString panicked for input 'eings'

mschoch added a commit to blevesearch/go-porterstemmer that referenced this issue Oct 20, 2014
originally reported in identified by reiver#4
@mholt
Copy link

mholt commented Jan 6, 2015

Ah, yeah, I would love to see that PR merged in soon 👍

Also, @smhanov -- I didn't know you were dabbling in Go! (I've mostly seen Python code from your blog.)

@mschoch
Copy link
Contributor

mschoch commented Jan 6, 2015

I'm maintaining a fork now. I don't plan on doing any new development, but I do have an interest in fixing bugs. I have cleaned up a few other things, and put some continuous integration in place.

https://github.com/blevesearch/go-porterstemmer

@mholt
Copy link

mholt commented Jan 9, 2015

@mschoch Thanks, that looks good!

@k1xme
Copy link

k1xme commented Jun 10, 2015

@mschoch very helpful! thanks!

dhowden added a commit to sajari/go-porterstemmer that referenced this issue Feb 2, 2016
Fixed bug mentioned by reiver#4 by applying mschoch/go-porterstemmer/c5e9efb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants