package com.yqt.yqt.entity;
/*
* Diff Match and Patch
*
* Copyright 2006 Google Inc.
* http://code.google.com/p/google-diff-match-patch/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/*
* Functions for diff, match and patch.
* Computes the difference between two texts to create a patch.
* Applies the patch onto another text, allowing for errors.
*
* @author fraser@google.com (Neil Fraser)
*/
/**
* Class containing the diff, match and patch methods.
* Also contains the behaviour settings.
*/
public class DiffMatchPatch {
// Defaults.
// Set these on your diff_match_patch instance to override the defaults.
/**
* Number of seconds to map a diff before giving up (0 for infinity).
*/
public float Diff_Timeout = 1.0f;
/**
* Cost of an empty edit operation in terms of edit characters.
*/
public short Diff_EditCost = 4;
/**
* The size beyond which the double-ended diff activates.
* Double-ending is twice as fast, but less accurate.
*/
public short Diff_DualThreshold = 32;
/**
* At what point is no match declared (0.0 = perfection, 1.0 = very loose).
*/
public float Match_Threshold = 0.5f;
/**
* How far to search for a match (0 = exact location, 1000+ = broad match).
* A match this many characters away from the expected location will add
* 1.0 to the score (0.0 is a perfect match).
*/
public int Match_Distance = 1000;
/**
* When deleting a large block of text (over ~64 characters), how close does
* the contents have to match the expected contents. (0.0 = perfection,
* 1.0 = very loose). Note that Match_Threshold controls how closely the
* end points of a delete need to match.
*/
public float Patch_DeleteThreshold = 0.5f;
/**
* Chunk size for context length.
*/
public short Patch_Margin = 4;
/**
* The number of bits in an int.
*/
private int Match_MaxBits = 32;
/**
* Internal class for returning results from diff_linesToChars().
* Other less paranoid languages just use a three-element array.
*/
protected static class LinesToCharsResult {
protected String chars1;
protected String chars2;
protected List<String> lineArray;
protected LinesToCharsResult(String chars1, String chars2,
List<String> lineArray) {
this.chars1 = chars1;
this.chars2 = chars2;
this.lineArray = lineArray;
}
}
// DIFF FUNCTIONS
/**
* The data structure representing a diff is a Linked list of Diff objects:
* {Diff(Operation.DELETE, "Hello"), Diff(Operation.INSERT, "Goodbye"),
* Diff(Operation.EQUAL, " world.")}
* which means: delete "Hello", add "Goodbye" and keep " world."
*/
public enum Operation {
DELETE, INSERT, EQUAL
}
/**
* Find the differences between two texts.
* Run a faster slightly less optimal diff
* This method allows the 'checklines' of diff_main() to be optional.
* Most of the time checklines is wanted, so default to true.
* @param text1 Old string to be diffed.
* @param text2 New string to be diffed.
* @return Linked List of Diff objects.
*/
public LinkedList<Diff> diff_main(String text1, String text2) {
return diff_main(text1, text2, true);
}
/**
* Find the differences between two texts. Simplifies the problem by
* stripping any common prefix or suffix off the texts before diffing.
* @param text1 Old string to be diffed.
* @param text2 New string to be diffed.
* @param checklines Speedup flag. If false, then don't run a
* line-level diff first to identify the changed areas.
* If true, then run a faster slightly less optimal diff
* @return Linked List of Diff objects.
*/
public LinkedList<Diff> diff_main(String text1, String text2, boolean checklines) {
// Check for equality (speedup)
LinkedList<Diff> diffs;
if (text1.equals(text2)) {
diffs = new LinkedList<Diff>();
diffs.add(new Diff(Operation.EQUAL, text1));
return diffs;
}
// Trim off common prefix (speedup)
int commonlength = diff_commonPrefix(text1, text2);
String commonprefix = text1.substring(0, commonlength);
text1 = text1.substring(commonlength);
text2 = text2.substring(commonlength);
// Trim off common suffix (speedup)
commonlength = diff_commonSuffix(text1, text2);
String commonsuffix = text1.substring(text1.length() - commonlength);
text1 = text1.substring(0, text1.length() - commonlength);
text2 = text2.substring(0, text2.length() - commonlength);
// Compute the diff on the middle block
diffs = diff_compute(text1, text2, checklines);
// Restore the prefix and suffix
if (commonprefix.length() != 0) {
diffs.addFirst(new Diff(Operation.EQUAL, commonprefix));
}
if (commonsuffix.length() != 0) {
diffs.addLast(new Diff(Operation.EQUAL, commonsuffix));
}
diff_cleanupMerge(diffs);
return diffs;
}
/**
* Find the differences between two texts. Assumes that the texts do not
* have any common prefix or suffix.
* @param text1 Old string to be diffed.
* @param text2 New string to be diffed.
* @param checklines Speedup flag. If false, then don't run a
* line-level diff first to identify the changed areas.
* If true, then run a faster slightly less optimal diff
* @return Linked List of Diff objects.
*/
protected LinkedList<Diff> diff_compute(String text1, String text2,boolean checklines) {
LinkedList<Diff> diffs = new LinkedList<Diff>();
if (text1.length() == 0) {
// Just add some text (speedup)
diffs.add(new Diff(Operation.INSERT, text2));
return diffs;
}
if (text2.length() == 0) {
// Just delete some text (speedup)
diffs.add(new Diff(Operation.DELETE, text1));
return diffs;
}
String longtext = text1.length() > text2.length() ? text1 : text2;
String shorttext = text1.length() > text2.length() ? text2 : text1;
int i = longtext.indexOf(shorttext);
if (i != -1) {
// Shorter text is inside the longer text (speedup)
Operation op = (text1.length() > text2.length()) ?
Operation.DELETE : Operation.INSERT;
diffs.add(new Diff(op, longtext.substring(0, i)));
diffs.add(new Diff(Operation.EQUAL, shorttext));
diffs.add(new Diff(op, longtext.substring(i + shorttext.length())));
return diffs;
}
longtext = shorttext = null; // Garbage collect.
// Check to see if the problem can be split in two.
String[] hm = diff_halfMatch(text1, text2);
if (hm != null) {
// A half-match was found, sort out the return data.
String text1_a = hm
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
免费的自然语言处理、情感分析、实体识别、图像识别与分类、OCR识别、语音识别接口,功能强大。思通数科利用自然语言处理技术,让计算机具备对网页、文件、文本、声音、图像的阅读能力,帮助客户自动化处理海量文本数据,打造一系列NLP技术工具集或场景化方案,提升文字处理效率和文本挖掘深度,降低人工成本。同时可做到定制化,本地部署、低成本、接入快速、将网页、文件、文本、声音、图像中的文本进行结构化的处理,支持通过文本挖掘技术实现内容标签提取、文本自动分类等功能,全方位构建企业级数据库与内容画像
资源推荐
资源详情
资源评论
收起资源包目录
免费的自然语言处理、情感分析、实体识别、图像识别与分类、OCR识别、语音识别接口,功能强大 (607个子文件)
category 105B
mvnw.cmd 7KB
style.min.css 605KB
bootstrap.css 231KB
bootstrap.min.css 230KB
bootstrap-dark.css 229KB
bootstrap-dark.min.css 228KB
app-rtl.css 125KB
app-rtl.min.css 97KB
layui.css 80KB
app.css 79KB
app-dark.css 75KB
app.min.css 74KB
custom.css 73KB
icons.css 68KB
app-dark.min.css 61KB
icons.min.css 53KB
anychart-ui.min.css 34KB
summernote-bs4.css 18KB
flatpickr.min.css 16KB
select2.min.css 15KB
main.min.css 14KB
layer.css 14KB
anychart-font.min.css 11KB
dropzone.min.css 9KB
bootstrap-colorpicker.min.css 9KB
index.css 8KB
laydate.css 8KB
pointAnnotations.css 6KB
public.css 6KB
login.css 5KB
dataTables.bootstrap4.min.css 5KB
buttons.bootstrap4.min.css 4KB
select.bootstrap4.min.css 4KB
index.css 4KB
imageAnnotations.css 4KB
responsive.bootstrap4.min.css 4KB
index.css 4KB
faceSearch.css 4KB
smart_wizard.min.css 3KB
main.min.css 3KB
smart_wizard_theme_arrows.min.css 3KB
index.css 3KB
index.css 3KB
videoDetect.css 3KB
index.css 3KB
index.css 3KB
smart_wizard_theme_dots.min.css 3KB
index.css 3KB
adddataset.css 2KB
voiceRecognize.css 2KB
imageDetect.css 2KB
faceDetect.css 2KB
selfdefineImage.css 2KB
targetDetect.css 2KB
index.css 2KB
multi-select.css 2KB
addData.css 2KB
smart_wizard_theme_circles.min.css 2KB
backstage.css 2KB
index.css 2KB
index.css 2KB
index.css 2KB
index.css 2KB
index.css 2KB
index.css 2KB
objectDetail.css 2KB
code.css 2KB
objectDetail.css 2KB
objectDetail.css 2KB
objectDetail.css 2KB
voiceSynthesis.css 2KB
index.css 2KB
index.css 1KB
index.css 1KB
datebase.css 1KB
privateGPT.css 1KB
bootstrap-tagsinput.css 1KB
index.css 1KB
objectDetail.css 1KB
objectDetail.css 1KB
index.css 1KB
backstage.css 1KB
backstage.css 1KB
index.css 1KB
index.css 1KB
detail.css 1KB
addData.css 1KB
index.css 1KB
index.css 1KB
main.min.css 1KB
index.css 1KB
imageAnnotations.css 1KB
index.css 1KB
index.css 1021B
index.css 1021B
main.min.css 1004B
common.css 928B
index.css 916B
multiLabelMark.css 908B
共 607 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
- m0_720950202024-05-18资源有很好的参考价值,总算找到了自己需要的资源啦。
Java程序员-张凯
- 粉丝: 1w+
- 资源: 7451
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- C#源码 上位机 联合Visionpro 通用框架开发源码,已应用于多个项目,整套设备程序,可以根据需求编出来,具体Vpp功能自己编 程序包含功能 1.自动设置界面窗体个数及分布 2.照方式以命令触
- 程序名称:悬架设计计算程序 开发平台:基于matlab平台 计算内容:悬架偏频刚度挠度;螺旋弹簧,多片簧,少片簧,稳定杆,减震器的匹配计算;悬架垂向纵向侧向力学、纵倾、侧倾校核等;独立悬架杠杆比,等效
- 华为OD+真题及解析+智能驾驶
- jQuery信息提示插件
- 基于stm32的通信系统,sim800c与服务器通信,无线通信监测,远程定位,服务器通信系统,gps,sim800c,心率,温度,stm32 由STM32F103ZET6单片机核心板电路、DS18B2
- 充电器检测9-YOLO(v5至v11)、COCO、Create充电器检测9L、Paligemma、TFRecord、VOC数据集合集.rar
- 华为OD+考试真题+实现过程
- 保险箱检测51-YOLO(v5至v11)、COCO、CreateML、Paligemma、TFRecord、VOC数据集合集.rar
- 五相电机邻近四矢量SVPWM模型-MATLAB-Simulink仿真模型包括: (1)原理说明文档(重要):包括扇区判断、矢量作用时间计算、矢量作用顺序及切时间计算、PWM波的生成; (2)输出部分仿
- 一对一MybatisProgram.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功