Closed batakpout closed 5 years ago
I just found the fix, your imports are wrong, in ur scala example its mentioned as
import com.github.vickumar1981.stringdistance.StringDistance. import com.github.vickumar1981.stringdistance.StringSound.
It should be
import com.github.vickumar1981.stringdistance.util.StringDistance. import com.github.vickumar1981.stringdistance.util.StringSound.
👍 thanks for bringing this to my attention. I'll take a look at the scala examples later tonight.
The util
package is specifically for Java, so if you have a java project, you should use that. If you are using scala, however, the other packages should work (I could have missed an import somewhere though).
For the 1st scala example, can you try importing:
import com.github.vickumar1981.stringdistance.implicits._
that's the package where all the implicit definitions live:
Thanks again for bringing this up. I'm on EST, so around 6-7 tonight, I'll be looking at it if it's not resolved.
Thanks for the quick response, I have tried all the options even import com.github.vickumar1981.stringdistance.implicits. is also not working, finally I settled with import com.github.vickumar1981.stringdistance.StringDistance. looks like you have missed something, please look into this.
Thanks
@aamir-f I pushed up a 1.1.0
build (and a 1.1.0-SNAPSHOT
if you don't want to wait) which should be up on maven shortly that updates/fixes the bugs. Also, updated the README.md
with working instructions.
Specifically, I found out what wasn't working were the scoring algorithms that required an extra parameter to them. Cosine.score(s1, s2, regEx)
is the signature of the function, where regex is how you want to split up the strings - either treating them as a word, or as a sentence. These parameters are now required for the implementations that need them. (With 1.1.1
you can go back to treating them optionally, the examples in the README
are only for pointing out explicitly that these parameters exist)
Other examples are Jaccard.score(s1, s2, nGrams)
where nGrams
is how you want to tokenize strings s1
and s2
for comparison.
If you want to bypass setting up some of the extra parameters, you can also use the 2nd usage:
import com.github.vickumar1981.stringdistance.StringConverter._
val cosSimilarity: Double = "hello" cosine "chello"
I tried to update the docs to reflect this, but I'm sure they still need work. Let me know if you're still having issues, and thank you again for opening the issue.
@aamir-f is it okay to close this issue?
I'm creating a simple Test program to test ur Scala code, I am facing implicit issues, I tried various thing but is working, here is my sample code
import com.github.vickumar1981.stringdistance.StringDistance._
object test extends App {
val res = Cosine.score("aamir", "rimaa") } Its expecting implicit in scope, I simply copied from example from https://github.com/vickumar1981/stringdistance
this is the error message its giving: Error:(8, 38) ambiguous reference to overloaded definition, both method score in trait StringMetric of type (s1: String, s2: String)(implicit algo: com.github.vickumar1981.stringdistance.SoundScoringAlgorithm[com.github.vickumar1981.stringdistance.CosineAlgorithm])Boolean and method score in trait StringMetric of type (s1: String, s2: String)(implicit algo: com.github.vickumar1981.stringdistance.ScoringAlgorithm[com.github.vickumar1981.stringdistance.CosineAlgorithm])Double match argument types (String,String) val cosSimilarity: Double = Cosine.score("hello", "chello")() // 0.935
there you haven't mentioned any implicit usage or importing any implicit. Please look into this.