pocketberserker / diff.match.patch Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Please make DiffLinesToChars
and DiffCharsToLines
methods public so it would be possible to do a line diff as described here https://github.com/google/diff-match-patch/wiki/Line-or-Word-Diffs.
I'd like to use this great library to help with failing unit tests comparing expected/actual string values.
I'd like the diff to be pretty printed pretty much like github shows with each line prefixed with + and - and few lines of context around each diff.
I figured out how to use the library to get the list of diff but couldn't figure out how to implement the appropriate pretty-printing to do what I described.
I'd appreciate minimal code sample to do that!
I am comparing two string
problem is that not get expected output
when I enter run time:
This is my testing for matching algoritham - first string
This is my testing for matchings algoritham for application by website - second string
see my output:
when I remove the is keyword then I dont want to display in param1:
what I want to:
testing matching
testings matchings
WebForm1.aspx.cs
protected void Button1_Click(object sender, EventArgs e)
{
if (IsPostBack)
{
Label1.Text = "";
Label2.Text = "";
}
var slist = stextbox.Text.Split(' ');
var flist = ftextbox.Text.Split(' ');
int minWordCount = Math.Min(slist.Length, flist.Length);
var diffWords = slist.Take(minWordCount).Where(x => flist.Contains(x) == false).ToList();
var diffWordsf = flist.Take(minWordCount).Where(x => slist.Contains(x) == false).ToList();
Label2.Text = "param2:" + string.Join(" ", diffWords);
Label1.Text = "param1:" + string.Join(" ", diffWordsf);
}
}
.aspx
<asp:TextBox ID="ftextbox" runat="server" TextMode="MultiLine" Width="500px" Height="200px"></asp:TextBox>
<asp:TextBox ID="stextbox" runat="server" TextMode="MultiLine" Width="500px" Height="200px"></asp:TextBox>
please help
The code requires the FSharp.Core library which hasn't been referenced after adding Diff.Match.Patch to my project using NuGet.
There might be a missing dependency information in the .nuspec file.
This example throws an exception. Version is 2.0.1 from NuGet. The exception is System.ArgumentException: Invalid patch string: @@ -5,12 +5,18 @@
const string text1 = "this is some example text";
const string text2 = "this is not really example text";
var patches = DiffMatchPatchModule.Default.PatchMake(text1, text2);
var patchString = DiffMatchPatchModule.Default.PatchToText(patches);
var roundtrip = DiffMatchPatchModule.Default.PatchFromText(patchString);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.