tonytonyjan / jaro_winkler

Ruby & C implementation of Jaro-Winkler distance algorithm which supports UTF-8 string.
MIT License
195 stars 29 forks source link

`JaroWinkler.c_distance` aborted #10

Closed hanachin closed 9 years ago

hanachin commented 9 years ago

Following code cause error in Ruby 2.2.3 and JaroWinkler 1.3.6

require 'jaro_winkler'

JaroWinkler.c_distance("In that case, you can set the `config.force_ssl` in your environment file.", "In this guide you will learn how controllers work and how they fit into the request cycle in your application.")

Reproduce code: https://github.com/hanachin/jaro_winkler_sample https://travis-ci.org/hanachin/jaro_winkler_sample

tonytonyjan commented 9 years ago

@hanachin I guess it's buffer issue, not verified yet. https://github.com/tonytonyjan/jaro_winkler/blob/a2ee3bde6377fbbd368b93513b4367921a078dc3/ext/jaro_winkler/jaro.h#L5

hanachin commented 9 years ago

@tonytonyjan thanks for quick response :+1:

tonytonyjan commented 9 years ago

BTW, since Jaro–Winkler distance is designed and best suited for short strings such as person names, that's why I define a small number as length limitation.

I wonder what kind of application are you building? Your sample strings are quite long.

tonytonyjan commented 9 years ago

BTW, since Jaro–Winkler distance is designed and best suited for short strings such as person names, that's why I define a small number as length limitation.

I wonder what kind of application are you building? Your sample strings are quite long.

hanachin commented 9 years ago

I'm finding translated sentences from sentences translated previously.

BTW, since Jaro–Winkler distance is designed and best suited for short strings such as person names, that's why I define a small number as length limitation.

I missed that :see_no_evil: My application uses even more long strings, I should change the algorithm :stuck_out_tongue: Thank you for letting me know.

tonytonyjan commented 9 years ago

@hanachin I've merged your pull request, thanks for contribution. But I soon found a better way to do it. Because Variable-length automatic arrays are allowed in C99, we can easily replace the macro with variable.

cheers :beers:

hanachin commented 9 years ago

:beers: :hibiscus: