waltsmith88 / go-flashtext

Go-flashtext is a flashtext implement written in Go (Golang). It is based on the FlashText algorithm.
https://arxiv.org/abs/1711.00046
MIT License
18 stars 5 forks source link

Full sub-pattern not matched #1

Open IFtech-A opened 3 years ago

IFtech-A commented 3 years ago

I do not know if this is an implementation issue or a feature. Full sub-patterns are not matched if the text contains the pattern.

Test code

package main

import (
        "fmt"
        gf "github.com/waltsmith88/go-flashtext"
        "os"
)

func main() {

        keywordProcessor := gf.NewKeywordProcessor()
        keywordProcessor.AddKeywordsFromList([]string{"retractable", "able"})

        cleanNameList := keywordProcessor.ExtractKeywords("it is so retractable")
        fmt.Printf("Found %v keywords\n", len(cleanNameList))
        for _, keyword := range cleanNameList {
                fmt.Fprintf(os.Stderr, "%v\n", keyword)
        }
}

Expected result

Found 2 keywords
retractable
able

Result

Found 1 keywords
retractable
code-innovator-zyx commented 1 year ago

I do not know if this is an implementation issue or a feature. Full sub-patterns are not matched if the text contains the pattern.

Test code

package main

import (
        "fmt"
        gf "github.com/waltsmith88/go-flashtext"
        "os"
)

func main() {

        keywordProcessor := gf.NewKeywordProcessor()
        keywordProcessor.AddKeywordsFromList([]string{"retractable", "able"})

        cleanNameList := keywordProcessor.ExtractKeywords("it is so retractable")
        fmt.Printf("Found %v keywords\n", len(cleanNameList))
        for _, keyword := range cleanNameList {
                fmt.Fprintf(os.Stderr, "%v\n", keyword)
        }
}

Expected result

Found 2 keywords
retractable
able

Result

Found 1 keywords
retractable

This requires you to do the participle matching yourself