블로그 이미지
이비그치면

태그목록

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

제 블로그의 중국어(한어) word 문서에 병음붙이기 

찾아오신 분께서 혹시 자신이 워드로  만든 중국어 단어장 문서에도 병음달기 기능이 되느냐고 해서 

답을 해드린 내용이다

아래와 같이 중국어 단어장을 만들었는데 매 단어마다 단어지정(단어선택)을 하고 MS WORD의

윗주달기기능('내천川' 버튼이 윗주 달기 버튼)을 실행해야 하는 노가다를 해야(복수단어 지정시 키 활성화가

아예 안됨-비활성화되어있음)해서 인터넷 검색하다가 이비그치면님의 블로그를 찾게 되었는데

MS WORD에서 TABLE(표 그리기)로 만든 단어장 문서여서 혹시 WORD의 단축키(일련의 연속작업을 반복할 수

있도록 하는 hotkey 지정) 혹은 매크로가 가능하냐고 댓글로 문의해오신 내용이다

기존의 매크로를 약간 변경하여 아래와 같이 한 테이블에 17줄 * 2 = 34개의 단어를 병음달기를 하는데 

1분이 채 걸리지 않았다

혹시 워드(MS WORD)의 표기능을 이용하여 중국어 단어장을 만드시고 병음달기 노가다에 짜증이 나신(애를 먹고 계신)

분들께 도움이 되길 바란다

원하시는 분들께서는 댓글로 메일주소를 알려주시기 바랍니다

그렇게 대단한 매크로는 아니지만(실은 아주 간단하지만 많은 시행착오를 거침)

꼭 필요한 분들께만 드리기 위해서입니다

[[ 매크로 시행전 ]]

 

[[ 매크로 시행후 ]]

 

 

 

 

크롬 단축키(chrome shortcut)

2020. 10. 22. 11:13 | Posted by 이비그치면

- Ctrl + W 탭 닫기

- Ctrl + Shift + T  탭 복원(잘못 탭을 닫았을 때)

 

- Ctrl + Shift + I  개발자 도구

- Ctrl + S 페이지 저장(save)

- Ctrl + O 페이지 열기(open)

- Ctrl + E 구글 검색

 

포토샵 레이어에 이미지 불러오기

- 레이어추가

- [ALT + F ] + L

아래와 같이 테이블(18*2)을 생성하고 생성한후에 랜덤하게(무작위로) 첫째칼럼의 열과

둘째칼럼의 열을 shading/hiding 하는 vba이다

단어장을 만들고 랜덤하게 뜻과 의미를 감추어 단어암기에 도움을 주기위해 만들었다

vba로 만들어져 매번 실행시마다 감추어지고 드러나는 셀들이 변경된다


Sub MakeTable()

    '--- 먼저 18*2  [row(행):18, col(열):2]테이블을 만든다
    ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=18, NumColumns:= _
            2, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
            wdAutoFitFixed
    With Selection.Tables(1)
        If .Style <> "표 구분선" Then
            .Style = "표 구분선"
        End If
        .ApplyStyleHeadingRows = True
        .ApplyStyleLastRow = False
        .ApplyStyleFirstColumn = True
        .ApplyStyleLastColumn = False
        .ApplyStyleRowBands = True
        .ApplyStyleColumnBands = False
    End With
    
    '--- 두번째 렬(column)에서 행(row)을 둘로 나눈다
    x = 1
    nTab = ActiveDocument.Range(0, Selection.Tables(1).Range.End).Tables.Count
    nRows = ActiveDocument.Tables(nTab).Rows.Count
    For i = 1 To nRows
        ActiveDocument.Tables(nTab).Cell(x, 2).Split NumRows:=2
        x = x + 2
    Next
    
End Sub

워드(WORD) VBA에서 

위와 같은 형태의 행이 합쳐진(vertically merged cell) 테이블(TABLE)내의 특정 셀(cell)이  merge되어있는지를 check하는데에는 약간의 어려움이 있다

그리고 랜덤으로 특정셀을 가리거나 드러내는 작업도 좀 복잡하다



Sub RandomHiding()

Dim R As Row
Dim C As Cell
Dim RowSpan, iCol, iRow

Const lo = 1
Const hi = 18
Const itms = 1

Dim i, k As Integer
Dim x As Variant

    '--- 먼저 전체 숫자집합(원소수 18)에서 몇개를 선택할것인가를 임의로 결정
    '--- 여기에선 6개이상 9개이하로 함
    Do While 1
        x = getRandomNumbers(lo, hi, itms)
    
        For i = lo To hi
            If x(i) = True Then k = i
        Next i
        If (k > 5) And (k < 10) Then
            Exit Do
        End If
    Loop
    
    '--- 다시 무작위로 위에서 정해진 갯수(k) 만큼의 숫자를 선택함
    x = getRandomNumbers(lo, hi, k)
    
    '--- 이제 테이블의 셀들을 돌면서 위에서 정해진 위치의 셀을 찾아
    '--- hiding/shading 한다
    
    Set tbl = ActiveDocument.Tables(1)
    
    For Each C In tbl.Range.Cells
        C.Select
        
        '--- 해당셀이 열병합(vertically merged)되어있는지 check
        RowSpan = (Selection.Information(wdEndOfRangeRowNumber) - _
            Selection.Information(wdStartOfRangeRowNumber)) + 1
        If RowSpan > 1 Then
            If x(Fix(C.RowIndex / 2) + 1) = True Then
                tbl.Cell(C.RowIndex, 1).Shading.BackgroundPatternColor = wdColorGray25
            End If
        Else
            If x(Ceiling(C.RowIndex / 2)) = False Then
                tbl.Cell(C.RowIndex, 2).Shading.BackgroundPatternColor = wdColorGray25
            End If
        End If
    Next C
End Sub

Function getRandomNumbers(lo As Integer, hi As Integer, toSelect As Integer)
'--- 기능 : 특정범위의 연속된 숫자집합에서 지정된 갯수만큼 무작위로 선택
'---        배열(boolean array)을 return(선택된 숫자들이 array index가 되고 그값은 true)
'---        예를 들어 1..18까지고 3개를 random으로 뽑은 숫자가 1,7, 17 이라면
'---        retArr(1) = True, retArr(7) = True, retArr(17) = True
'--- 입력값 : lo : 숫자집합의 최저값, hi : 숫자집합의 최고값, toSelect : 선택할 갯수
'--- 결과값 : 배열(boolean array)

    ReDim Items(lo To hi) As Variant
    Dim selected As Integer
    
    Randomize
    
    Do While selected < toSelect
        Dim rec As Integer
        rec = Int((hi - lo + 1) * Rnd + lo)
        If Items(rec) = False Then
            Items(rec) = True
            selected = selected + 1
        End If
    Loop

    getRandomNumbers = Items
    
End Function

Function Ceiling(Number As Double) As Long
'--- 기능: 소숫점 이하값 무조건 올림

    Ceiling = -Int(-Number)
    
End Function

중국어(한어) Word 문서에 병음 붙이기

2016. 12. 30. 19:11 | Posted by 이비그치면

$$ 중국어 단어장(표로 작성된) 에 적용되는 매크로입니다

https://oneone59.tistory.com/entry/%EC%9B%8C%EB%93%9C%EB%A1%9C-%EC%9E%91%EC%84%B1%EB%90%9C-%EC%A4%91%EA%B5%AD%EC%96%B4%ED%95%9C%EC%96%B4-%EB%8B%A8%EC%96%B4%EC%9E%A5MS-WORD%EB%A1%9C-%EC%9E%91%EC%84%B1%EC%97%90-%EB%B3%91%EC%9D%8C%EB%8B%AC%EA%B8%B0

$$

ms워드의 윗주달기를 이용하면 쉽게 병음을 붙일수있습니다

그러나 문서선택을 하고  메뉴에 나와있는 윗주달기버튼을 누르면 몇줄밖에(정확치는 않지만 대략 20에서 30자정도) 병음이 붙지않는것을 볼수있습니다

그래서 많은 분량의 문서에 병음처리를 하려면 상당한 수고(노가다)를 해야합니다

예를 들어 중국어/한어(Hanyu) MS WORD 문서에 병음(Pinyin)을 붙이려고 할때 문서의 일부분을 선택하고 윗주달기버튼(아래사진에서 연두색)을 누르면

 

다음과 같이 병음이 붙는것을 볼수있습니다

 

위에서 보시는 바와같이 3줄에서 4줄정도에 병음이 붙은것을 볼수있습니다

상당히 편리한 병음달기기능이지만 이렇게 제한이 있으면

많은량의 문서에 대해 병음을 달려고하면 이는 너무나도 힘들고 짜증나는 단순노가다

작업이 아닐수없습니다

 

기쁜소식을 하나 전합니다

몇번의 시행착오와 테스트를 거쳐 간단한 VBA(매크로)를 만들었습니다

아래가 시행한 후의 모습입니다

혹 이러한 노가다앞에서 절망(?)하고 있을 분들에게 도움이 되었으면 합니다

꼭 필요한 분은 제메일이나 댓글로 문서를 첨부해 남겨주세요

 

 

WORD VBA - 번체자 제거하고 병음만 남기기

2016. 12. 23. 15:27 | Posted by 이비그치면

아래 중국어(한어) 번체자(병음)으로 되어있는 문자열에서

병음만 남기는 VBA  script이다


(nín)(shì)(lǎo)(shī)(ma)  ==> nínshìlǎoshīma


Sub xxxx()
Dim regEx, Match, Matches
Dim sPinyin As String

Set regEx = New RegExp

sHan = "您(nín)是(shì)老(lǎo)师(shī)吗(ma)"

regEx.Pattern = "\((.*?)\)"  '-- 괄호속 문자 찾기(non-greedy)
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(sHan)

sPinyin = ""
For Each m In Matches
    sPinyin = sPinyin + m.SubMatches(0)
Next
Debug.Print sPinyin

End Sub


unix에서 파일안에 있는 null character(vi로 열어보면 ^@로 보임) space로 대치하기

1) edit mode로 들어가서

  :%s/ctrl-v ctrl-2/ /g


2) tr command 이용(shell 이용해서 복수의 파일 한꺼번에 변경할때)

    tr -A '\000' ' ' < foo.txt > bar.txt


한줄데이타 정해진자릿수(offset)로 나누기

2013. 7. 4. 18:47 | Posted by 이비그치면
import re 
str1 = 'abcdef'
 p = re.compile('^(.{2})(.{3})(.{1})')
aa = "|".join(p.split(str1))
print aa
'|ab|cde|f|'

웹사이트의 소스보기를 할때 자바스크립트 코드가 다음과 같이 압축되어

가독성이 떨어져있는 경우가 있다(일종의 코드숨기기)


다음 사이트에 접속하여 압축된 코드를 복사하여 

http://jsbeautifier.org/

Beautify javascript or HTML 창에 붙여넣기하고 ctrl-enter 하면 

아래와 같이 보기좋아진 코드를 얻을수있다


압축된 코드

var arg;this.div=null;this.classMain="tabber";this.classMainLive="tabberlive";this.classTab="tabbertab";this.classTabDefault="tabbertabdefault";this.classNav="tabbernav";this.classTabHide="tabbertabhide";this.classNavActive="tabberactive";this.titleElements=['h2','h3','h4','h5','h6'];this.titleElementsStripHTML=true;this.removeTitle=true;this.addLinkId=false;this.linkIdFormat='nav';for(arg in argsObj){this[arg]=argsObj[arg];}
this.REclassMain=new RegExp('\\b'+this.classMain+'\\b','gi');this.REclassMainLive=new RegExp('\\b'+this.classMainLive+'\\b','gi');this.REclassTab=new RegExp('\\b'+this.classTab+'\\b','gi');this.REclassTabDefault=new RegExp('\\b'+this.classTabDefault+'\\b','gi');this.REclassTabHide=new RegExp('\\b'+this.classTabHide+'\\b','gi');this.tabs=new Array();if(this.div){this.init(this.div);this.div=null;}}


들여쓰기되어 보기좋아진 코드

var arg;
this.div = null;
this.classMain = "tabber";
this.classMainLive = "tabberlive";
this.classTab = "tabbertab";
this.classTabDefault = "tabbertabdefault";
this.classNav = "tabbernav";
this.classTabHide = "tabbertabhide";
this.classNavActive = "tabberactive";
this.titleElements = ['h2', 'h3', 'h4', 'h5', 'h6'];
this.titleElementsStripHTML = true;
this.removeTitle = true;
this.addLinkId = false;
this.linkIdFormat = 'nav';
for (arg in argsObj) {
    this[arg] = argsObj[arg];
}
this.REclassMain = new RegExp('\\b' + this.classMain + '\\b', 'gi');
this.REclassMainLive = new RegExp('\\b' + this.classMainLive + '\\b', 'gi');
this.REclassTab = new RegExp('\\b' + this.classTab + '\\b', 'gi');
this.REclassTabDefault = new RegExp('\\b' + this.classTabDefault + '\\b', 'gi');
this.REclassTabHide = new RegExp('\\b' + this.classTabHide + '\\b', 'gi');
this.tabs = new Array();
if (this.div) {
    this.init(this.div);
    this.div = null;
}
}

프로그램 소스코드(program source code)를 티스토리 블로그(tistory blog)에

프로그래밍언어(Programming Language)별로

syntax highlighting(구문, keyword등 하이라이트로 구분)하여

보기좋게 올리는 방법이다


1) SyntaxHighlighter download

http://alexgorbatchev.com/SyntaxHighlighter/download/


2) 다운받은 압축파일을 풀어서 티스토리에 올리기(upload)

    - 티스토리 admin(관리자)으로 login

    - 꾸미기의 HTML/CSS편집 -> 파일업로드

       . Brush(코드종류별 Syntax 프로그램) -- 압축해제후 scripts 폴더에서 각자 원하는걸로

         제경우 자바스크립트, 파이선, 비쥬얼베이직, HTML, SQL

         shBrushJScript.js

         shBrushPython.js

         shBrushVb.js

         shBrushXml.js

         shBrushSql.js


       . 메인프로그램 -- scripts 폴더에서

         shCore.js


      . 스타일쉬트  -- styles 폴더에서

        shCore .css

        shThemeDefault.css


3) 티스토리 스킨파일(tistory skin.html) 수정

    - 꾸미기의 HTML/CSS편집 -> HTML/CSS의 skin.html

       <head>와 </head> 사이에 아래코드 삽입

















4) 글쓰기에서 프로그램코드를 넣을때 다음과 같이 brush명을 입력하여 사용

브러시명 : 파이선(python), 자바스크립트(js), 비쥬얼베이직(vb), SQL(sql), HTML(html)

 
  
myName = "Ahn"
print myName


이전 1 2 3 4 다음