From 4013339bfdf92e7a5bc7bc3e3124188632f0a9f6 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Mon, 18 Jan 2016 16:39:03 -0500 Subject: [PATCH] add fuzy match --- Gemfile | 1 + Gemfile.lock | 2 ++ script/check-approval | 12 ++++++++++++ 3 files changed, 15 insertions(+) diff --git a/Gemfile b/Gemfile index 8379c51..57fd539 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ gem "jekyll-seo-tag" group :development do gem 'colored' gem 'terminal-table' + gem 'fuzzy_match' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index e299b1e..5c91e2b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -26,6 +26,7 @@ GEM multipart-post (>= 1.2, < 3) fast-stemmer (1.0.2) ffi (1.9.10) + fuzzy_match (2.1.0) gemoji (2.1.0) github-pages (43) RedCloth (= 4.2.9) @@ -167,6 +168,7 @@ PLATFORMS DEPENDENCIES colored + fuzzy_match github-pages html-proofer (= 2.5.2) jekyll-seo-tag diff --git a/script/check-approval b/script/check-approval index bd3a575..d34a950 100755 --- a/script/check-approval +++ b/script/check-approval @@ -6,6 +6,7 @@ require_relative '../spec/spec_helper' require 'terminal-table' require 'colored' +require 'fuzzy_match' # Display usage instructions if ARGV.count != 1 @@ -56,3 +57,14 @@ rows << ["Eligible", eligible] puts Terminal::Table.new title: "License: #{license}", rows: rows puts puts "Code search: https://github.com/search?q=#{license}+filename%3ALICENSE&type=Code" + +if spdx.nil? + puts + puts "SPDX ID not found. Some possible matches:" + puts + + fm = FuzzyMatch.new(spdx_ids) + matches = fm.find_all_with_score(license) + matches = matches[0...5].map { |record, _dice, _levin| record } + matches.each { |l| puts "* #{l}" } +end