comparateur 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/a.rb +11 -0
- data/lib/comparateur/version.rb +1 -1
- data/lib/comparateur.rb +4 -4
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29c929d2e8f2a89a4a4a36bcd412819a0feaf171
|
4
|
+
data.tar.gz: 4287a132f615bb35cff1c4e49da0697387aae91d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad03801f73f44f3e89d95d9591f569f7eb7a82f3e89f3512e6d88d00a3a8b3aaefdd1a4721a1514e583ea38e9300bb183225f766d9380d70541a93c638a14950
|
7
|
+
data.tar.gz: 883479951d98d6409d6637e05141f8c078c42dc9f766c20a9408bfd80758c2c493ce37f941d754fbca607d0c0d80e52de6bc08b6ba2443efb1982d00d6d1d00d
|
data/README.md
CHANGED
@@ -26,7 +26,11 @@ exp = Le::Comparateur.new
|
|
26
26
|
a = "<html><body></body></html>"
|
27
27
|
b = "<html><body><h1></h1></body></html>"
|
28
28
|
|
29
|
-
|
29
|
+
c = Nokogiri::HTML("<html><body></body></html>")
|
30
|
+
d = a
|
31
|
+
|
32
|
+
p exp.calculate_similarity(a, b) * 100 # in %
|
33
|
+
p exp.calculate_similarity(c, d)
|
30
34
|
```
|
31
35
|
|
32
36
|
## Contributing
|
data/a.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
load "lib/comparateur.rb"
|
2
|
+
|
3
|
+
exp = Le::Comparateur.new
|
4
|
+
|
5
|
+
#site1 = Nokogiri::HTML("<html><body><h1></h1><h2></h2></body></html>")
|
6
|
+
|
7
|
+
|
8
|
+
site1 = ["html", "body"]
|
9
|
+
site2 = Nokogiri::HTML("<html><body></body></html>")
|
10
|
+
|
11
|
+
p exp.calculate_similarity(site1, site2)
|
data/lib/comparateur/version.rb
CHANGED
data/lib/comparateur.rb
CHANGED
@@ -6,11 +6,11 @@ module Le
|
|
6
6
|
class Comparateur
|
7
7
|
|
8
8
|
def calculate_similarity site1, site2
|
9
|
-
|
10
|
-
|
9
|
+
site1 = Nokogiri::HTML(site1) unless site1.is_a?(Nokogiri::HTML::Document)
|
10
|
+
site2 = Nokogiri::HTML(site2) unless site2.is_a?(Nokogiri::HTML::Document)
|
11
11
|
|
12
|
-
arr_site1 =
|
13
|
-
arr_site2 =
|
12
|
+
arr_site1 = site1.search('*').map(&:name)
|
13
|
+
arr_site2 = site2.search('*').map(&:name)
|
14
14
|
lcs = Diff::LCS.LCS(arr_site1, arr_site2)
|
15
15
|
|
16
16
|
return (2.0 * lcs.length.to_f) / (arr_site1.length.to_f + arr_site2.length.to_f)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comparateur
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Radu-Bogdan Croitoru
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- LICENSE.txt
|
79
79
|
- README.md
|
80
80
|
- Rakefile
|
81
|
+
- a.rb
|
81
82
|
- comparateur.gemspec
|
82
83
|
- lib/comparateur.rb
|
83
84
|
- lib/comparateur/version.rb
|