levenshtein_ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/Makefile +261 -0
- data/README.md +41 -0
- data/Rakefile +11 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/ext/levenshtein_ruby/extconf.rb +2 -0
- data/ext/levenshtein_ruby/levenshtein_ruby.c +60 -0
- data/levenshtein_ruby.gemspec +34 -0
- data/lib/levenshtein_ruby.rb +5 -0
- data/lib/levenshtein_ruby/version.rb +3 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f9f817f4c065ce80aedfdf5b721aba39ffba44bd
|
4
|
+
data.tar.gz: 0db84cb04de9d0415bded2881f2f7542d430c693
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e5449958dd08763332fd4c8d4eaf6b8b0d03a4c55a7d0968da2efb4eb3c87301aa02e2ffc815dc604fd52d20f35ae4cb8286fa72f98415a948e73d8092c013c5
|
7
|
+
data.tar.gz: 3e10b5d78145948f31d3269db55e90ac04734219a3511ec74b38ae3e32513e6ca1d2cb57d474d5fe0e7fa1eed60c9722d225cbbc7d8af21478219200f622f9e3
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at ttattataa@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 meriy100
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/Makefile
ADDED
@@ -0,0 +1,261 @@
|
|
1
|
+
|
2
|
+
SHELL = /bin/sh
|
3
|
+
|
4
|
+
# V=0 quiet, V=1 verbose. other values don't work.
|
5
|
+
V = 0
|
6
|
+
Q1 = $(V:1=)
|
7
|
+
Q = $(Q1:0=@)
|
8
|
+
ECHO1 = $(V:1=@:)
|
9
|
+
ECHO = $(ECHO1:0=@echo)
|
10
|
+
NULLCMD = :
|
11
|
+
|
12
|
+
#### Start of system configuration section. ####
|
13
|
+
|
14
|
+
srcdir = .
|
15
|
+
topdir = /Users/meriy100/.rbenv/versions/2.3.0/include/ruby-2.3.0
|
16
|
+
hdrdir = $(topdir)
|
17
|
+
arch_hdrdir = /Users/meriy100/.rbenv/versions/2.3.0/include/ruby-2.3.0/x86_64-darwin15
|
18
|
+
PATH_SEPARATOR = :
|
19
|
+
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
|
20
|
+
prefix = $(DESTDIR)/Users/meriy100/.rbenv/versions/2.3.0
|
21
|
+
rubysitearchprefix = $(rubylibprefix)/$(sitearch)
|
22
|
+
rubyarchprefix = $(rubylibprefix)/$(arch)
|
23
|
+
rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
|
24
|
+
exec_prefix = $(prefix)
|
25
|
+
vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
|
26
|
+
sitearchhdrdir = $(sitehdrdir)/$(sitearch)
|
27
|
+
rubyarchhdrdir = $(rubyhdrdir)/$(arch)
|
28
|
+
vendorhdrdir = $(rubyhdrdir)/vendor_ruby
|
29
|
+
sitehdrdir = $(rubyhdrdir)/site_ruby
|
30
|
+
rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
|
31
|
+
vendorarchdir = $(vendorlibdir)/$(sitearch)
|
32
|
+
vendorlibdir = $(vendordir)/$(ruby_version)
|
33
|
+
vendordir = $(rubylibprefix)/vendor_ruby
|
34
|
+
sitearchdir = $(sitelibdir)/$(sitearch)
|
35
|
+
sitelibdir = $(sitedir)/$(ruby_version)
|
36
|
+
sitedir = $(rubylibprefix)/site_ruby
|
37
|
+
rubyarchdir = $(rubylibdir)/$(arch)
|
38
|
+
rubylibdir = $(rubylibprefix)/$(ruby_version)
|
39
|
+
sitearchincludedir = $(includedir)/$(sitearch)
|
40
|
+
archincludedir = $(includedir)/$(arch)
|
41
|
+
sitearchlibdir = $(libdir)/$(sitearch)
|
42
|
+
archlibdir = $(libdir)/$(arch)
|
43
|
+
ridir = $(datarootdir)/$(RI_BASE_NAME)
|
44
|
+
mandir = $(datarootdir)/man
|
45
|
+
localedir = $(datarootdir)/locale
|
46
|
+
libdir = $(exec_prefix)/lib
|
47
|
+
psdir = $(docdir)
|
48
|
+
pdfdir = $(docdir)
|
49
|
+
dvidir = $(docdir)
|
50
|
+
htmldir = $(docdir)
|
51
|
+
infodir = $(datarootdir)/info
|
52
|
+
docdir = $(datarootdir)/doc/$(PACKAGE)
|
53
|
+
oldincludedir = $(DESTDIR)/usr/include
|
54
|
+
includedir = $(SDKROOT)$(prefix)/include
|
55
|
+
localstatedir = $(prefix)/var
|
56
|
+
sharedstatedir = $(prefix)/com
|
57
|
+
sysconfdir = $(prefix)/etc
|
58
|
+
datadir = $(datarootdir)
|
59
|
+
datarootdir = $(prefix)/share
|
60
|
+
libexecdir = $(exec_prefix)/libexec
|
61
|
+
sbindir = $(exec_prefix)/sbin
|
62
|
+
bindir = $(exec_prefix)/bin
|
63
|
+
archdir = $(rubyarchdir)
|
64
|
+
|
65
|
+
|
66
|
+
CC = clang
|
67
|
+
CXX = clang++
|
68
|
+
LIBRUBY = $(LIBRUBY_A)
|
69
|
+
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
70
|
+
LIBRUBYARG_SHARED =
|
71
|
+
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static -framework CoreFoundation
|
72
|
+
empty =
|
73
|
+
OUTFLAG = -o $(empty)
|
74
|
+
COUTFLAG = -o $(empty)
|
75
|
+
|
76
|
+
RUBY_EXTCONF_H =
|
77
|
+
cflags = $(optflags) $(debugflags) $(warnflags)
|
78
|
+
cxxflags = $(optflags) $(debugflags) $(warnflags)
|
79
|
+
optflags = -O3 -fno-fast-math
|
80
|
+
debugflags = -ggdb3
|
81
|
+
warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens
|
82
|
+
CCDLFLAGS = -fno-common
|
83
|
+
CFLAGS = $(CCDLFLAGS) -O3 -Wno-error=shorten-64-to-32 -pipe $(ARCH_FLAG)
|
84
|
+
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
|
85
|
+
DEFS =
|
86
|
+
CPPFLAGS = -I/Users/meriy100/.rbenv/versions/2.3.0/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT $(DEFS) $(cppflags)
|
87
|
+
CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
|
88
|
+
ldflags = -L. -L/Users/meriy100/.rbenv/versions/2.3.0/lib -fstack-protector -L/usr/local/lib
|
89
|
+
dldflags = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress
|
90
|
+
ARCH_FLAG =
|
91
|
+
DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
|
92
|
+
LDSHARED = $(CC) -dynamic -bundle
|
93
|
+
LDSHAREDXX = $(CXX) -dynamic -bundle
|
94
|
+
AR = ar
|
95
|
+
EXEEXT =
|
96
|
+
|
97
|
+
RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
|
98
|
+
RUBY_SO_NAME = ruby
|
99
|
+
RUBYW_INSTALL_NAME =
|
100
|
+
RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
|
101
|
+
RUBYW_BASE_NAME = rubyw
|
102
|
+
RUBY_BASE_NAME = ruby
|
103
|
+
|
104
|
+
arch = x86_64-darwin15
|
105
|
+
sitearch = $(arch)
|
106
|
+
ruby_version = 2.3.0
|
107
|
+
ruby = $(bindir)/$(RUBY_BASE_NAME)
|
108
|
+
RUBY = $(ruby)
|
109
|
+
ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
|
110
|
+
|
111
|
+
RM = rm -f
|
112
|
+
RM_RF = $(RUBY) -run -e rm -- -rf
|
113
|
+
RMDIRS = rmdir -p
|
114
|
+
MAKEDIRS = mkdir -p
|
115
|
+
INSTALL = /usr/bin/install -c
|
116
|
+
INSTALL_PROG = $(INSTALL) -m 0755
|
117
|
+
INSTALL_DATA = $(INSTALL) -m 644
|
118
|
+
COPY = cp
|
119
|
+
TOUCH = exit >
|
120
|
+
|
121
|
+
#### End of system configuration section. ####
|
122
|
+
|
123
|
+
preload =
|
124
|
+
|
125
|
+
libpath = . $(libdir)
|
126
|
+
LIBPATH = -L. -L$(libdir)
|
127
|
+
DEFFILE =
|
128
|
+
|
129
|
+
CLEANFILES = mkmf.log
|
130
|
+
DISTCLEANFILES =
|
131
|
+
DISTCLEANDIRS =
|
132
|
+
|
133
|
+
extout =
|
134
|
+
extout_prefix =
|
135
|
+
target_prefix =
|
136
|
+
LOCAL_LIBS =
|
137
|
+
LIBS = -lpthread -ldl -lobjc
|
138
|
+
ORIG_SRCS = levenshtein_ruby.c
|
139
|
+
SRCS = $(ORIG_SRCS)
|
140
|
+
OBJS = levenshtein_ruby.o
|
141
|
+
HDRS =
|
142
|
+
TARGET = levenshtein_ruby
|
143
|
+
TARGET_NAME = levenshtein_ruby
|
144
|
+
TARGET_ENTRY = Init_$(TARGET_NAME)
|
145
|
+
DLLIB = $(TARGET).bundle
|
146
|
+
EXTSTATIC =
|
147
|
+
STATIC_LIB =
|
148
|
+
|
149
|
+
TIMESTAMP_DIR = .
|
150
|
+
BINDIR = $(bindir)
|
151
|
+
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
152
|
+
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
153
|
+
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
154
|
+
HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
|
155
|
+
ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
|
156
|
+
|
157
|
+
TARGET_SO = $(DLLIB)
|
158
|
+
CLEANLIBS = $(TARGET).bundle
|
159
|
+
CLEANOBJS = *.o *.bak
|
160
|
+
|
161
|
+
all: $(DLLIB)
|
162
|
+
static: $(STATIC_LIB) install-rb
|
163
|
+
.PHONY: all install static install-so install-rb
|
164
|
+
.PHONY: clean clean-so clean-static clean-rb
|
165
|
+
|
166
|
+
clean-static::
|
167
|
+
clean-rb-default::
|
168
|
+
clean-rb::
|
169
|
+
clean-so::
|
170
|
+
clean: clean-so clean-static clean-rb-default clean-rb
|
171
|
+
-$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
|
172
|
+
|
173
|
+
distclean-rb-default::
|
174
|
+
distclean-rb::
|
175
|
+
distclean-so::
|
176
|
+
distclean-static::
|
177
|
+
distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
|
178
|
+
-$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
179
|
+
-$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
180
|
+
-$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
|
181
|
+
|
182
|
+
realclean: distclean
|
183
|
+
install: install-so install-rb
|
184
|
+
|
185
|
+
install-so: $(DLLIB) $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
|
186
|
+
$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
|
187
|
+
clean-static::
|
188
|
+
-$(Q)$(RM) $(STATIC_LIB)
|
189
|
+
install-rb: pre-install-rb install-rb-default
|
190
|
+
install-rb-default: pre-install-rb-default
|
191
|
+
pre-install-rb: Makefile
|
192
|
+
pre-install-rb-default: Makefile
|
193
|
+
pre-install-rb-default:
|
194
|
+
@$(NULLCMD)
|
195
|
+
$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
|
196
|
+
$(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
|
197
|
+
$(Q) $(TOUCH) $@
|
198
|
+
|
199
|
+
site-install: site-install-so site-install-rb
|
200
|
+
site-install-so: install-so
|
201
|
+
site-install-rb: install-rb
|
202
|
+
|
203
|
+
.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
|
204
|
+
|
205
|
+
.cc.o:
|
206
|
+
$(ECHO) compiling $(<)
|
207
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
208
|
+
|
209
|
+
.cc.S:
|
210
|
+
$(ECHO) translating $(<)
|
211
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
|
212
|
+
|
213
|
+
.mm.o:
|
214
|
+
$(ECHO) compiling $(<)
|
215
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
216
|
+
|
217
|
+
.mm.S:
|
218
|
+
$(ECHO) translating $(<)
|
219
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
|
220
|
+
|
221
|
+
.cxx.o:
|
222
|
+
$(ECHO) compiling $(<)
|
223
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
224
|
+
|
225
|
+
.cxx.S:
|
226
|
+
$(ECHO) translating $(<)
|
227
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
|
228
|
+
|
229
|
+
.cpp.o:
|
230
|
+
$(ECHO) compiling $(<)
|
231
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
232
|
+
|
233
|
+
.cpp.S:
|
234
|
+
$(ECHO) translating $(<)
|
235
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
|
236
|
+
|
237
|
+
.c.o:
|
238
|
+
$(ECHO) compiling $(<)
|
239
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
|
240
|
+
|
241
|
+
.c.S:
|
242
|
+
$(ECHO) translating $(<)
|
243
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
|
244
|
+
|
245
|
+
.m.o:
|
246
|
+
$(ECHO) compiling $(<)
|
247
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
|
248
|
+
|
249
|
+
.m.S:
|
250
|
+
$(ECHO) translating $(<)
|
251
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
|
252
|
+
|
253
|
+
$(DLLIB): $(OBJS) Makefile
|
254
|
+
$(ECHO) linking shared-object $(DLLIB)
|
255
|
+
-$(Q)$(RM) $(@)
|
256
|
+
$(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
|
257
|
+
$(Q) $(POSTLINK)
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
$(OBJS): $(HDRS) $(ruby_headers)
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# LevenshteinRuby
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/levenshtein_ruby`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'levenshtein_ruby'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install levenshtein_ruby
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/levenshtein_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "levenshtein_ruby"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
#include <stdio.h>
|
2
|
+
#include <ruby.h>
|
3
|
+
|
4
|
+
VALUE cLevenshtein;
|
5
|
+
|
6
|
+
|
7
|
+
VALUE distance_func(VALUE self, VALUE s_word1, VALUE s_word2)
|
8
|
+
{
|
9
|
+
char* word1 = StringValuePtr(s_word1);
|
10
|
+
char* word2 = StringValuePtr(s_word2);
|
11
|
+
int len1 = strlen(word1);
|
12
|
+
int len2 = strlen(word2);
|
13
|
+
int matrix[len1 + 1][len2 + 1];
|
14
|
+
int i;
|
15
|
+
for (i = 0; i <= len1; i++) {
|
16
|
+
matrix[i][0] = i;
|
17
|
+
}
|
18
|
+
for (i = 0; i <= len2; i++) {
|
19
|
+
matrix[0][i] = i;
|
20
|
+
}
|
21
|
+
for (i = 1; i <= len1; i++) {
|
22
|
+
int j;
|
23
|
+
char c1;
|
24
|
+
|
25
|
+
c1 = word1[i-1];
|
26
|
+
for (j = 1; j <= len2; j++) {
|
27
|
+
char c2;
|
28
|
+
|
29
|
+
c2 = word2[j-1];
|
30
|
+
if (c1 == c2) {
|
31
|
+
matrix[i][j] = matrix[i-1][j-1];
|
32
|
+
}
|
33
|
+
else {
|
34
|
+
int delete;
|
35
|
+
int insert;
|
36
|
+
int substitute;
|
37
|
+
int minimum;
|
38
|
+
|
39
|
+
delete = matrix[i-1][j] + 1;
|
40
|
+
insert = matrix[i][j-1] + 1;
|
41
|
+
substitute = matrix[i-1][j-1] + 1;
|
42
|
+
minimum = delete;
|
43
|
+
if (insert < minimum) {
|
44
|
+
minimum = insert;
|
45
|
+
}
|
46
|
+
if (substitute < minimum) {
|
47
|
+
minimum = substitute;
|
48
|
+
}
|
49
|
+
matrix[i][j] = minimum;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
return INT2NUM(matrix[len1][len2]);
|
54
|
+
}
|
55
|
+
|
56
|
+
void Init_levenshtein_ruby()
|
57
|
+
{
|
58
|
+
cLevenshtein = rb_define_class("Levenshtein", rb_cObject);
|
59
|
+
rb_define_method(cLevenshtein, "distance", RUBY_METHOD_FUNC(distance_func), 2);
|
60
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'levenshtein_ruby/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "levenshtein_ruby"
|
8
|
+
spec.version = LevenshteinRuby::VERSION
|
9
|
+
spec.authors = ["meriy100"]
|
10
|
+
spec.email = ["ttattataa@gmail.com"]
|
11
|
+
|
12
|
+
spec.description = %q{Levenshtein distance}
|
13
|
+
spec.summary = %q{Levenshtein distance}
|
14
|
+
spec.homepage = "https://github.com/meriy100/levenshtein_ruby"
|
15
|
+
spec.license = "MIT"
|
16
|
+
spec.extensions = %w[ext/levenshtein_ruby/extconf.rb]
|
17
|
+
|
18
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
20
|
+
# if spec.respond_to?(:metadata)
|
21
|
+
# spec.metadata['allowed_push_host'] = "https://github.com/meriy100/levenshtein_ruby"
|
22
|
+
# else
|
23
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
24
|
+
# end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
32
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
33
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: levenshtein_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- meriy100
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Levenshtein distance
|
56
|
+
email:
|
57
|
+
- ttattataa@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions:
|
60
|
+
- ext/levenshtein_ruby/extconf.rb
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- CODE_OF_CONDUCT.md
|
67
|
+
- Gemfile
|
68
|
+
- LICENSE.txt
|
69
|
+
- Makefile
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- bin/console
|
73
|
+
- bin/setup
|
74
|
+
- ext/levenshtein_ruby/extconf.rb
|
75
|
+
- ext/levenshtein_ruby/levenshtein_ruby.c
|
76
|
+
- levenshtein_ruby.gemspec
|
77
|
+
- lib/levenshtein_ruby.rb
|
78
|
+
- lib/levenshtein_ruby/version.rb
|
79
|
+
homepage: https://github.com/meriy100/levenshtein_ruby
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.5.1
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: Levenshtein distance
|
103
|
+
test_files: []
|
104
|
+
has_rdoc:
|