토론:개인정보 보호법
새 주제보이기
마지막 의견: 12년 전 (HappyMidnight님) - 주제: 개정 법률 반영 요청
개정 법률 반영 요청
[편집][시행 2013.3.23.] [법률 제11690호, 2013.3.23., 타법개정]이 최신인 듯 합니다. 반영을 요청드립니다. HappyMidnight (토론) 2013년 8월 5일 (월) 10:55 (KST)
- 죄송하지만 해당 분야에 대해 잘 모릅니다. 현재 문서가 별도의 보호 상태에 있거나 하지 않으므로, 직접 반영해 주셔도 될 것 같습니다. Ø샐러맨더 (토론 / 기여) 2013년 8월 5일 (월) 13:07 (KST)
- 뭉게구름님이 해 주셨네요. 뭉게구름님이 뭔가, 자동화적인 편집 기능을 다룰 줄 아시는 것 같아서 매번 요청드리고 있습니다. HappyMidnight (토론) 2013년 8월 5일 (월) 17:46 (KST)
- 파워쉘로 어설프게 만들어 쓰고 있습니다. 수작업도 필요합니다! 필요한 분은 소스를 드리겠습니다. 뭉게구름 (토론) 2013년 8월 5일 (월) 19:18 (KST)
- 뭉게구름님, 방법을 구체적으로 알려 주시면 저도 법령 업데이트 작업을 돕도록 하겠습니다. HappyMidnight (토론) 2013년 8월 6일 (화) 12:19 (KST)
- 파워쉘로 어설프게 만들어 쓰고 있습니다. 수작업도 필요합니다! 필요한 분은 소스를 드리겠습니다. 뭉게구름 (토론) 2013년 8월 5일 (월) 19:18 (KST)
법령 가공 방법
[편집]- 필요조건
- 닷넷프레임웍 설치
- os가 윈되우 xp, 2003 서버이면 파워셸 설치
- 전제 조건
- 법률.txt 파일의 경로를 수정
- 법령정보센터(law.go.kr)에서 해당 법률 문서 텍스트를 복사하여 저장.
- 결과.txt 파일의 경로를 수정
- 법률.txt 파일의 경로를 수정
- 보조프로그램 아래 그룹에서 파워셸 ise를 실행하시고
아래 스트립트를 붙여 넣고 실행 버튼을 클릭하세요. 실행 권한이 없다는 메세지가 나타나면
- Set-ExecutionPolicy RemoteSigned
- 를 먼저 실행하시고, 다시 실행하시면 결과.txt에 가공 문서가 저장됩니다.
- 결과.txt의 내용을 위키문헌에 붙여으시고, 모자란 부분은 직접 편집하시면 끝입니다.
- 소스
# Set-ExecutionPolicy RemoteSigned
function first_item_reg {
Param(
[Parameter(Mandatory=$true)]
[string] $Name
)
process
{
#편 처리
if ($Name -match "^제[0-9]{1,}편[의]*[0-9]{0,}\S*" ) {
$Name = "`r`n" + "== " + $Name + " =="
return $Name
}
#장 처리
if ($Name -match "^제[0-9]{1,}장[의]*[0-9]{0,}\S*" ) {
$desc = "=="
if ($pyon -eq 1) {
$desc = "==="
}
$Name = "`r`n" + $desc + " " + $Name + " " + $desc
return $Name
}
#절 처리
if ($Name -match "^제[0-9]{1,}절[의]*[0-9]{0,}\S*" ) {
$desc = "==="
if ($pyon -eq 1) {
$desc = "===="
}
$Name = "`r`n" + $desc + " " + $Name + " " + $desc
return $Name
}
#관 처리
if ($Name -match "^제[0-9]{1,}관[의]*[0-9]{0,}\S*" ) {
$desc = "===="
if ($pyon -eq 1) {
$desc = "====="
}
$Name = "`r`n" + $desc + " " + $Name + " " + $desc
return $Name
}
#항 처리(2013.1.1 추가)
if ($Name -match "^제[0-9]{1,}항[의]*[0-9]{0,}\S*" ) {
$desc = "====="
if ($pyon -eq 1) {
$desc = "======"
}
$Name = "`r`n" + $desc + " " + $Name + " " + $desc
return $Name
}
#if ( $Name.IndexOf("①") ) {
# $Name = $Name.Replace("①", "(1)")
#}
#조문 처리
if ($Name -match "^제[0-9]{1,}조[의]*[0-9]{0,}" ) {
$chap_title = $Matches[0]
if ($Name -match "^제[0-9]{1,}조[의]*[0-9]{0,}\s*[(]{1}[^)]+[)]{1}" )
{
$chap_text = $Matches[0]
if ($Name -match "^제[0-9]{1,}조[의]*[0-9]{0,}" ) {
$tempchap = ($Matches[0] -replace "[제조]", "") -replace "의", "-"
$tempchap = "`r`n" + "* '''<span id='" + $tempchap + "'>" + $chap_text + "</span>'''"
$Name = $Name -replace "^제[0-9]{1,}조[의]*[0-9]{0,}\s*[(]{1}[^)]+[)]{1}", $tempchap
#Write-Host $tempchap
}
} elseif ($Name -match "^제[0-9]{1,}조[의]*[0-9]{0,}\s삭제\S{0,}") {
if ($Name -match "^제[0-9]{1,}조[의]*[0-9]{0,}" ) {
$tempchap = ($Matches[0] -replace "[제조]", "") -replace "의", "-"
$tempchap = "`r`n" + "* '''<span id='" + $tempchap + "'>" + $chap_title + "</span>'''"
$Name = $Name -replace "^제[0-9]{1,}조[의]*[0-9]{0,}", $tempchap
#Write-Host "삭제 조문 " + $Name
}
<# '제3호' 와 같이 조문명이 없는 법령 처리 #>
} elseif ($Name -match "^제[0-9]{1,}조[의]*[0-9]{0,}\S{0,}") {
$tempchap = ($Matches[0] -replace "[제조]", "") -replace "의", "-"
$tempchap = "`r`n" + "* '''<span id='" + $tempchap + "'>" + $chap_title + "</span>'''"
$Name = $Name -replace "^제[0-9]{1,}조[의]*[0-9]{0,}", $tempchap
<# '제3호' 와 같이 조문명이 없는 법령 처리 #>
}
return $Name
}
} #end process
}
$pyon = 0 #편 존재 여부
$add_number = "0"
$add_cond_cnt = 0
$add_cnt = 0
$line_cnt = 0
$law_name = ""
$filepath = "E:\\문서\\파워쉘\\법률.txt" <# 경로 수정할 부분 #>
$law_kind_arr = @('대법원규칙', '대통령령', '법률', '보건복지가족부령', '보건복지부령', '총리령', '행정안전부령')
$law_kind = $law_kind_arr -join '|'
$stream = [System.IO.StreamWriter] "E:\\문서\\파워쉘\\결과.txt" <# 경로 수정할 부분 #>
$header ="{{대한민국 법령
|제목 = title
|구분 = kind
|지은이 =
|호수 = number
|시행일자 = stdate
|제정개정구분 = mocode
|제정개정일자 = modate
* dept_info
|이전 =
|이후 =
}}"
$footer = "
== 구 시행 법 목록 ==
* [[대한민국 title (제number호)]] (시행 stdate)
== 라이선스 ==
{{PD-대한민국}}
[[분류:대한민국의 kind|title]]"
$row_cnt = 0
$cnt = -1
try {
#$law = [System.IO.File]::ReadAllLines($filepath)
$law = [System.IO.File]::ReadAllText($filepath)
$reader = [regex]::Split($law, "`r`n")
$row_cnt = $reader.length
for(;;) {
# 줄 단위 처리
for(;;) {
if ($cnt -gt $row_cnt) {
break
}
$cnt += 1
$line = $reader[$cnt]
# 빈 줄 제거
if ($line.length -gt 0) {
break
}
}
#Write-Host $line -foregroundcolor blue
#$line = $reader.ReadLine()
if ($line -eq $null) { break }
# process the line
## 공백 제거
$c_line = $line.Trim()
$c_line = $c_line.Replace("ㆍ", "·")
# `r
# “,” --> " 변경
$sp = '[“”]'
if ($c_line -match $sp) {
$c_line = $c_line -replace $sp, '"'
}
$line_cnt += 1
if ($line_cnt -eq 1) {
$law_name = $c_line
$c_line = ""
$header = $header -replace "title", $law_name
$footer = $footer -replace "title", $law_name
}
if ($line_cnt -eq 2) {
####################
# 공표 정보
# ##################
$c_line = $c_line.replace( "[", "Q")
$c_line = $c_line.replace( "]", "Q")
####################
#시행일자
if ( $c_line -match "^Q시행\s+[0-9.]+Q" ) {
$temp_header = $Matches[0]
$temp_header = ($temp_header -replace "[Q시행]", "").Trim()
# 날짜 끝에 붙어 있는 "." 제거
if ($temp_header.EndsWith(".") -gt 0)
{
$temp_header = $temp_header.substring(0, $temp_header.length-1)
}
$c_line = ($c_line -replace $Matches[0], "").Trim()
$header = $header -replace "stdate", $temp_header
$footer = $footer -replace "stdate", $temp_header
}
#공표번호
#if ( $c_line -match "^Q(법률|대통령령)\s+제[0-9]+호" ) {
if ( $c_line -match "^Q("+ $law_kind +")\s+제[0-9]+호" ) {
$temp_header = $Matches[0]
$temp_law_kind = $Matches[1]
foreach ($temp_kind_arr in $law_kind_arr)
{
if ($temp_law_kind -eq $temp_kind_arr) {
#write-host '일치' + $temp_law_kind
$header = $header -replace "kind", $temp_law_kind
$footer = $footer -replace "kind", $temp_law_kind
$cur_law_kind = $temp_law_kind
break
}
}
$temp_header = ($temp_header -replace "[Q법률대법원규칙대통령제호]", "").Trim()
$c_line = ($c_line -replace $Matches[0], "").Trim()
$header = $header -replace "number", $temp_header
$footer = $footer -replace "number", $temp_header
}
#제개정일자
if ( $c_line -match "^[,]\s+[0-9.]{6,}[,]{1}" ) {
$temp_header = $Matches[0]
$temp_header = ($temp_header -replace ",", "").Trim()
$c_line = ($c_line -replace $Matches[0], "").Trim()
$header = $header -replace "modate", $temp_header
#Write-Host $header -foregroundcolor blue
$c_line = $c_line.replace("공포법령보기", "").Trim()
}
#제개정구분
if ( $c_line -match "^\S+Q{1}$" ) {
$temp_header = $Matches[0]
$temp_header = $temp_header -replace "Q", ""
$c_line = ($c_line -replace $Matches[0], "").Trim()
$header = $header -replace "mocode", $temp_header
#Write-Host $header -foregroundcolor blue
$c_line = ""
#$stream.WriteLine($header)
}
} elseif ($line_cnt -eq 3) {
####################
# 소관부처 정보
# ##################
if ( $c_line -match '^([가-힝]+)\([가-힝]+\)\,\s+[0-9\-\~]+' ) {
$temp_header_etc = $c_line -replace $Matches[1], ''
$temp_header = '[[:w:대한민국 ' + $Matches[1] + '|'+ $Matches[1] + ']] ' + $temp_header_etc.Trim();
$c_line = ""
$header = $header -replace "dept_info", $temp_header
}
}
if ($c_line -match "^제[0-9]{1,}편[의]*[0-9]{0,}\S*" ) {
$pyon = 1
}
if ( $c_line.StartsWith("연혁") -or $c_line.StartsWith("조문체계도버튼연혁") -or $c_line.StartsWith("조문체계도버튼") ) {
$c_line = $c_line.Replace("연혁 ", "")
$c_line = $c_line.Replace("조문체계도버튼연혁", "")
$c_line = $c_line.Replace("조문체계도버튼", "")
$c_line = $c_line.Trim()
}
if ( $c_line -match "^\[{1}(단순위헌|본조신설|시행일|전문개정|제목개정|종전|시행미지정|제[0-9]+조의{0,1}[0-9]{0,1}에서|헌법)\s*" ) {
$c_line = ": " + $c_line
}
if ($c_line -match "^(닫기|열기|펼침)\s*" ) {
$c_line = $c_line -replace "(닫기|열기|펼침)\s*", ""
}
if ( $c_line.StartsWith("부칙 부칙") ) {
$c_line = $c_line.Replace("부칙 부칙", "부칙")
}
if ($c_line -match "(부칙보기|부칙[\(]전체보기[\)])\s*$" ) {
$c_line = $c_line -replace "(부칙보기|부칙[\(]전체보기[\)])\s*$", ""
}
if ( $c_line.IndexOf("부칙 더보기(요약보기)") ) {
$c_line = $c_line.Replace("부칙 더보기(요약보기)", "").Trim()
}
if ( $c_line -match "^부칙\s+[<]{1}("+ $law_kind +")\s*제[0-9]{1,}호[,]+\s*\S+[>]{1}" ) {
$add_number = "1"
$add_cnt = $add_cnt + 1
$add_cond_cnt += 1
}
if ( $add_cond_cnt -gt 0 ) {
if ( $add_cnt -eq 1 ) {
$add_cnt = 0
#부칙 <법률 제4102호, 1989.3.31>
if ($c_line -match "^부칙\s+[<]{1}("+ $law_kind +")\s*제[0-9]{1,}호[,]+\s*\S+[>]{1}" )
{
$temp_line = $c_line
# write-host $cur_law_kind
if ( ($cur_law_kind -eq '법률') -or ($cur_law_kind -eq '대통령령') -or ($cur_law_kind -eq '대법원규칙') ) {
$deco_text = $Matches[0] -replace "(법률|대법원규칙|대통령령)\s{0,1}", ""
$deco_text = "`r`n" + "* '''" + $deco_text + "'''"
$c_line = $c_line -replace "^부칙\s+[<]{1}(법률|대법원규칙|대통령령)\s*제[0-9]{1,}호[,]+\s*\S+[>]{1}", $deco_text
$temp_line = ($temp_line -replace "^부칙\s+[<]{1}("+ $law_kind +")\s*제[0-9]{1,}호[,]+\s*\S+[>]{1}", "").Trim()
if ($temp_line.length -gt 3) {
$repl_temp_string = $temp_line -replace "[\(\)]", ""
$repl_temp_string = "[[대한민국 " + $repl_temp_string + "|" + $repl_temp_string + "]]"
$c_line = $c_line -replace $temp_line, $repl_temp_string
#Write-Host $c_line -foregroundcolor black
}
} else {
if ($temp_line -match "^부칙\s+\<(보건복지가족부령|보건복지부령|총리령)\s*제[0-9]{1,}호\,\s+\S+\>") {
$temp_replace_string = $Matches[0]
} else {
$temp_replace_string = $c_line
}
$temp_line = ($temp_line -replace $temp_replace_string, "").Trim()
$temp_replace_string = "`r`n" + "* " + "'''" + $temp_replace_string + "'''"
if ($temp_line.length -gt 3) {
$repl_temp_string = $temp_line -replace "[\(\)]", ""
$repl_temp_string = "[[대한민국 " + $repl_temp_string + "|" + $repl_temp_string + "]]"
#$temp_replace_string = '`r`n*' + "'''" + $Matches[0] + "'''"
#$c_line = $c_line -replace $temp_line, $repl_temp_string
$c_line = $temp_replace_string + " " + $repl_temp_string
} else {
$c_line = $temp_replace_string
}
}
}
}
}
if (! $c_line.length -eq 0) {
$st_char = $c_line.substring(0, 1)
if ( $st_char -match "[①-⑮]" ) {
#$cnumber = circle_char_repl($c_line)
$c_line = ": " + $c_line
}
}
if ( $c_line.length -gt 2) {
$st_char = $c_line.substring(0, 2)
}
# 1. 처리
if ($c_line -match "^[0-9]{1,}[.]") {
$c_line = ":: " + $c_line
}
# 1의3. 처리
if ($c_line -match "^[0-9]{1,}의[0-9]{1,}.") {
$c_line = ":: " + $c_line
}
if ($add_number -eq "0" ) {
# ############################
# 부칙이 아니면 처리
# ############################
if ($c_line -match "^[가-허]{1}[.]{1}\s*" ) {
$c_line = "::: " + $c_line
}
if ($c_line -match "^[0-9]{1,}[\)]\s*") {
$c_line = ":::: " + $c_line
}
if ($c_line -match "^[가-허]{1}[\)]{1}\s*" ) {
$c_line = "::::: " + $c_line
}
} else {
if ($c_line -match "^[가-허]{1}[.]{1}\s*" ) {
$c_line = ":: " + $c_line
}
}
if ( ($c_line.StartsWith("제")) -or ($c_line.StartsWith("<")) ) {
## 조문 일 때
if ($add_number -eq "0") {
$cnumber = first_item_reg($c_line)
if (! ($cnumber -eq $null)) {
$c_line = $cnumber
}
##부칙일 때
} elseif ($add_cond_cnt -gt 1) {
# '.+일부를\s{1}다음과\s{1}같이\s{1}개정한다\.'
$c_line = ": " + $c_line
#write-host $c_line
# write-host $law_arr
#$cnumber = circle_char_repl($c_line)
#if (! ($cnumber -eq $null)) {
# $c_line = $cnumber
#}
<#
if ($c_line -match '((?(1)([0-9가-힣\·\s]+)))\s{1}일부를\s{1}다음과\s{1}같이\s{1}개정한다') {
write-host $c_line
write-host $Matches.toString()
}
#>
} else {
## 그 외
$c_line = ": " + $c_line
}
}
#부칙에 포함된 원문자 제거
#if ($add_cond_cnt -gt 1) {
# $c_line = circle_char_repl($c_line)
#}
$ex = new-object System.Text.RegularExpressions.Regex('\s+([\「 ])(?(1)([0-9가-힣\·\s]+)[\」])',[System.Text.RegularExpressions.RegexOptions]::Singleline)
$ms = $ex.Matches($c_line)
if ($ms.Count -gt 0) {
foreach ($list in $ms) {
# =======================
# Write-host $list.Value
# =======================
$temp_law_text = $list.Value
$clean_rst_law_text = $temp_law_text -replace '\s+(\「|\」)', ''
$clean_rst_law_text = ($temp_law_text -replace "「|\」", "").Trim()
if ( ($clean_rst_law_text.EndsWith('조약')) -or ($clean_rst_law_text.EndsWith('협약')) -or ($clean_rst_law_text.EndsWith('협정')) ) {
$rst_law_text = ' [[「' + $clean_rst_law_text.Trim() + '」]]'
} else {
$rst_law_text = ' [[대한민국 ' + $clean_rst_law_text + '|「' + $clean_rst_law_text.Trim() + '」]]'
}
#본문이면 모두 링크
if ($add_cond_cnt -lt 1) {
$c_line = $c_line -replace $temp_law_text, $rst_law_text
#부칙은 자신을 제외
} elseif ( ($add_cond_cnt -gt 1) -and ($clean_rst_law_text -ne $law_name) ) {
$c_line = $c_line -replace $temp_law_text, $rst_law_text
}
}
}
if ($add_cond_cnt -gt 1) {
if ($c_line -match "^이\s{1}[규칙|영|법]{1}은" -or $c_line -match "^본법은" -or $c_line -match "^별표\s+" -or $c_line -match "^별지\s+") {
$c_line = ": " + $c_line
}
# <12> 형태를 (12)로 변경
if ($c_line -match "^[:]{1}\s+[\<]{1}[0-9]{1,3}[\>]{1}" ) {
$c_line = $c_line.Replace("<", "(").Replace(">", ")")
}
}
#$temp_law_text = $c_line -replace '.+?\「(.+?)\」.+$', '[[대한민국 $1|「$1」]]'
#$c_line = $c_line -replace '\「(.+?)\」', $temp_law_text
if ($line_cnt -gt 2) {
if ($line_cnt -eq 3) {
$stream.WriteLine($header)
}
# ==================================
# 부칙 문단 추가
# ==================================
if ($add_cond_cnt -eq 1 ) {
$add_text = "`r`n`r`n" + '== 부칙 =='
$add_cond_cnt += 1
# 빈줄이 추가 방지
$c_line = $c_line.Trim()
#Write-Host $c_line -foregroundcolor black
$stream.WriteLine($add_text)
}
$stream.WriteLine($c_line)
}
#}
}
$stream.WriteLine($footer)
}
finally {
#$law.Close()
$stream.close()
}
#}