Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
-
#
|
| 2 |
-
# 実行方法: python
|
| 3 |
|
| 4 |
import re
|
| 5 |
import difflib
|
|
@@ -169,6 +169,7 @@ def filter_opcodes(opcodes):
|
|
| 169 |
else:
|
| 170 |
is_diff.append(True)
|
| 171 |
|
|
|
|
| 172 |
for idx in range(n):
|
| 173 |
if ops[idx][0] == 'equal':
|
| 174 |
is_diff[idx] = False
|
|
@@ -189,22 +190,25 @@ def filter_opcodes(opcodes):
|
|
| 189 |
j = i + 1
|
| 190 |
while j < n and is_diff[j]:
|
| 191 |
j += 1
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
result_dst.append((dst_start, dst_end))
|
| 202 |
i = j
|
| 203 |
else:
|
| 204 |
i += 1
|
| 205 |
|
| 206 |
return result_src, result_dst
|
| 207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
def compare_texts(src, dst, settings):
|
| 209 |
src_flags = build_active_flags(src, settings)
|
| 210 |
dst_flags = build_active_flags(dst, settings)
|
|
@@ -228,15 +232,13 @@ def compare_texts(src, dst, settings):
|
|
| 228 |
opcodes = matcher.get_opcodes()
|
| 229 |
result_src, result_dst = filter_opcodes(opcodes)
|
| 230 |
|
| 231 |
-
for
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
src_diff_ranges.append((orig_start, orig_end))
|
| 235 |
|
| 236 |
-
for
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
dst_diff_ranges.append((orig_start, orig_end))
|
| 240 |
|
| 241 |
has_diff = bool(src_diff_ranges or dst_diff_ranges)
|
| 242 |
|
|
@@ -332,7 +334,7 @@ DST25 = (
|
|
| 332 |
# ============================================================
|
| 333 |
|
| 334 |
print("=" * 60)
|
| 335 |
-
print("バグ2 検証スクリプト
|
| 336 |
print("=" * 60)
|
| 337 |
|
| 338 |
# ---- 全設定オフ ----
|
|
@@ -381,8 +383,7 @@ run_test("TEST-08 約物無視 設定オフ",
|
|
| 381 |
"吾輩は猫である名前はまだない",
|
| 382 |
OFF,
|
| 383 |
["、", "。「", "」", "(", ")", "!"],
|
| 384 |
-
[],
|
| 385 |
-
True)
|
| 386 |
|
| 387 |
run_test("TEST-09 約物無視 設定オン",
|
| 388 |
"(abc)テスト", "abcテスト",
|
|
|
|
| 1 |
+
# verify_bug2_ver8.py
|
| 2 |
+
# 実行方法: python verify_bug2_ver8.py
|
| 3 |
|
| 4 |
import re
|
| 5 |
import difflib
|
|
|
|
| 169 |
else:
|
| 170 |
is_diff.append(True)
|
| 171 |
|
| 172 |
+
# 両端のequal区間はdiff扱いにしない
|
| 173 |
for idx in range(n):
|
| 174 |
if ops[idx][0] == 'equal':
|
| 175 |
is_diff[idx] = False
|
|
|
|
| 190 |
j = i + 1
|
| 191 |
while j < n and is_diff[j]:
|
| 192 |
j += 1
|
| 193 |
+
# この範囲内でreplace/delete/insertの文字位置のみ収集
|
| 194 |
+
for k in range(i, j):
|
| 195 |
+
tag, i1, i2, j1, j2 = ops[k]
|
| 196 |
+
if tag in ('replace', 'delete'):
|
| 197 |
+
for pos in range(i1, i2):
|
| 198 |
+
result_src.append(pos)
|
| 199 |
+
if tag in ('replace', 'insert'):
|
| 200 |
+
for pos in range(j1, j2):
|
| 201 |
+
result_dst.append(pos)
|
|
|
|
| 202 |
i = j
|
| 203 |
else:
|
| 204 |
i += 1
|
| 205 |
|
| 206 |
return result_src, result_dst
|
| 207 |
|
| 208 |
+
# ============================================================
|
| 209 |
+
# 比較コア
|
| 210 |
+
# ============================================================
|
| 211 |
+
|
| 212 |
def compare_texts(src, dst, settings):
|
| 213 |
src_flags = build_active_flags(src, settings)
|
| 214 |
dst_flags = build_active_flags(dst, settings)
|
|
|
|
| 232 |
opcodes = matcher.get_opcodes()
|
| 233 |
result_src, result_dst = filter_opcodes(opcodes)
|
| 234 |
|
| 235 |
+
for pos in result_src:
|
| 236 |
+
orig = src_map[pos]
|
| 237 |
+
src_diff_ranges.append((orig, orig + 1))
|
|
|
|
| 238 |
|
| 239 |
+
for pos in result_dst:
|
| 240 |
+
orig = dst_map[pos]
|
| 241 |
+
dst_diff_ranges.append((orig, orig + 1))
|
|
|
|
| 242 |
|
| 243 |
has_diff = bool(src_diff_ranges or dst_diff_ranges)
|
| 244 |
|
|
|
|
| 334 |
# ============================================================
|
| 335 |
|
| 336 |
print("=" * 60)
|
| 337 |
+
print("バグ2 検証スクリプト ver8")
|
| 338 |
print("=" * 60)
|
| 339 |
|
| 340 |
# ---- 全設定オフ ----
|
|
|
|
| 383 |
"吾輩は猫である名前はまだない",
|
| 384 |
OFF,
|
| 385 |
["、", "。「", "」", "(", ")", "!"],
|
| 386 |
+
[], True)
|
|
|
|
| 387 |
|
| 388 |
run_test("TEST-09 約物無視 設定オン",
|
| 389 |
"(abc)テスト", "abcテスト",
|