본문 바로가기
네이버 블로그 백업/전산영어학

기말 과제 - 2. 첨부된 파일 [ex_01.txt]는 "캔터베리 이야기"에서 추출한 어휘 목록이다.

by wizmusa 2003. 12. 23.

2. 첨부된 파일 [ex_01.txt]는 "캔터베리 이야기"에서 추출한 어휘 목록이다.

 

파일 [ex_01.txt]의 구성

Field(Column)-1

Field(Column)-2

어휘 목록

각 어휘의 빈도수

the Number of Records :10,674

 

    ⁚ [ex_01.txt]를 대상으로 아래에 제시된 기능을 수행하는 awk 프로그램을 제작하시오.

        (1) 빈도수가 7이상(빈도수 7 포함)인 어휘 목록을 추출하는 프로그램을 만드시오. (10점)

 

{

if ($2 >= 7) print $1,"\t", $2;

}

 

a 2921

abbot 8

abedde 9

abhomynable 8

able 10

aboute 78

above 44

aboven 16

absence 8

absolon 30

youres 9

youreself 15

youthe 13

yow 710

yslayn 7

ytaille 9

yvel 11

yvele 18

ywedded 8

ywis 21

    (2) 어휘 길이(알파벳의 수)가 5 이상인 어휘의 목록을 추출하는 프로그램을 만드시오. (15점)

 

{

if (length($1) >= 5) print $1,"\t", $2;

}

 

aaron 1

abasshed 1

abate 1

abated 1

abateth 1

abaundone 1

abaundoneth 2

abaysed 1

abayst 2

abbay 1

ywoxen 1

ywrite 1

ywriten 3

ywroght 5

ywrye 1

ywympled 1

zakarie 1

zanzis 1

zenobia 1

zephirus 1



    (3) 어휘 길이(알파벳의 수)가 5 이상이고 빈도수가 3 이상인 어휘의 목록을 추출하는 프로그램을 만드시오. (15점)

 

{

if (length($1) >= 5 && $2 >= 3) print $1,"\t", $2;

}

 

abbot 8

abedde 9

abhomynable 8

abide 3

aboute 78

abouten 5

above 44

aboven 16

abregge 5

absence 8

ysworn 3

ytaille 9

ytake 6

ytaught 6

ytoold 3

yvele 18

yveles 6

ywedded 8

ywriten 3

ywroght 5



    (4) 주어진 파일은 <필드 1>을 기준으로 정순, 정방향으로 정렬되어 있다. <필드 1>을 기준으로 역순, 정방향으로 정렬하는 프로그램을 만드시오. (정순-정방향으로 정렬된 파일을 맨 마지막 라인부터 거꾸로 출력하면 역순-정방향 리스트가 만들어진다) (20점)

 

{

line[NR] = $0;

}

END {

for (i = NR;i > 0; i--) print line[i];

}

 

zephirus 1

zenobia 1

zanzis 1

zakarie 1

ywys 3

ywympled 1

ywrye 1

ywroght 5

ywriten 3

ywrite 1

abaundoneth 2

abaundone 1

abateth 1

abated 1

abate 1

abasshed 1

abak 2

aas 1

aaron 1

a 2921

반응형