-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a85367e
Showing
11 changed files
with
533 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/.bundle/ | ||
/.yardoc | ||
/_yardoc/ | ||
/coverage/ | ||
/doc/ | ||
/pkg/ | ||
/spec/reports/ | ||
/tmp/ |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
source 'https://rubygems.org' | ||
|
||
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } | ||
|
||
gemspec |
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require 'bundler/gem_tasks' | ||
task default: :spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'bundler/setup' | ||
require 'crawler/movie' | ||
|
||
require 'irb' | ||
IRB.start(__FILE__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
set -vx | ||
|
||
bundle install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
lib = File.expand_path('../lib', __FILE__) | ||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | ||
require 'crawler/core/version' | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = 'crawler-core' | ||
spec.version = Crawler::Core::VERSION | ||
spec.authors = ['Jonathan PHILIPPE'] | ||
spec.email = ['jonathan@cinema.paris'] | ||
|
||
spec.summary = %q{} | ||
spec.description = %q{} | ||
spec.homepage = 'https://crawler.cinema.paris' | ||
spec.license = 'CC-BY-SA-4.0' | ||
|
||
if spec.respond_to?(:metadata) | ||
spec.metadata['homepage_uri'] = spec.homepage | ||
spec.metadata['source_code_uri'] = 'https://github.com/cinema-paris/crawler-core' | ||
spec.metadata['changelog_uri'] = 'https://github.com/cinema-paris/crawler-core/CHANGELOG.md' | ||
end | ||
|
||
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do | ||
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } | ||
end | ||
spec.bindir = 'exe' | ||
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } | ||
spec.require_paths = ['lib'] | ||
|
||
spec.add_development_dependency 'bundler', '~> 1.17' | ||
spec.add_development_dependency 'rake', '~> 10.0' | ||
spec.add_runtime_dependency 'activesupport', '>= 3.0' | ||
spec.add_runtime_dependency 'levenshtein-ffi', '>= 1.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'active_support/concern' | ||
require 'active_support/inflector' | ||
require 'levenshtein-ffi' | ||
|
||
module Crawler | ||
module Base | ||
extend ActiveSupport::Concern | ||
|
||
class_methods do | ||
def add_provider(provider_name, options = {}) | ||
raise NotImplementedError | ||
end | ||
|
||
def configure | ||
yield self | ||
end | ||
|
||
def transliterate(string) | ||
ActiveSupport::Inflector.transliterate(string.gsub(/[:\-.,!?]/, ' ').strip.gsub(/\s+/, ' '), nil).downcase | ||
end | ||
|
||
def levenshtein_score(string_1, string_2) | ||
string_1_transliterated = transliterate(string_1) | ||
string_2_transliterated = transliterate(string_2) | ||
levenshtein_distance = Levenshtein.distance(string_1_transliterated, string_2_transliterated) | ||
max_size = [string_1_transliterated.size, string_2_transliterated.size].max.to_f | ||
|
||
(max_size - levenshtein_distance) / max_size | ||
end | ||
|
||
def search(*args) | ||
raise NotImplementedError | ||
end | ||
|
||
def best(*args) | ||
raise NotImplementedError | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Crawler | ||
module Core | ||
VERSION = '0.1.0' | ||
end | ||
end |