Sha256: b2493d9a4ebdb3e6961be697280f830e6998105922629c121a4d2b1cc1239640
Contents?: true
Size: 936 Bytes
Versions: 2
Compression:
Stored size: 936 Bytes
Contents
module Plagiarism module Strategies class Engine THRESHOLD = 0.8 attr_accessor :content, :params class << self def fetch(content, params) raise end def valid_segments(ps, params) ps.segment.count do |sentence| typhoeus = fetch("\"#{sentence}\"", params) typhoeus.success? && exists?(typhoeus.response_body) end end def exists?(response) raise end def whitelists_regex whitelists = Config.whitelists.map { |w| Regexp.new w } Regexp.union whitelists end end def initialize(c, p) @content, @params = c, p end def unique? ps = PragmaticSegmenter::Segmenter.new(text: content) valid_segments = self.class.valid_segments(ps, params) valid_segments / ps.segment.size >= THRESHOLD end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
plagiarism2-0.0.5 | lib/plagiarism/strategries/engine.rb |
plagiarism2-0.0.4 | lib/plagiarism/strategries/engine.rb |