Similar
Constants
Class methods
Creates a diff between old and new with the given algorithm capturing the ops.
This is like diff but instead of using an
arbitrary hook this will always use Compact + Replace + Capture
and return the captured DiffOps.
Creates a diff between old and new with the given algorithm capturing the ops.
Works like capture_diff but with an optional deadline.
Creates a diff between old and new with the given algorithm capturing the ops.
Creates a diff between old and new with the given algorithm capturing the ops.
Works like capture_diff_slices but with an optional deadline.
Return a list of the best "good enough" matches.
word is a sequence for which close matches are desired (typically a string). possibilities is a list of sequences against which to match word (typically a list of strings). n (default 3) is the maximum number of close matches to return; n must be greater than 0. cutoff (default 0.6) is a float in the range [0, 1]. Possibilities that don't score at least that similar to word are ignored.
require "similar"
matches = Similar.get_close_matches("appel", ["ape", "apple", "peach", "puppy"], 3, 0.6)
matches.should eq(["apple", "ape"])
Requires the text feature.
Return a measure of similarity in the range 0..=1.
A ratio of 1.0 means the two sequences are a complete match, a
ratio of 0.0 would indicate completely distinct sequences. The input
is the sequence of diff operations and the length of the old and new
sequence.
Isolate change clusters by eliminating ranges with no changes.
This will leave holes behind in long periods of equal ranges so that you can build things like unified diffs.
Nested types
- Similar::Algorithm
- Similar::Algorithms
- Similar::AllChangesIter(Old, New, T)
- Similar::BytesWrapper
- Similar::Change(T)
- Similar::ChangeTag
- Similar::ChangesIter(Old, New, T)
- Similar::DeadlineSupport
- Similar::DiffHook
- Similar::DiffOp
- Similar::DiffTag
- Similar::DiffableStr
- Similar::InlineChange
- Similar::MissingNewlineHint
- Similar::StringWrapper
- Similar::Text
- Similar::TextDiff(T)
- Similar::TextDiffConfig
- Similar::UnifiedDiff(T)
- Similar::UnifiedDiffHunk(T)
- Similar::UnifiedDiffHunkRange
- Similar::UnifiedHunkHeader
- Similar::Utils