from deltas.segmenters import ParagraphsSentencesAndWhitespace from deltas import sequence_matcher, segment_matcher import sys sys.path.insert(0, ".") a = ["This", "is", "a", "sentence", ".", " ", "This", "isn't", "a", "sentence", "."] b = ["This", "isn't", "a", "sentence", ".", " ", "This", "is", "a", "sentence", "."] print("Comparing:") print(" - A: {0}".format(a)) print(" - B: {0}".format(b)) print("\n") print("Longest common substring:") for operation in sequence_matcher.diff(a, b): print("--> " + str(operation)) print("\n") print("Segment matcher:") for operation in segment_matcher.diff( a, b, segmenter=ParagraphsSentencesAndWhitespace()): print("--> " + str(operation))
import sys;sys.path.insert(0, ".") from deltas import sequence_matcher, segment_matcher from deltas.segmenters import ParagraphsSentencesAndWhitespace a = ["This", "is", "a", "sentence", ".", " ", "This", "isn't", "a", "sentence", "."] b = ["This", "isn't", "a", "sentence", ".", " ", "This", "is", "a", "sentence", "."] print("Comparing:") print(" - A: {0}".format(a)) print(" - B: {0}".format(b)) print("\n") print("Longest common substring:") for operation in sequence_matcher.diff(a,b): print("--> " + str(operation)) print("\n") print("Segment matcher:") for operation in segment_matcher.diff(a,b, segmenter=ParagraphsSentencesAndWhitespace()): print("--> " + str(operation))
def sequence_random(): start = time.time() for _ in range(25): operations = list(sequence_matcher.diff(random1_tokens, random2_tokens)) print("\trandom: {0}".format((time.time() - start)/25))
def sequence_common(): start = time.time() for _ in range(25): operations = list(sequence_matcher.diff(common1_tokens, common2_tokens)) print("\tcommon: {0}".format((time.time() - start)/25))
def sequence_random(): start = time.time() for _ in range(25): operations = list(sequence_matcher.diff(random1_tokens, random2_tokens)) print("\trandom: {0}".format((time.time() - start) / 25))
def sequence_common(): start = time.time() for _ in range(25): operations = list(sequence_matcher.diff(common1_tokens, common2_tokens)) print("\tcommon: {0}".format((time.time() - start) / 25))