2010-04-30 2 views
2

두 가지 버전의 텍스트가 있으며 Google 문서 또는 스택 오버플로와 유사한 버전의 HTML보기를 생성하려고합니다. 파이썬에서이 작업을 수행해야합니다. 이 기술이 무엇인지 불렀는지 모르겠지만 이름이 있다고 가정합니다. 그리고 할 수있는 파이썬 라이브러리가 있기를 바랍니다.파이썬에서 텍스트의 업데이트 내역보기 생성

버전 1 :

윌리엄 헨리 "빌"게이츠 III는 (1955 년 10 월 28 일 출생) [2]는 미국의 비즈니스 거물, 자선 및 회장 [3] 마이크로 소프트의 그는 Paul Allen과 함께 설립 한 회사입니다.

버전 2 :

윌리엄 헨리 "빌"게이츠 III (1955년 10월 28일 태어나는) [2] 박애주 의자, 비즈니스 거물이며, 회장 [3] 마이크로 소프트, 그는 소프트웨어를 Paul Allen과 함께 설립했습니다. 그는 미국인입니다.

원하는 출력 :

윌리엄 헨리 "빌"게이츠 III ( 년 10 월 (28), 1955 년생) [2] 자선하는 N 미국 사업 거물이며, 회장 [ 3], 소프트웨어는 Paul Allen과 함께 설립했습니다. 그는 미국인입니다. 이 열/단어가 다른 어떤 다르지만되지 않는 선 저를 알려주기 때문에 작동하지 않습니다 diff 명령을 사용하여

.

$ echo 'William Henry "Bill" Gates III (born October 28, 1955)[2] is an American business magnate, philanthropist, and chairman[3] of Microsoft, the software company he founded with Paul Allen.' > oldfile 
$ echo 'William Henry "Bill" Gates III (born October 28, 1955)[2] is a business magnate, philanthropist, and chairman[3] of Microsoft, the software company he founded with Paul Allen. He is American.' > newfile 
$ diff -u oldfile newfile 
--- oldfile 2010-04-30 13:32:43.000000000 -0700 
+++ newfile 2010-04-30 13:33:09.000000000 -0700 
@@ -1 +1 @@ 
-William Henry "Bill" Gates III (born October 28, 1955)[2] is an American business magnate, philanthropist, and chairman[3] of Microsoft, the software company he founded with Paul Allen. 
+William Henry "Bill" Gates III (born October 28, 1955)[2] is a business magnate, philanthropist, and chairman[3] of Microsoft, the software company he founded with Paul Allen. He is American.' > oldfile 

답변

0

wdiff을 사용할 수 있습니다. 파이썬 구현이 있는지 모르겠어요 :

$ wdiff oldfile newfile 
William Henry "Bill" Gates III (born October 28, 1955)[2] is [-an American-] {+a+} business magnate, philanthropist, and chairman[3] of Microsoft, the software company he founded with Paul Allen. {+He is American.+} 
0

difflib 모듈이이 문제에 도움이 될 수 있습니다.

관련 문제