morphological_metrics 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.autotest +30 -30
- data/.gemtest +0 -0
- data/.minitest.rb +3 -3
- data/.travis.yml +10 -10
- data/Gemfile +0 -0
- data/Gemfile.lock +0 -0
- data/History.txt +6 -6
- data/Manifest.txt +27 -27
- data/README.rdoc +65 -66
- data/ROADMAP.txt +63 -63
- data/Rakefile +32 -32
- data/bin/mm +3 -3
- data/lib/mm/deltas.rb +35 -35
- data/lib/mm/metric.rb +180 -191
- data/lib/mm/pairs.rb +12 -11
- data/lib/mm/ratio.rb +145 -148
- data/lib/mm/scaling.rb +30 -27
- data/lib/mm/search.rb +81 -81
- data/lib/mm.rb +10 -11
- data/lib/shortcuts.yml +49 -49
- data/test/helpers.rb +19 -22
- data/test/mm/test_deltas.rb +5 -0
- data/test/mm/test_metric.rb +160 -168
- data/test/mm/test_mm.rb +5 -6
- data/test/mm/test_pairs.rb +24 -27
- data/test/mm/test_ratio.rb +130 -132
- data/test/mm/test_scaling.rb +3 -0
- data/test/mm/test_search.rb +83 -89
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ba2d3ed751029eb26b50499cf4e2d7cc6d70cd0
|
4
|
+
data.tar.gz: 7a3aef67fdfb0a14115b28609d2e51e0463f1e84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9584b0a4c8afeda2a9eb619b4c96303711dfbf8bdbd0aa42701b373c017e9c61e8e19260135527c67e6a03f80531120057e490689708274b342d83aa4f4811c
|
7
|
+
data.tar.gz: d6004665555d21c3089efbe2e8897180bac779e7995dff046ec587af532671d49f1f2c886e09010724b67375da5dcad9900ba0bbeeef5e3814ddc38fb46054b7
|
data/.autotest
CHANGED
@@ -1,30 +1,30 @@
|
|
1
|
-
# -*- ruby -*-
|
2
|
-
|
3
|
-
require "autotest/restart"
|
4
|
-
|
5
|
-
Autotest.add_hook :initialize do |at|
|
6
|
-
at.testlib = ".minitest"
|
7
|
-
#
|
8
|
-
# at.extra_files << "../some/external/dependency.rb"
|
9
|
-
#
|
10
|
-
# at.libs << ":../some/external"
|
11
|
-
#
|
12
|
-
# at.add_exception "vendor"
|
13
|
-
#
|
14
|
-
# at.add_mapping(/dependency.rb/) do |f, _|
|
15
|
-
# at.files_matching(/test_.*rb$/)
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
# %w(TestA TestB).each do |klass|
|
19
|
-
# at.extra_class_map[klass] = "test/test_misc.rb"
|
20
|
-
# end
|
21
|
-
end
|
22
|
-
|
23
|
-
# Autotest.add_hook :run_command do |at|
|
24
|
-
# system "rake build"
|
25
|
-
# end
|
26
|
-
|
27
|
-
Autotest.add_hook :all_good do |at|
|
28
|
-
system "rake rcov_info"
|
29
|
-
end if ENV['RCOV']
|
30
|
-
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require "autotest/restart"
|
4
|
+
|
5
|
+
Autotest.add_hook :initialize do |at|
|
6
|
+
at.testlib = ".minitest"
|
7
|
+
#
|
8
|
+
# at.extra_files << "../some/external/dependency.rb"
|
9
|
+
#
|
10
|
+
# at.libs << ":../some/external"
|
11
|
+
#
|
12
|
+
# at.add_exception "vendor"
|
13
|
+
#
|
14
|
+
# at.add_mapping(/dependency.rb/) do |f, _|
|
15
|
+
# at.files_matching(/test_.*rb$/)
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# %w(TestA TestB).each do |klass|
|
19
|
+
# at.extra_class_map[klass] = "test/test_misc.rb"
|
20
|
+
# end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Autotest.add_hook :run_command do |at|
|
24
|
+
# system "rake build"
|
25
|
+
# end
|
26
|
+
|
27
|
+
Autotest.add_hook :all_good do |at|
|
28
|
+
system "rake rcov_info"
|
29
|
+
end if ENV['RCOV']
|
30
|
+
|
data/.gemtest
CHANGED
File without changes
|
data/.minitest.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
gem "minitest"
|
2
|
-
require "minitest/autorun"
|
3
|
-
|
1
|
+
gem "minitest"
|
2
|
+
require "minitest/autorun"
|
3
|
+
|
data/.travis.yml
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
language: ruby
|
2
|
-
env:
|
3
|
-
- CODECLIMATE_REPO_TOKEN=d05b64cdc405df4f1632a3656a1062ea4873a20ff4463732c47c4d811884fde6
|
4
|
-
rvm:
|
5
|
-
- "2.0.0"
|
6
|
-
- "2.1.2"
|
7
|
-
addons:
|
8
|
-
code_climate:
|
9
|
-
repo_token: d05b64cdc405df4f1632a3656a1062ea4873a20ff4463732c47c4d811884fde6
|
10
|
-
|
1
|
+
language: ruby
|
2
|
+
env:
|
3
|
+
- CODECLIMATE_REPO_TOKEN=d05b64cdc405df4f1632a3656a1062ea4873a20ff4463732c47c4d811884fde6
|
4
|
+
rvm:
|
5
|
+
- "2.0.0"
|
6
|
+
- "2.1.2"
|
7
|
+
addons:
|
8
|
+
code_climate:
|
9
|
+
repo_token: d05b64cdc405df4f1632a3656a1062ea4873a20ff4463732c47c4d811884fde6
|
10
|
+
|
data/Gemfile
CHANGED
Binary file
|
data/Gemfile.lock
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
=== 1.0.0 / 2014-04-09
|
2
|
-
|
3
|
-
* 1 major enhancement
|
4
|
-
|
5
|
-
* Birthday!
|
6
|
-
|
1
|
+
=== 1.0.0 / 2014-04-09
|
2
|
+
|
3
|
+
* 1 major enhancement
|
4
|
+
|
5
|
+
* Birthday!
|
6
|
+
|
data/Manifest.txt
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
.autotest
|
2
|
-
.minitest.rb
|
3
|
-
.travis.yml
|
4
|
-
Gemfile
|
5
|
-
Gemfile.lock
|
6
|
-
History.txt
|
7
|
-
Manifest.txt
|
8
|
-
README.rdoc
|
9
|
-
ROADMAP.txt
|
10
|
-
Rakefile
|
11
|
-
bin/mm
|
12
|
-
lib/mm.rb
|
13
|
-
lib/mm/deltas.rb
|
14
|
-
lib/mm/metric.rb
|
15
|
-
lib/mm/pairs.rb
|
16
|
-
lib/mm/ratio.rb
|
17
|
-
lib/mm/scaling.rb
|
18
|
-
lib/mm/search.rb
|
19
|
-
lib/shortcuts.yml
|
20
|
-
test/helpers.rb
|
21
|
-
test/mm/test_deltas.rb
|
22
|
-
test/mm/test_metric.rb
|
23
|
-
test/mm/test_mm.rb
|
24
|
-
test/mm/test_pairs.rb
|
25
|
-
test/mm/test_ratio.rb
|
26
|
-
test/mm/test_scaling.rb
|
27
|
-
test/mm/test_search.rb
|
1
|
+
.autotest
|
2
|
+
.minitest.rb
|
3
|
+
.travis.yml
|
4
|
+
Gemfile
|
5
|
+
Gemfile.lock
|
6
|
+
History.txt
|
7
|
+
Manifest.txt
|
8
|
+
README.rdoc
|
9
|
+
ROADMAP.txt
|
10
|
+
Rakefile
|
11
|
+
bin/mm
|
12
|
+
lib/mm.rb
|
13
|
+
lib/mm/deltas.rb
|
14
|
+
lib/mm/metric.rb
|
15
|
+
lib/mm/pairs.rb
|
16
|
+
lib/mm/ratio.rb
|
17
|
+
lib/mm/scaling.rb
|
18
|
+
lib/mm/search.rb
|
19
|
+
lib/shortcuts.yml
|
20
|
+
test/helpers.rb
|
21
|
+
test/mm/test_deltas.rb
|
22
|
+
test/mm/test_metric.rb
|
23
|
+
test/mm/test_mm.rb
|
24
|
+
test/mm/test_pairs.rb
|
25
|
+
test/mm/test_ratio.rb
|
26
|
+
test/mm/test_scaling.rb
|
27
|
+
test/mm/test_search.rb
|
data/README.rdoc
CHANGED
@@ -1,66 +1,65 @@
|
|
1
|
-
{<img src="https://codeclimate.com/github/andrewcsmith/mm.png"
|
2
|
-
/>}[https://codeclimate.com/github/andrewcsmith/mm]
|
3
|
-
|
4
|
-
{<img src="https://travis-ci.org/andrewcsmith/mm.svg?branch=master"
|
5
|
-
/>}[https://travis-ci.org/andrewcsmith/mm]
|
6
|
-
|
7
|
-
= mm
|
8
|
-
|
9
|
-
https://www.github.com/andrewcsmith/mm
|
10
|
-
|
11
|
-
== DESCRIPTION:
|
12
|
-
|
13
|
-
Implements some Morphological Metrics, described by Larry Polansky.
|
14
|
-
|
15
|
-
== FEATURES/PROBLEMS:
|
16
|
-
|
17
|
-
* Works on anything Enumerable
|
18
|
-
* Can get a number of different MMs
|
19
|
-
* Works extra fast on large NMatrix objects
|
20
|
-
|
21
|
-
== SYNOPSIS:
|
22
|
-
|
23
|
-
Code sample, LOL
|
24
|
-
|
25
|
-
== REQUIREMENTS:
|
26
|
-
|
27
|
-
* nmatrix
|
28
|
-
* ruby
|
29
|
-
|
30
|
-
== INSTALL:
|
31
|
-
|
32
|
-
* FIX (sudo gem install, anything else)
|
33
|
-
|
34
|
-
== DEVELOPERS:
|
35
|
-
|
36
|
-
After checking out the source, run:
|
37
|
-
|
38
|
-
$ rake newb
|
39
|
-
|
40
|
-
This task will install any missing dependencies, run the tests/specs,
|
41
|
-
and generate the RDoc.
|
42
|
-
|
43
|
-
== LICENSE:
|
44
|
-
|
45
|
-
(The MIT License)
|
46
|
-
|
47
|
-
Copyright (c) 2014 FIX
|
48
|
-
|
49
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
50
|
-
a copy of this software and associated documentation files (the
|
51
|
-
'Software'), to deal in the Software without restriction, including
|
52
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
53
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
54
|
-
permit persons to whom the Software is furnished to do so, subject to
|
55
|
-
the following conditions:
|
56
|
-
|
57
|
-
The above copyright notice and this permission notice shall be
|
58
|
-
included in all copies or substantial portions of the Software.
|
59
|
-
|
60
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
61
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
62
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
63
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
64
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
65
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
66
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
{<img src="https://codeclimate.com/github/andrewcsmith/mm.png"
|
2
|
+
/>}[https://codeclimate.com/github/andrewcsmith/mm]
|
3
|
+
|
4
|
+
{<img src="https://travis-ci.org/andrewcsmith/mm.svg?branch=master"
|
5
|
+
/>}[https://travis-ci.org/andrewcsmith/mm]
|
6
|
+
|
7
|
+
= mm
|
8
|
+
|
9
|
+
https://www.github.com/andrewcsmith/mm
|
10
|
+
|
11
|
+
== DESCRIPTION:
|
12
|
+
|
13
|
+
Implements some Morphological Metrics, described by Larry Polansky.
|
14
|
+
|
15
|
+
== FEATURES/PROBLEMS:
|
16
|
+
|
17
|
+
* Works on anything Enumerable
|
18
|
+
* Can get a number of different MMs
|
19
|
+
* Works extra fast on large NMatrix objects
|
20
|
+
|
21
|
+
== SYNOPSIS:
|
22
|
+
|
23
|
+
Code sample, LOL
|
24
|
+
|
25
|
+
== REQUIREMENTS:
|
26
|
+
|
27
|
+
* nmatrix
|
28
|
+
* ruby
|
29
|
+
|
30
|
+
== INSTALL:
|
31
|
+
|
32
|
+
* FIX (sudo gem install, anything else)
|
33
|
+
|
34
|
+
== DEVELOPERS:
|
35
|
+
|
36
|
+
After checking out the source, run:
|
37
|
+
|
38
|
+
$ rake newb
|
39
|
+
|
40
|
+
This task will install any missing dependencies, run the tests/specs,
|
41
|
+
and generate the RDoc.
|
42
|
+
|
43
|
+
== LICENSE:
|
44
|
+
|
45
|
+
(The MIT License)
|
46
|
+
|
47
|
+
Copyright (c) 2014 FIX
|
48
|
+
|
49
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
50
|
+
a copy of this software and associated documentation files (the
|
51
|
+
'Software'), to deal in the Software without restriction, including
|
52
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
53
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
54
|
+
permit persons to whom the Software is furnished to do so, subject to
|
55
|
+
the following conditions:
|
56
|
+
|
57
|
+
The above copyright notice and this permission notice shall be
|
58
|
+
included in all copies or substantial portions of the Software.
|
59
|
+
|
60
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
61
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
62
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
63
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
64
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
65
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECT
|
data/ROADMAP.txt
CHANGED
@@ -1,63 +1,63 @@
|
|
1
|
-
- Complete functions for getting combinatorial and adjacent pairs
|
2
|
-
- fix any problems with shapes, test more thoroughly
|
3
|
-
- add the ability to recurse throughout an Array tree
|
4
|
-
- Create a selection of distance functions that work with NMatrix etc
|
5
|
-
- These should be implementation-agnostic
|
6
|
-
- Ideally they should be of the symbol/method format, where the user passes a
|
7
|
-
symbol of the method to the metric
|
8
|
-
- Create a Metric class, perhaps as a subclass of Proc
|
9
|
-
- What does it mean to subclass Proc?
|
10
|
-
- Do some research.
|
11
|
-
- What about subclassing Method? What would that give us?
|
12
|
-
- Instead of a "factory" class, the creation of the metric should take place in
|
13
|
-
its initialization.
|
14
|
-
- Metric.new should take arguments similar to DistConfig, but with a
|
15
|
-
specific implementation of OLM, OCM, etc.
|
16
|
-
- This is out of a desire to tie the selection of the logic into the
|
17
|
-
distance function.
|
18
|
-
- However, there could be MM.ocm, MM.olm, etc., functions that are
|
19
|
-
"factories" that call the normal instantiation method. But it should
|
20
|
-
not be possible to create a metric without the DistConfig in instantiation.
|
21
|
-
|
22
|
-
Implementation and interface requirements:
|
23
|
-
- Objects should implement [] and #each
|
24
|
-
- Objects should implement whatever distance method is called by the Metric
|
25
|
-
|
26
|
-
Additional distance functions should (ideally) be in their own gems.
|
27
|
-
|
28
|
-
== Metric Class Methods
|
29
|
-
|
30
|
-
=== ::new(ordering, pairing, scaling, delta)
|
31
|
-
|
32
|
-
Generates a new morphological metric based on various parameters
|
33
|
-
|
34
|
-
**ordered**: can be true or false. Corresponds to ordered/unordered.
|
35
|
-
|
36
|
-
**pairing**: Similar to the delta. If it is a Proc, then the pairing function is
|
37
|
-
called on each vector (or however it is handled by the ordering). If it is a
|
38
|
-
Symbol, then we look it up in MM::PAIRING_FUNCTIONS.
|
39
|
-
|
40
|
-
**scaling**: *always* a Proc. There are prebaked scaling functions for absolute,
|
41
|
-
relative, and unscaled that are available for use. If a Symbol is passed instead
|
42
|
-
of a Proc, it looks for the Proc in the Hash MM::SCALING_FUNCTIONS
|
43
|
-
|
44
|
-
**delta functions**: If it is a Proc, then the delta function is used as d(x, y)
|
45
|
-
on each element. If it is a symbol, then the symbol is first looked up in the
|
46
|
-
MM::DELTA_FUNCTIONS hash. If it is not found, then x.symbol(y) is attempted.
|
47
|
-
Delta functions should aspire to being as general as possible; let the source
|
48
|
-
implement the method.
|
49
|
-
|
50
|
-
**order**: this is confusing terminology - first-order and second-order
|
51
|
-
difference functions.
|
52
|
-
|
53
|
-
**interval functions**: We should instead brew the int_func into the method of
|
54
|
-
finding pairs. This is where the Pairs class might come in handy; it could
|
55
|
-
generate functions (Procs, whatever) as a factory from various values, taking
|
56
|
-
into account what each value should be compared to. It's not [element, element],
|
57
|
-
but [element, comparison-element] that matters.
|
58
|
-
|
59
|
-
=== ::olm(scaling, delta)
|
60
|
-
|
61
|
-
Generates a new morphological metric calling ::new with the given ordering and
|
62
|
-
pairing
|
63
|
-
|
1
|
+
- Complete functions for getting combinatorial and adjacent pairs
|
2
|
+
- fix any problems with shapes, test more thoroughly
|
3
|
+
- add the ability to recurse throughout an Array tree
|
4
|
+
- Create a selection of distance functions that work with NMatrix etc
|
5
|
+
- These should be implementation-agnostic
|
6
|
+
- Ideally they should be of the symbol/method format, where the user passes a
|
7
|
+
symbol of the method to the metric
|
8
|
+
- Create a Metric class, perhaps as a subclass of Proc
|
9
|
+
- What does it mean to subclass Proc?
|
10
|
+
- Do some research.
|
11
|
+
- What about subclassing Method? What would that give us?
|
12
|
+
- Instead of a "factory" class, the creation of the metric should take place in
|
13
|
+
its initialization.
|
14
|
+
- Metric.new should take arguments similar to DistConfig, but with a
|
15
|
+
specific implementation of OLM, OCM, etc.
|
16
|
+
- This is out of a desire to tie the selection of the logic into the
|
17
|
+
distance function.
|
18
|
+
- However, there could be MM.ocm, MM.olm, etc., functions that are
|
19
|
+
"factories" that call the normal instantiation method. But it should
|
20
|
+
not be possible to create a metric without the DistConfig in instantiation.
|
21
|
+
|
22
|
+
Implementation and interface requirements:
|
23
|
+
- Objects should implement [] and #each
|
24
|
+
- Objects should implement whatever distance method is called by the Metric
|
25
|
+
|
26
|
+
Additional distance functions should (ideally) be in their own gems.
|
27
|
+
|
28
|
+
== Metric Class Methods
|
29
|
+
|
30
|
+
=== ::new(ordering, pairing, scaling, delta)
|
31
|
+
|
32
|
+
Generates a new morphological metric based on various parameters
|
33
|
+
|
34
|
+
**ordered**: can be true or false. Corresponds to ordered/unordered.
|
35
|
+
|
36
|
+
**pairing**: Similar to the delta. If it is a Proc, then the pairing function is
|
37
|
+
called on each vector (or however it is handled by the ordering). If it is a
|
38
|
+
Symbol, then we look it up in MM::PAIRING_FUNCTIONS.
|
39
|
+
|
40
|
+
**scaling**: *always* a Proc. There are prebaked scaling functions for absolute,
|
41
|
+
relative, and unscaled that are available for use. If a Symbol is passed instead
|
42
|
+
of a Proc, it looks for the Proc in the Hash MM::SCALING_FUNCTIONS
|
43
|
+
|
44
|
+
**delta functions**: If it is a Proc, then the delta function is used as d(x, y)
|
45
|
+
on each element. If it is a symbol, then the symbol is first looked up in the
|
46
|
+
MM::DELTA_FUNCTIONS hash. If it is not found, then x.symbol(y) is attempted.
|
47
|
+
Delta functions should aspire to being as general as possible; let the source
|
48
|
+
implement the method.
|
49
|
+
|
50
|
+
**order**: this is confusing terminology - first-order and second-order
|
51
|
+
difference functions.
|
52
|
+
|
53
|
+
**interval functions**: We should instead brew the int_func into the method of
|
54
|
+
finding pairs. This is where the Pairs class might come in handy; it could
|
55
|
+
generate functions (Procs, whatever) as a factory from various values, taking
|
56
|
+
into account what each value should be compared to. It's not [element, element],
|
57
|
+
but [element, comparison-element] that matters.
|
58
|
+
|
59
|
+
=== ::olm(scaling, delta)
|
60
|
+
|
61
|
+
Generates a new morphological metric calling ::new with the given ordering and
|
62
|
+
pairing
|
63
|
+
|
data/Rakefile
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
# -*- ruby -*-
|
2
|
-
|
3
|
-
require "rubygems"
|
4
|
-
require "hoe"
|
5
|
-
|
6
|
-
# Hoe.plugin :compiler
|
7
|
-
# Hoe.plugin :gem_prelude_sucks
|
8
|
-
# Hoe.plugin :racc
|
9
|
-
# Hoe.plugin :rcov
|
10
|
-
Hoe.plugin :flay
|
11
|
-
Hoe.plugin :flog
|
12
|
-
|
13
|
-
Hoe.plugin :travis
|
14
|
-
Hoe.plugin :inline
|
15
|
-
Hoe.plugin :minitest
|
16
|
-
Hoe.plugin :package
|
17
|
-
|
18
|
-
hoe = Hoe.spec "morphological_metrics" do |h|
|
19
|
-
developer("Andrew C. Smith", "andrewchristophersmith@gmail.com")
|
20
|
-
license "MIT" # this should match the license in the README
|
21
|
-
self.readme_file = "README.rdoc"
|
22
|
-
require_rubygems_version '>= 1.4'
|
23
|
-
end
|
24
|
-
|
25
|
-
if ENV['CODECLIMATE_REPO_TOKEN']
|
26
|
-
hoe.test_prelude = <<CC
|
27
|
-
require "codeclimate-test-reporter"
|
28
|
-
CodeClimate::TestReporter.start
|
29
|
-
CC
|
30
|
-
end
|
31
|
-
|
32
|
-
# vim: syntax=ruby
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "hoe"
|
5
|
+
|
6
|
+
# Hoe.plugin :compiler
|
7
|
+
# Hoe.plugin :gem_prelude_sucks
|
8
|
+
# Hoe.plugin :racc
|
9
|
+
# Hoe.plugin :rcov
|
10
|
+
Hoe.plugin :flay
|
11
|
+
Hoe.plugin :flog
|
12
|
+
|
13
|
+
Hoe.plugin :travis
|
14
|
+
Hoe.plugin :inline
|
15
|
+
Hoe.plugin :minitest
|
16
|
+
Hoe.plugin :package
|
17
|
+
|
18
|
+
hoe = Hoe.spec "morphological_metrics" do |h|
|
19
|
+
developer("Andrew C. Smith", "andrewchristophersmith@gmail.com")
|
20
|
+
license "MIT" # this should match the license in the README
|
21
|
+
self.readme_file = "README.rdoc"
|
22
|
+
require_rubygems_version '>= 1.4'
|
23
|
+
end
|
24
|
+
|
25
|
+
if ENV['CODECLIMATE_REPO_TOKEN']
|
26
|
+
hoe.test_prelude = <<CC
|
27
|
+
require "codeclimate-test-reporter"
|
28
|
+
CodeClimate::TestReporter.start
|
29
|
+
CC
|
30
|
+
end
|
31
|
+
|
32
|
+
# vim: syntax=ruby
|
data/bin/mm
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
abort "you need to write me"
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
abort "you need to write me"
|
data/lib/mm/deltas.rb
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
module MM
|
2
|
-
module Deltas
|
3
|
-
def self.abs n
|
4
|
-
(n[0] - n[1]).abs
|
5
|
-
end
|
6
|
-
|
7
|
-
def self.diff n
|
8
|
-
n[0] - n[1]
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.mean n
|
12
|
-
n.inject(0.0, :+) / n.size
|
13
|
-
end
|
14
|
-
|
15
|
-
# Have to scale by 0.5 in order to normalize to a max distance of 1.0
|
16
|
-
def self.direction n
|
17
|
-
(n[0] <=> n[1]) * 0.5
|
18
|
-
end
|
19
|
-
|
20
|
-
# Accepts a tuple where the quotient responds to #numerator and #denominator
|
21
|
-
def self.tenney n
|
22
|
-
->(r) { Math.log2(r.numerator * r.denominator) }.call(n[0] / n[1])
|
23
|
-
end
|
24
|
-
|
25
|
-
# Accepts a tuple of anything that Math.log2 can handle
|
26
|
-
def self.log_ratio n
|
27
|
-
Math.log2((n[0] / n[1]).to_f).abs
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.ratio n
|
31
|
-
n[0] / n[1]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
1
|
+
module MM
|
2
|
+
module Deltas
|
3
|
+
def self.abs n
|
4
|
+
(n[0] - n[1]).abs
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.diff n
|
8
|
+
n[0] - n[1]
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.mean n
|
12
|
+
n.inject(0.0, :+) / n.size
|
13
|
+
end
|
14
|
+
|
15
|
+
# Have to scale by 0.5 in order to normalize to a max distance of 1.0
|
16
|
+
def self.direction n
|
17
|
+
(n[0] <=> n[1]) * 0.5
|
18
|
+
end
|
19
|
+
|
20
|
+
# Accepts a tuple where the quotient responds to #numerator and #denominator
|
21
|
+
def self.tenney n
|
22
|
+
->(r) { Math.log2(r.numerator * r.denominator) }.call(n[0] / n[1])
|
23
|
+
end
|
24
|
+
|
25
|
+
# Accepts a tuple of anything that Math.log2 can handle
|
26
|
+
def self.log_ratio n
|
27
|
+
Math.log2((n[0] / n[1]).to_f).abs
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.ratio n
|
31
|
+
n[0] / n[1]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|