java-diff-utils

简介: java-diff-utils

谁终将声震人间,必长久深自缄默;谁终将点燃闪电,必长久如云漂泊。——尼采

https://github.com/java-diff-utils/java-diff-utils

Diff Utils库是一个开源库,用于在文本或某种数据之间执行比较/差异操作:计算差异,应用补丁,生成统一差异或解析它们,生成差异输出以便将来显示(如并排视图)等。

例如:

//create a configured DiffRowGenerator
DiffRowGenerator generator = DiffRowGenerator.create()
                .showInlineDiffs(true)
                .mergeOriginalRevised(true)
                .inlineDiffByWord(true)
                .oldTag(f -> "~")      //introduce markdown style for strikethrough
                .newTag(f -> "**")     //introduce markdown style for bold
                .build();
//compute the differences for two test texts.
List<DiffRow> rows = generator.generateDiffRows(
                Arrays.asList("This is a test senctence."),
                Arrays.asList("This is a test for diffutils."));
System.out.println(rows.get(0).getOldLine());

会得到:This is a test senctencefor diffutils.

还可以使用并排视图:

DiffRowGenerator generator = DiffRowGenerator.create()
                .showInlineDiffs(true)
                .inlineDiffByWord(true)
                .oldTag(f -> "~")
                .newTag(f -> "**")
                .build();
List<DiffRow> rows = generator.generateDiffRows(
                Arrays.asList("This is a test senctence.", "This is the second line.", "And here is the finish."),
                Arrays.asList("This is a test for diffutils.", "This is the second line."));
System.out.println("|original|new|");
System.out.println("|--------|---|");
for (DiffRow row : rows) {
    System.out.println("|" + row.getOldLine() + "|" + row.getNewLine() + "|");
}
original new
This is a test senctence. This is a test for diffutils.
This is the second line. This is the second line.
~And here is the finish.~

引入:

相关文章
|
安全 Java 数据安全/隐私保护
SpringBoot实现二维码扫码登录的原理与详细步骤
SpringBoot实现二维码扫码登录的原理与详细步骤
1667 1
|
11月前
|
SQL 运维 关系型数据库
智能数据库运维大脑 DAS Agent 使用全攻略
智能数据库运维大脑 DAS Agent 使用全攻略
|
前端开发 JavaScript Java
java实现文件对比
基于java实现类似于svn的文件对比功能及效果,该对比适用于html,js,css,text等
java实现文件对比
|
Java 开发工具 git
微服务配置管理:Spring Cloud Config 实践指南
微服务配置管理:Spring Cloud Config 实践指南
|
人工智能 监控 API
狂揽22.6k星!这个开源工具让你一键调用100+大模型,开发效率直接起飞!
LiteLLM是由BerriAI团队开发的开源项目,通过标准化OpenAI格式API接口,支持调用100+主流大语言模型(如OpenAI、Azure、Anthropic等)。其核心功能包括统一调用方式、企业级智能路由、异步流式响应及环境变量管理。项目适用于企业AI中台搭建、多模型对比测试、教育科研实验等场景。技术架构涵盖接口层、路由层、管理层与监控层,提供高效稳定的服务。相比LangChain、LlamaIndex等项目,LiteLLM在多平台混合开发方面优势显著。项目地址:https://github.com/BerriAI/litellm。
3343 2

热门文章

最新文章