!"#$%&'()*+,-./01R 234(567+2011 89:0
11 ; 24 <R =>?@A&B
http://cran.md.tsukuba.ac.jp/
CD
DEFGE
GEH>IJKL&5MNOP<- 2NOPQRSNOTUVDWXY2ZPCD

<- c(

,

,

,

) 2NOPCD[QRM\U]P^_`P
ls()abUZcdNefZP^_`P
length(QRg0hi(j&(k USB lmn&MopqfrcFshitukFefrvPw-----------------------------------------------------------------!hixyzK5n&U{|MgfZP^}~
getwd()-----------------------------------------------------------------!•€•JFqfop‚OfZPx&ƒ=„…†…

scan(file="•€•J=‡ˆFg‰", what="char")GEx&ƒW=2swhat="char"kŠ‹?•@BkŒZfsGUI 2•Žscan(choose.files(), what="char")•'z&ƒ&=•x&ƒ=‘’k\2“”P^x••J5H– (j&(—‘’2„…†˜MHs•'z&ƒ&kŠ‹™P
sep="¥n"„…†Yš•€•Jk R =›Mx&ƒFqfop™P
QRg!ns.lines*FZœg‰M™P|FM™P
ns.lines <- scan(choose.files(), what="char", sep ="¥n")!›•kžPMH{œ™P^Ÿ¡¢£kžPhead(CDg, abD)¤¥¢£kžP
tail(CDg, abD)!¦^Xx&ƒk§PS¨=x&ƒk©ª™P«•¬(=-kŠ‹™P|F2s¨^X®=Dšv©ªq¯°=U±²‚OP
tail (CDg, -1)³´=µ—=©ª¡¶·—kžP
¤¥¸¹—kžP

¶º—»^X¶¹—»švkžPMHŸ
¨^X¶¹—»±²q¯¼2s¦^X½—FO¾s¿ÀÁM¶ºs¶¸s¶¹—»U±
Pw
head(ns.liles, 17)tail(, 3)

tail(head(ns.lines, 17), 3)!Â‹=—šv§Ã±™
ns.lines[79]ns.lines[c(77, 78, 79)]
ns.lines[77:79]!GER=ÄÅ
grep("ÄÅGER", CDg)
grep("NS001", ns.lines)
abÆÇ+S—ÆÇ0UÈÉ‚OPw!ÊË™P—=x&ƒk§Ã±™
ns.lines[grep("NS001", ns.lines)]!abÆÇ2Wcs›•®=°=k±²™PLÌÍÎ@value=Tgrep("NS001", ns.lines, value=T)!µd»=abHÊËqWZ°=
tail =ÏÐ2©ª!ÑÒ•$x&ƒ=x&ƒ¢£=…Ó±ns.data <- tail(grep("NS001", ns.lines, value=T), -1)-----------------------------------------------------------------‘Òn(5khP

ns.data!Ô—‘’2NefZPx&ƒks‘Ò‘’MÕÖÕÖM™P!GERkÕÖÕÖM™P×Ø
strsplit(CDg, "•'z&ƒ")
strsplit(ns.data, " ")ns.data k(j&(2”efÕÖÕÖM™PÕÖÕÖMq¯¿ÀH!n(5*MNP+ÙÚÛx&ƒ0[[1]][1] [2] ...
[[2]][1] [2] ...
[[3]][1] [2] ...
ns.data.list <- strsplit(ns.data, " ")!n(5=abkÕÖÕÖM™P
unlist(CDg)unlist(ns.data.list)
unlist(strsplit(ns.data, " ")) 2°ÜÝ!ÕÖÕÖMWe¯‘ÒkÞ`ßàP
sort(CDg)sort(unlist(ns.data.list))!Þ`ßà¯‘Ò=µá=âVkãFäP+åWÃÒ0
unique(CDg)unique(sort(unlist(ns.data.list)))-----------------------------------------------------------------"æ^Zçèé!•$êÇ!*NS001:¥t*UNefZP– Së– ©ª!©ª™PFHsss\°Wq2ìíîàP
!ìî%«@Bgsub(Û=GER, ïqZGER, ðñx&ƒ)
òaW=H!*NS001:¥t*2s[ef…óœwœãcZ^WZw

ÂôGE!**Hs!õ(ö&Ì*™P÷aU]P– – – Së– ¥¥– k‰Mdvfõ(ö&Ì
gsub("¥¥*NS001:¥t", " ", ns.data)|=¿Àksns.data2 FZœCD2op|=æ^Zçèkøùq¯œà2sú9s‘Òn(5+åWÃÒ0khûqf…óœw-----------------------------------------------------------!±ü¨Ue¯n(5=±²+•€•JFqfop0
write(CDg, file="•€•Jg")
write(ns.data.words, file="NS001-wordlist.txt")-----------------------------------------------------------------ý#Fqfsþ=•€•J2[ef…óœ
------------------------------------------------------------------

ÿÒD+!`ÒD0+token0FåWÃÒD+type0k±qf…óœw®œWPFsTTR °š"P^w
Type/Token
FWPFsGuiraud Index °±"PWw
Type/sqrt(Token)-----------------------------------------------------------"L«ö!—DkDàP
nrow()!#W…MRDkDàP
ncol()!CD=g‰kCàPïqZg‰ <- $Zg‰
rm($Zg‰)¶Ù;¶<
gsub("ìíîà‰=GER", "ìíîà¼=GER", CD)©ªH\°Wq2ìíîàPw
gsub("ìíîà‰=GER", "", CD)-------------------%i2&'W^e¯!æ^Z|F*¶0êÇ(=67+S)DE*+k©ª0.,È-2Èê
.¢/=0e¯12– [^a-zA-Z0-9]– gsub("[^a-zA-Z0-9]", "", CD)°œµd=12– ¥W
gsub("¥¥W", "", CD)
R 2=.,È-H*¦k34=|F
http://www.okada.jp.org/RWiki/?R%20%A4%CB%A4%AA%A4%B1%A4%EB%C0%B5%
B5%AC%C9%BD%B8%BD#content_1_3
Ù05GEF6GE=§Ã&Z+S7¢6GEM®8àP0.¢/=0e¯12– tolower
tolower(CD)!%«@B+9D0=0Z1Hsl:;&=!<JÌ*^X!R =9D*k•Ž-------------------!%=kãFä¯j&>°34=|F
http://sugiura-ken.org/wiki/wiki.cgi/exp?page=R-------------------!ÜÝóœW67k\?°™PwSë– ÌA@ÖA@@qfBFd=!×Ø*FqfãF
äP+¼2[Ãã™0-------------------"[efí¯67=ý#¶0\kq¯Z=^ŸÙ0‘Ò+åWÃÒ0=µáÈ½00'OfZP‘Ò+!`Ò0kn(5M™P·0GkÕÖÕÖ=‘ÒM™P– – (j&(k•'z&ƒ&M– – êÇ(H©ª– – 7¢6GEMº0CGšvDí±™
– – •$êÇ=©ª¸0E•=—švDí±™
¹0—‘’2•€•J^Xx&ƒk„…†˜-------------------åWÃÒDFs!`ÒDU'^O¾sZ8Z8'^Pw¶034(5=F‚+GãOP‘ÒDS!`ÒD0
Ù0HHI½0Guiraud index-------------------‚fsJ<Hs‘Ò=K9µáÈ-------------------table(!`ÒD=CD0|OšvL
NS001word.list <- table(NS001word.token)-------------------•€•JMopqãqMœw
write(NS001word.list, "op•€•Jg")+{|Mop‚OP^HsNz@5xyzK5n&k}~1 getwd())
žf…Pw]sšäšsss
write.table(NS001word.list, "op•€•Jg")|O2sÈFqfop‚OPwõK•J2ŒZf…óœw“”ÃHsx••J5H– (j&(“”ÃkƒIMCàPMHsLÌÍÎ@kOvfopw

write.table(NS001word.list, "op•€•Jg", sep="¥t")-------------------"ÜÝóœW67kãFäfµ9M™P"ãPHsx&ƒk„…†Y2sCG=34(5¢£švkCDMNOPMH
myData <- function(){lines.tmp <- scan(choose.files(), what="char", sep="¥n")#•€•Jk•Qw
data.tmp <- grep("¥¥*(JPN|NS)...:¥t", lines.tmp, value=T)#*2RãP—=…w
body.tmp <- gsub("¥¥*(JPN|NS)...:¥t", "", data.tmp)#—¡=ƒ@k©ªw
body.tmp <- body.tmp[body.tmp != ""] #S—k©ªw}]FHs
jpn.body <- myData()kT—wŒc•€•JkU^OP=2sŠ‹™Pšvw-------------------"2HsTTR kBFãFä=%«@BM
myTTR <- function(a){jpn.body.lower <- tolower(a)jpn.words <- unlist(strsplit(jpn.body.lower, "¥¥W"))
length(unique(jpn.words))/length(jpn.words)}]FHs
myTTR(jpn.body)kT—w"2HsÜVM Guiraid index
myGI <- function(a){jpn.body.lower <- tolower(a)jpn.words <- unlist(strsplit(jpn.body.lower, "¥¥W"))
length(unique(jpn.words))/sqrt(length(jpn.words))}

-------------------ÚMsWX‘ÒFk±qf…óœ
-------------------WX‘ÒFFHs‘ÒkYû™PGED=WX+Average Word Length)ÿGED– ÷– ÿ‘ÒD– 22PHPw
ÿ‘ÒDHs!`ÒDW=2s'^efPwÝZsÿGEDH{œ±™^Ÿ
!GEDkDàP%«@B+9D01– nchar(CD)nchar(jpn.body)|OšFsÔGMGãOP‘Ò=ÿGEDU2PwÝZs‘Òk7¢(j&(Wq2dW[¯°=UNe¯CDkdcO¾óZw
!abkdW[P%«@B1– paste(CD, collapse="")paste(jpn.words, collapse=""))|œqfrZfsÿGEDk_`O¾óZw
myAWL <- function(a){jpn.words <- unlist(strsplit(a, "¥¥W"))
nchar(paste(jpn.words, collapse=""))/length(jpn.words)}|O2]FHs
myAWL(jpn.body)-------------------ÝZs°BFdsWXGF+Average Sentence Length0-------------------µGMGãOP‘ÒD=WXÿ‘ÒD– ÷– ÿGD]s|OH\‘šw]£2 myASL khef…óœw

-------------------||ã2í¯Xs•€•JkŠ‹q¯X|OXk7¢ãFäf67q¯¿Àk±™ÌA@Ö^°_vã™`w!`ÒD– åWÃÒD– Guiraud Index– WX‘ÒF– WXGF--------------------

¶Ù;a<"WXGF+µG=›MWX‘ÒUZcd]P^0+b0+¶0GcFM‘ÒUZcdNefZP^_`Pw+Ù0‘Ò=D=WXk±™w+d0+¶0•€•J7e2GUZcd]P^_`Pw+Ù0•€•J7e2ÿ‘ÒDk_`Pw+½0‘ÒDkGD2fPFWXU±Pw"x&ƒk„…†Y2sCG=34(5¢£švkCDMNOPMH
myData <- function(){lines.tmp <- scan(choose.files(), what="char", sep="¥n")#•€•Jk•Qw
data.tmp <- grep("¥¥*(JPN|NS)...:¥t", lines.tmp, value=T)#*2RãP—=…w
body.tmp <- gsub("¥¥*(JPN|NS)...:¥t", "", data.tmp)#—¡=ƒ@k©ªw
body.tmp <- body.tmp[body.tmp != ""] #S—k©ªw}]FHs
jpn.body <- myData()|O2sx&ƒ=…U jpn.body MNPw
"jpn.body MCGx&ƒUNefZPFqfs#+d0=122sWXGFkgäPMHs
myASL <- function(a){words.tmp = unlist(strsplit(a,"¥¥W"))
words.tmp = words.tmp[words.tmp !=""]
length(words.tmp)/length(a)}|O2sh]=9D myASL khefrZfs
myASL(jpn.body)kT—™O¾óZw!.¢/=EiwZ#Z# jpn.body kopqWcf°s!NOj*Mqfqãà¾ó
Zw> myASL(myData())

#+b0122sWXGFkgäPMH
Ô—+SG0cFMs‘ÒDk±™w
FZœ|FHsÔ—kQRF…Wqfs®=abDkš"¾óZw!ãPsêÇ(k©ªqfrc
myNoKigou <- function(a){b <- gsub(" ", "ZSPACEZ", a)# (j&(Hkpq¯Zc <- gsub("¥¥W", "", b)# )DGE*+H©ªd <- gsub("ZSPACEZ", " ", c)# (j&(kl™
gsub(" *", " ", d)# VD=(j&(kµdM}ë strsplit(myNoKigou(jpn.body), "¥¥W")|O2mÚÛ=QR+n(50U2íPwmÚÛQR=µ—»H [[1]]strsplit(myNoKigou(jpn.body), "¥¥W")[[1]]'^Ã[™c™P¯äMsZe¯Yn(5M x FZœg‰kOvfopw
x <- strsplit(myNoKigou(jpn.body), "¥¥W")
W=2sµ—»Hsx[[1]] 2±Pwµ—»=abD+‘ÒD0Hs
length(x[[1]])|O2sÔ—=‘ÒDU±Pw]FHs|Ok™`f=—MdZfs!nÃoqf—œ*w
7¢2\—]P^FZœFs
length(x)#nÃoqfT—+pq1ÌA@Ö^=rOk%@5A&J™P0
for (st) {
™P|F
™P|F
}

!!st*¢£=_í1– – CD in ®=uv
– –w1 i in 1:19
– – ¶^X¶xã2syM i MNOP– –w1 i in 1:length(x)– – ¶^Xsx =D+G=D0ã2syM i MNOP
for (i in 1:length(x)){
print(length(x[[i]]))}# print()H!±²*™P×Ø|OkT—™PFsÔ—=‘ÒDUµáÈÉ!±²*™P=2Wcsx&ƒFqf y Mop™P
for (i in 1:length(x)){
y <- (length(x[[i]]))}]s|OHšäw³¼=q^op‚OfWZw! x = i Æ»=k y = i Æ»MopqWZFZvWZw
for (i in 1:length(x)){
y[i] <- (length(x[[i]]))}|O2sy MNe¯w!WXk±™9DH mean()mean(y)"•€•JkŠ‹™PFsType F Token =z1kµ9M±²™P9DHŸ
myTT <- function(a){lines.tmp <- scan(choose.files(), what="char", sep="¥n")data.tmp <- grep("¥¥*(JPN|NS)...:¥t", lines.tmp, value=T)
body.tmp <- gsub("¥¥*(JPN|NS)...:¥t", "", data.tmp)
body.tmp <- body.tmp[body.tmp != ""] #S—k©ªw
body.tmp.lower <- tolower(body.tmp)# 6GEM
words.tmp <- unlist(strsplit(body.tmp.lower, "¥¥W")) # ‘ÒMwords.tmp = words.tmp[words.tmp !=""]# ]P=švM
c(length(unique(words.tmp)), length(words.tmp))# md=abkQRM

}2s]FHs*¦kT—1
myTT()"VD=•€•JMðqf]{ÁMT—™PMHssssãPs•€•JgkŠ‹qfT—™PMHsscan(choose.files(), what="char", sep="¥n") =|ˆ2s}eÁM•€•JgkŠ‹™Pw!•k£^Ã[™c™P¯äMs– hixyzK5n&ksx&=]PxyzK5n&MC~– Sël:;&=!•€•J*^Xs!xyzK5n=C~*– Sëgetwd() 2}~w–
– ®|M]P•€•JµákÈÉ– ë dir()–# JPN001.txt kwMscan("JPN001.txt" , what="char", sep="¥n")–|O2sJPN001.txt •Ð=ÌA@Ö^khef…Pw
myTTJPN001 <- function(){lines.tmp <- scan("JPN001.txt" , what="char", sep="¥n")data.tmp <- grep("¥¥*(JPN|NS)...:¥t", lines.tmp, value=T)
body.tmp <- gsub("¥¥*(JPN|NS)...:¥t", "", data.tmp)
body.tmp <- body.tmp[body.tmp != ""] #S—k©ªw
body.tmp.lower <- tolower(body.tmp)# 6GEM
words.tmp <- unlist(strsplit(body.tmp.lower, "¥¥W")) # ‘ÒMwords.tmp = words.tmp[words.tmp !=""]# ]P=švM
c(length(unique(words.tmp)), length(words.tmp))# md=a
bkQRM
}
¼HT—1
ë myTTJPN001()#•€•Jg=µáÈÉë list.files#nÃoqfT—+pq1ÌA@Ö^=rOk%@5A&J™P0
for (st) {
™P|F
™P|F
}

#•€•Jµá=•€•JkyM67™O¾óZ
myTT <- function() {output.file = choose.files()type <- 0
token <- 0
files <- list.files()for (i in files) {lines.tmp <- scan(i , what="char", sep="¥n")data.tmp <- grep("¥¥*(JPN|NS)...:¥t", lines.tmp, value=T)
body.tmp <- gsub("¥¥*(JPN|NS)...:¥t", "", data.tmp)
body.tmp <- body.tmp[body.tmp != ""]body.tmp.lower <- tolower(body.tmp)
words.tmp <- unlist(strsplit(body.tmp.lower, "¥¥W"))
words.tmp <- words.tmp[words.tmp !=""]
type <- length(unique(words.tmp))
token <- length(words.tmp)
cat(type, token, "¥n", file=output.file, append=T)}}•€•JMop‚O¯w
tat <- read.table(choose.files())›•kžf…Ptat
ž±qUWZw
names(tat)ž±qkOvPMHs
names(tat) <- c("Type", "Token")€C•‚ƒkžP
summary(tat)
Type
Min.
: 57.0
1st Qu.:110.0
Median :135.0
Mean:142.43rd Qu.:170.0
Max.
:302.0
tat$Type

Token
Min.
:106.0 +³6-0
1st Qu.:243.2 +„£’é= 1/4 -0
Median :324.0 +›…-0Mean:339.6 +WX0
3rd Qu.:420.8 +„£’é= 3/4 -0
Max. :898.0 +³5-0

tat$Tokenboxplot(tat)bar(tat)plot(tat)plot(tat$Token)plot(sort(tat$Token))plot(tat$Type)plot(sort(tat$Type))
hist(tat$Token)
hist(tat$Type)¶Ù;¶º<"ÑÒ•$=x&ƒk67w¶0hixyzK5n&ksx&ƒ=]PxyzK5n&MC~– – l:;&=!•€•J*^X!xyzK5n=C~*– –Ù0!Nz@5xyzK5n*=}~– – getwd()– –½0myTT =T—-------------------myTT <- function() {output.file = choose.files()type <- 0
token <- 0
files <- list.files()for (i in files) {lines.tmp <- scan(i , what="char", sep="¥n")data.tmp <- grep("¥¥*(JPN|NS)...:¥t", lines.tmp, value=T)
body.tmp <- gsub("¥¥*(JPN|NS)...:¥t", "", data.tmp)
body.tmp <- body.tmp[body.tmp != ""]body.tmp.lower <- tolower(body.tmp)
words.tmp <- unlist(strsplit(body.tmp.lower, "¥¥W"))
words.tmp <- words.tmp[words.tmp !=""]
type <- length(unique(words.tmp))
token <- length(words.tmp)
cat(type, token, "¥n", file=output.file, append=T)}}-------------------myTT()– – op•€•JgHswà¾! tatns.txt *·0op•€•J^X R M„…†˜– – tatns <- read.table(choose.files())º0ž±qkOvP– – names(tatns) <- c("Type", "Token")¸0€C•‚ƒkžP– – summary(tatns)-------------------Type
Token
Min.
:196.0Min.
: 386.0
1st Qu.:247.8
1st Qu.: 521.0
Median :265.0
Median : 557.0
Mean:272.0Mean: 595.1
3rd Qu.:287.2
3rd Qu.: 612.0
Max.
:493.0Max.
:1555.0--------------------

¹0†(5@Ö^
hist(tatns$Token)
hist(tat$Token)â`fÈÉ‚"PMHsLÌÍÎ@add=T

hist(tatns$Token)
hist(tat$Token, add=T)âWefžMcZw‡kOvóœw
ˆí‰qw– ‰=kŠ™MH

plot.new()hist(tat$Token, col="blue")hist(tatns$Token, add=T, col="red")#hist()=LÌÍÎ@– ‹=CDkŒ‹™P breaks=CD– •Ž=uvkŠ‹™P xlim=c(0,1500)!•B[•
boxplot(tat$Token)
boxplot(tatns$Token, add=T)
boxplot(tat$Token, tatns$Token)!‘èše¯|F1"#$FÑÒ•$2sType =’“sToken =’“SSSSSSSSSSSSSS"ïqZ|F"SSSSSSSSSSSSSSSSS"™`f=•€•JMðqf TTR k±qf…Pw
tat$Type
tat$Type[1]tat$Token[1]tat$Type[1]/tat$Token[1]—R[—ÆÇ,RÆÇ]tat[1, ]tat[ ,1]¶—»=ab¶R»=ab+SType0!”R»M TTR =-kNO¯Z
tat[1,3] <- tat[1,1]/tat[1,2]tat 2žf…óœ
!ÝZs|OkyÆM[efZv¾óZw
yÆMnÃo™– for– k0œw—=DH– nrow()for (i in 1:nrow(tat)){tat[i,3] <- tat[i,1]/tat[i,2]}"ÝZs™`f=•€•JMðqf GI k±qf…Pw
for (i in 1:nrow(tat)){tat[i,4] <- tat[i,1]/sqrt(tat[i,2])}– – names(tmp) <- c("Type", "Token", "TTR", "GI")!!TTR H34(5=F‚M•–k—vP*FZ'OfZPw
plot(tmp$Token, tmp$TTR)
grid()
lines(lowess(tmp$TTR~tmp$Token))lines() 2˜k™clowess()2Wš›k™P+œŽ••Ž0#ž9U]P^+¶0Ÿ ¡@=ž9¢D+'Öl5n£K0+Ù0(Ÿ «@=ž9¢D+¤@'Öl5n£K0+½0ö@B&J=ž9¢D+¤@'Öl5n£K0!'ÖŸhttp://aoki2.si.gunma-u.ac.jp/lecture/Kentei/nonpara.html
Së– .,£¥kqfZP^kÄ‹qf…O¾óZw!.,£¥=Ä‹shapiro.test() 2 Shapiro-Wilk Ä‹– +p -U .05 óÃ5íZFs.,£¥qfZPF…W"P0
ž9¢Dk±qfs^d¦§^{œ^°}^äP
http://oku.edu.mie-u.ac.jp/~okumura/stat/correlation.php
cor.test(x, y, method="spearman")cor.test(tmp$Token, tmp$TTR, method="spearman")!!– „R»M Guiraud Index kOv¨qf…óœLL+‘è0– +Guiraud Index H34(5=F‚=•–k—vWZš8œ^Ÿ0

SSSSSSSSSSS"Ò©K9y¨’Òn(5SSSSSSSSSSS+myTT =ÏÐ0"¨’¶ª’ã2-------------------myTop10 <- function(a){lines.tmp <- scan(choose.files(), what="char", sep="¥n")data.tmp <- grep("¥¥*(JPN|NS)...:¥t", lines.tmp, value=T)
body.tmp <- gsub("¥¥*(JPN|NS)...:¥t", "", data.tmp)
body.tmp <- body.tmp[body.tmp != ""] #S—k©ªw
body.tmp.lower <- tolower(body.tmp)# 6GEM
words.tmp <- unlist(strsplit(body.tmp.lower, "¥¥W")) # ‘ÒMwords.tmp = words.tmp[words.tmp !=""]# ]P=švM
#c(length(unique(words.tmp)), length(words.tmp))
kQRM# md=abhead(sort(table(words.tmp), decreasing=T), 10)
5– «yÞ`ßà– ¨’¶ª

# !Ò©n(}-------------------"¨’\’ã2°ùäXOPóœM– +9D=»ÁÒkmdM™P0

-------------------myTop <- function(a,b){lines.tmp <- scan(choose.files(), what="char", sep="¥n")data.tmp <- grep("¥¥*(JPN|NS)...:¥t", lines.tmp, value=T)
body.tmp <- gsub("¥¥*(JPN|NS)...:¥t", "", data.tmp)
body.tmp <- body.tmp[body.tmp != ""] #S—k©ªw
body.tmp.lower <- tolower(body.tmp)# 6GEM
words.tmp <- unlist(strsplit(body.tmp.lower, "¥¥W")) # ‘ÒMwords.tmp = words.tmp[words.tmp !=""]# ]P=švM
head(sort(table(words.tmp), decreasing=T), b)2Š‹# !y’k b}-------------------myTop(,20)
SSSSSSSSSSS"¬ÒÈ-=Ó±SSSSSSSSSSS+-®k¯°•5±&B2²³0-------------------my2gram <- function(a){lines.tmp <- scan(choose.files(), what="char", sep="¥n")data.tmp <- grep("¥¥*(JPN|NS)...:¥t", lines.tmp, value=T)
body.tmp <- gsub("¥¥*(JPN|NS)...:¥t", "", data.tmp)
body.tmp <- body.tmp[body.tmp != ""] #S—k©ªwword.tmp <- unlist(strsplit(body.tmp, "¥¥W"))”ef!‘Ò*ÕÖÕÖM# )DE*+2for (i in 1:length(word.tmp)-1) {cat(word.tmp[i], word.tmp[i+1], "¥n")}}-------------------my2gram T—
Së– ¶Òšv=—U]Pw
Së– VD=(j&(kBFãFä2”PL– – ¥¥W+-------------------my2gram <- function(a){lines.tmp <- scan(choose.files(), what="char", sep="¥n")data.tmp <- grep("¥¥*(JPN|NS)...:¥t", lines.tmp, value=T)
body.tmp <- gsub("¥¥*(JPN|NS)...:¥t", "", data.tmp)
body.tmp <- body.tmp[body.tmp != ""] #S—k©ªw

word.tmp <- unlist(strsplit(body.tmp, "¥¥W+")))DE*+2”ef!‘Ò*ÕÖÕÖM

# ¶GE*¨=for (i in 1:length(word.tmp)-1) {cat(word.tmp[i], word.tmp[i+1], "¥n")}}-------------------! cat MLÌÍÎ@kOvfs•€•JMopw
file="•€•Jg"¨_í2HWcs´ê™PLÌÍÎ@°OvPw
append=T! op™P•€•Jkµ‹2HWcs³´MŠ‹2íPóœM™Pw
output.file <- choose.files()-------------------my2gram <- function(a,b){# »ÁÒmdL
output.file <- choose.files()lines.tmp <- scan(choose.files(), what="char", sep="¥n")data.tmp <- grep("¥¥*(JPN|NS)...:¥t", lines.tmp, value=T)
body.tmp <- gsub("¥¥*(JPN|NS)...:¥t", "", data.tmp)
body.tmp <- body.tmp[body.tmp != ""] #S—k©ªwword.tmp <- unlist(strsplit(body.tmp, "¥¥W+")))DE*+2”ef!‘Ò*ÕÖÕÖM

# ¶GE*¨=for (i in 1:length(word.tmp)-1) {cat(word.tmp[i], word.tmp[i+1], "¥n", file=output.file,append=T)}}-------------------my2gram() T—³´Mop•€•JgkN²+w– 2gram.txt0
ÚMs£¶ðñ•€•Jk•Q¿ÀH•€•JFqfop‚OP
op‚O¯•€•Jk„…†Y2…P
table(scan(choose.files(), what="char", sep="¥n"))R =›MNOP
bigramNS002 <- table(scan(choose.files(), what="char", sep="¥n"))head(sort(bigramNS002, decreasing = T), 10)-------------------myTopBigram <- function(a) {tmp <- table(scan(choose.files(), what="char", sep="¥n"))head(sort(tmp, decreasing=T), a)}-------------------myTopBigram(20)¶Ù;ÙÙ<""#$=z·Jk•Ž+TOEIC 600 ékwM0¸à1¶0¹º»¼=W^2 TOEIC U¸ªªé½=¾kàXŽÙ0{œÈê‚OfZP^Ÿ– – @Begin– – @Participants: JPN002– – @Age: 20– – @Sex: M– – @YearInSchool: U1– – @Major:
medicine– – @StudyHistory: 8– – @OtherLanguage: Spanish=0.6;none=– – @Qualification: TOEIC=620(2005);none=;none=@Begin½0@Qualification =—M¿»– S– ®=—k§Ã±qf_`P– – !@Qualification*FZœGERkÄÅ– S– grep
qualification.tmp <- grep("@Qualification", lines.tmp, value = T)·0®=—M¸ªªé½F_Zf]P^{œ^2stÀÁ™Pw– – TOEIC Hs½öƒ– S– ¸ªªé½Hs¸2RãPw– –– – TOEIC=6– F_Zf]P^kÀÁw– –toeic <- (grep("TOEIC=6", qualification.tmp))º0!stÀÁ=_í1!
if (ÀÁ=st) {ÊË™P‡ÂMT—™P×Ø}¸0grep 2ÄÅq¯¿ÀM!-*UNefZO¾óZw
if (length(toeic) != 0){
T—™P×Ø
}"TOEIC¸ªªé½=¾= Type F Token k±™w
– +myTT =ÏÐ0–-------------------function(){output.file = choose.files()files <- list.files()for (i in files) {lines.tmp <- scan(i, what = "char", sep = "¥n")qualification.tmp <- grep("@Qualification", lines.tmp, value= T)
toeic <- (grep("TOEIC=6", qualification.tmp))
if (length(toeic) != 0){data.tmp <- grep("¥¥*(JPN|NS)...:¥t", lines.tmp, value = T)body.tmp <- gsub("¥¥*(JPN|NS)...:¥t", "", data.tmp)
body.tmp <- body.tmp[body.tmp != ""]body.tmp.lower <- tolower(body.tmp)
words.tmp <- unlist(strsplit(body.tmp.lower, "¥¥W"))
words.tmp <- words.tmp[words.tmp != ""]type <- length(unique(words.tmp))
token <- length(words.tmp)
cat(type, token, "¥n", file = output.file, append = T)}}}-------------------"K9=Ä‹– N•]ÃÄ‹w1– ÄÅ=ÆÇ’ìa. However, such men don't make good husbands.
b. Such men, however, don't make good husbands.
c. Such men don't, however, make good husbands.
d. Such men don't make good husbands, however.
– – – – – – – – – – – – – (Halliday, 1985: 82)G¡ÈG›ÈG¤={|M2°ìc|FU2íPw
TÉHs{œW=^s%&'(2ÊË™Pw#LOB %&'(›= however =ÆÇ’ìk_`¯F|8sÚ=óœW¿ÀMWe¯w
G¡ 109G› 347G¤ 8HfsCËM{|MìZf°óZ=^s®OF°s!ÌÃ*U]P=^w

K9=ÍUsÎÏMóPÐÍ=œ#W=^sÐÍFHÑàWZ=^sN•]ÃÄ‹2_`
Pw-------------------however.data <- c(109, 347, 8)
chisq.test(however.data)-------------------Chi-squared test for given probabilities
data: however.data
X-squared = 391.7371, df = 2, p-value < 2.2e-16-------------------#2.2e-16 §ÒHs2.2"10-6 Ã +dãÃÓFY{ÔA0|=ÕÖdíHsÎÏ=ÐÍFHÑàWZw
!G¤HsÕWZ=2ÓFY{0'WZFqfsG¡FG›=0Z£vM\^Ö×U]P=š8œ^Ÿ
Sugiura, M. (19911Wû 3 8 3 ; 1 <). The Distribution Environmentof the Connective "However" and the Principle of Its Position --Based on the LOB Corpus---. Ø›¢5"ÙjÚÛ5"ÜaÈÑÒG›ÝÞß, 2,
47-63.
http://oscar.gsid.nagoya-u.ac.jp/paper/sugiura1991distribution.pdf"mÚÛ=K9Ík¸àPw•àn()ÒF

lnN)Ò2s therefore =ÆÇ’ìMáZU]P^w’ì– )– âG¡– 15– 38
G›– 96– 53|O°N•]ÃÄ‹w-------------------therefore.data <- matrix(c(15,96,38,53), nrow=2, ncol=2)#matrix 2—whûwnrow H—Dsncol HRDw|=‡ÂH 2"2-------------------– – [,1]– [,2][1,]– 15– 38[2,]– 96– 53-------------------chisq.test(therefore.data)

--------------------------¿À=±²----------------------Pearson's Chi-squared test with Yates' continuity correction
data: therefore.data
X-squared = 19.1788, df = 1, p-value = 1.190e-05----------------------------------------------------------------+¿À=øãw0•àn()ÒF lnN)Ò2stherefore =ÆÇ’ìM¦§WÌÃU]Pw!{|MÍU]P^H!äÍ£¶*k™Pw!F|8Usåæ='£ö&>MHäÍ£¶=9DHGãOfZWZw–– ç=¾Uhe¯°=k0'"f°Xœw–– ¶0•€•Jk>?@A&BqfsèÛMopqfs®Ok/Ðw
– – – 9Dk34(5•€•J2opqfséêjk!.R*M™Pw– – –– – – source(choose.files())– 2s•€•Jk„…†˜w– – –– Ù0L@Ö•@=•€•Jk®=ãã URL 2Š‹qf„…†˜w–– – – ëì5"=íî Æ=ï•5– – – http://aoki2.si.gunma-u.ac.jp/R/– – –– – – 9DM9™PÄ‹– – – N•mÃ£¥k0Ð™Phðº=Ä‹FäÍ£¶– – –– – – source("http://aoki2.si.gunma-u.ac.jp/R/src/my-chisq-test.R",
encoding="euc-jp")– – – my-chisq-test.R– – –– – – £¶q¯ZD-k9DMñÃs¿ÀkCD a M½Nw
– – –– – – a <- my.chisq.test(matrix(c(15,96,38,53), nrow=2, ncol=2))
– – –
– – –
– – – --------------------------¿À=±²----------------------N•mÃ£¥kÐZPhðº=Ä‹+äÍ£¶0
data: matrix(c(15, 96, 38, 53), nrow = 2, ncol = 2)
X-squared = 20.6124, df = 1, p-value = 5.623e-06-----------------------------------------------------------# ]{ÁMHäÍ£¶ã2±²qfcOWZw*¦kT—w> summary(a)--------------------------¿À=±²----------------------_ò‚O¯äÍ
– – – [,1]– – [,2][1,]– -4.5401– 4.5401[2,]– 4.5401– -4.5401
p – – – [,1]– – – – [,2][1,]– 5.6231e-06– 5.6231e-06[2,]– 5.6231e-06– 5.6231e-06-----------------------------------------------------------+¿À=øãw0N•mÃÄ‹=¿ÀóÃs•àn()ÒF lnN)Ò2stherefore =ÆÇ’ìM¦§WÌÃU]PwäÍ£¶=¿ÀóÃs•àn()Ò2Hs lnN)ÒM’`fs
therefore kG›2ÐZPK9U¦§MócsG¡2ÐZPK9U¦§MôZ|FU£^Pw"ðDõ9’+G (% 0#ÑÒx&ƒHÌÃU]ÃsN•mÃ£¥Mö÷‚"P|FMHø7U]P¯äsðDõ
9’k/Ð™P1UùãqZFZœŠúU]Pw
source("http://aoki2.si.gunma-u.ac.jp/R/src/G2.R", encoding="eucjp")·û£¶q¯ZD-k9DMñÃs¿ÀkCD a M½N> G2(matrix(c(15,96,38,53), nrow=2, ncol=2))--------------------------¿À=±²----------------------ðDõ9’M€üchðº=Ä‹+G-squared test0
data: matrix(c(15, 96, 38, 53), nrow = 2, ncol = 2)G-squared = 20.9249, df = 1, p-value = 4.776e-06-----------------------------------------------------------------+¿À=øãw0
p< .001 óÃs•àn()ÒF lnN)Ò2stherefore =ÆÇ’ìM¦§WÌÃU]Pw*¨