0
複数の値を持つ属性内のいくつかの属性値をprint
に選択したいとします。複数の値を持つxml-tei属性内の属性値を選択
[[1]]
<ref ana="whatAction #ktu1-3_ii_l6b_tḫtṣb #verb.competition #contend">Action belongs to verb competition subcategory contend
<stage ana="whatResult #result #defeate_ofOpposition"/></ref>
[[2]]
<ref ana="whatAction #ktu1-3_ii_l7_tmḫṣ #verb.emotion #humiliation">Action belongs to verb emotion, subcategory humiliation
<stage ana="whatResult #result #defeate_ofOpposition"/></ref>
[[3]]
<ref ana="whatAction #ktu1-3_ii_l8_tṣmt #verb.emotion #humiliation">Action belongs to verb emotion, subcategory humiliation</ref>
#print
[1] "whatAction #ktu1-3_ii_l6b_tḫtṣb #verb.competition #contend"
[1] "whatAction #ktu1-3_ii_l7_tmḫṣ #verb.emotion #humiliation"
[1] "whatAction #ktu1-3_ii_l8_tṣmt #verb.emotion #humiliation"
私は@ana
属性からわずか数の属性値を必要とし、2値及び3、例print
に:
[1] "#ktu1-3_ii_l6b_tḫtṣb #contend"
[1] "#ktu1-3_ii_l7_tmḫṣ #humiliation"
[1] "#ktu1-3_ii_l8_tṣmt #humiliation"
私が持っているこの例では
#in R
interpRef <- getNodeSet(doc,"//ns:ref[contains(@ana, 'whatAction')]", ns)
interpRef_ana <- for (i in 1:length(interpRef)) print(paste(xmlGetAttr(interpRef[[i]],"ana")))
私は結果を持っています次のものの中でいくつかの試みを行ったが、機能していない。
interpRef_ana <- for (i in 1:length(interpRef)) print(paste(xmlGetAttr(interpRef[[i]],"ana",[2:3])))
==== XML例====
各<ref>
は<interp>
内にあり、各@ana
語彙が事前定義された分類に由来するのと同じ階層構造に従います。
<interp xml:id="ktu1-3_ii_l6b_int" ana="#ktu1-3_ii_l6b" corresp="#ktu1-3_ii_6b">
<desc>
<ref ana="whatAction #ktu1-3_ii_l6b_tḫtṣb #verb.competition #contend"
>Action belongs to verb competition subcategory contend
<stage ana="whatResult #result #defeate_ofOpposition" />
</ref>
<castList>
<castItem>
<persName type="character" ana="#whatCharacter #Character #ANT #Female">
<state ana="#whatRole #active" />ʾAnatu
</persName>
</castItem>
</castList>
<view>
<placeName ana="#whatContext #battle">battle
<location ana="#whatSphere #outside" />
</placeName>
</view>
<stage ana="#whatBehavior">
<span ana="#toDestroy #five_dD #rage">Voluntary
intentionality, to destroy of her free will, with rage
(level five).</span>
<span ana="#AffectEntity_and_other">The result of action has
an impact on ʾAnatu and others</span>
</stage>
</desc>
</interp>
<interp xml:id="ktu1-3_ii_l7_int" ana="#ktu1-3_ii_l7" corresp="#ktu1-3_ii_l7">
<desc>
<ref ana="whatAction #ktu1-3_ii_l7_tmḫṣ #verb.emotion #humiliation"
>Action belongs to verb emotion, subcategory humuliation
<stage ana="whatResult #result #defeate_ofOpposition" />
</ref>
<castList>
<castItem>
<persName type="character" ana="#whatCharacter #Character #ANT #Female">
<state ana="#whatRole #active" />ʾAnatu
</persName>
<persName type="character" cert="low" ana="#Character #UNK #Unknown">
<state ana="#behav #passive" />People from the West
</persName>
</castItem>
</castList>
<view>
<placeName ana="#whatContext #battle">battle
<location ana="#whatSphere #outside" />outside her household
</placeName>
</view>
<stage ana="#whatBehavior">
<span ana="#toDestroy #free #five_dD">Voluntary
intentionality, to destroy of her free will, with rage
(level five)Five.</span>
<span ana="#affectEntity_and_other">The result of action has
an impact on ʾAnatu and others</span>
</stage>
</desc>
</interp>
====更新====
私は私が必要とする属性値を選択することができ、theoriticalyそれは動作しますが、ライブラリstring
を使用しようとしました:
x <- for (i in 1:length(interp)) print((cbind((y=(KTU = (xmlGetAttr(interp[[i]],"ana")))), (z=(verb.category = (xmlGetAttr(interpRef[[i]],"ana")))))))
x1 <- print (cbind(word(word(y,-1)),(word(z, -3, -2))))
x1
> x <- for (i in 1:length(interp)) print((cbind((y=(KTU = (xmlGetAttr(interp[[i]],"ana")))), (z=(verb.category = (xmlGetAttr(interpRef[[i]],"ana")))))))
[,1] [,2]
[1,] "#ktu1-3_ii_l5b-6a" "whatAction #ktu1-3_ii_l5b-6a_tmtḫṣ #verb.competition #contend"
[,1] [,2]
[1,] "#ktu1-3_ii_l6b" "whatAction #ktu1-3_ii_l6b_tḫtṣb #verb.competition #contend"
[,1] [,2]
[1,] "#ktu1-3_ii_l7" "whatAction #ktu1-3_ii_l7_tmḫṣ #verb.emotion #humiliation"
[,1] [,2]
[1,] "#ktu1-3_ii_l8" "whatAction #ktu1-3_ii_l8_tṣmt #verb.emotion #humiliation"
[,1] [,2]
[1,] "ktu1-3_ii_l11b_12a" "whatAction #ktu1-3_ii_l11b-12a_ʿtkt #put_together #action"
[,1] [,2]
[1,] "#ktu1-3_ii_l12b_13a" "whatAction #ktu1-3_ii_l12b-13a_šnst #put_together #action"
[,1] [,2]
[1,] "#ktu1-3_ii_l13b_14a" "whatAction #ktu1-3_ii_l13b-14a_tġlt #action #movement"
[,1] [,2]
[1,] "#ktu1-3_ii_l15b_16a" "whatAction #ktu1-3_ii_l5b_6a_tmtḫṣ #confrontation #action"
> x
NULL
> x1 <- print (cbind(word(word(y,-1)),(word(z, -3, -2))))
[,1] [,2]
[1,] "#ktu1-3_ii_l15b_16a" "#ktu1-3_ii_l5b_6a_tmtḫṣ #confrontation"
> x1
[,1] [,2]
[1,] "#ktu1-3_ii_l15b_16a" "#ktu1-3_ii_l5b_6a_tmtḫṣ #confrontation"
しかし、ただ1つのオカレンスの属性値を返し、リストは返しません。だから私はfor (i in 1:length(interp))
を追加しようとしました:
x1 <- for (i in 1:length(interp)) print (cbind(word(word(y,-1)),(word(z, -3, -2))))
> x1 <- for (i in 1:length(interp)) print (cbind(word(word(y,-1)),(word(z, -3, -2))))
[,1] [,2]
[1,] "#ktu1-3_ii_l15b_16a" "#ktu1-3_ii_l5b_6a_tmtḫṣ #confrontation"
[,1] [,2]
[1,] "#ktu1-3_ii_l15b_16a" "#ktu1-3_ii_l5b_6a_tmtḫṣ #confrontation"
[,1] [,2]
[1,] "#ktu1-3_ii_l15b_16a" "#ktu1-3_ii_l5b_6a_tmtḫṣ #confrontation"
[,1] [,2]
[1,] "#ktu1-3_ii_l15b_16a" "#ktu1-3_ii_l5b_6a_tmtḫṣ #confrontation"
[,1] [,2]
[1,] "#ktu1-3_ii_l15b_16a" "#ktu1-3_ii_l5b_6a_tmtḫṣ #confrontation"
[,1] [,2]
[1,] "#ktu1-3_ii_l15b_16a" "#ktu1-3_ii_l5b_6a_tmtḫṣ #confrontation"
[,1] [,2]
[1,] "#ktu1-3_ii_l15b_16a" "#ktu1-3_ii_l5b_6a_tmtḫṣ #confrontation"
[,1] [,2]
[1,] "#ktu1-3_ii_l15b_16a" "#ktu1-3_ii_l5b_6a_tmtḫṣ #confrontation"
> x1
は、私はちょうどあなたの助けのために同じ出現を8回(=実際の発生回数)を予め
、感謝を繰り返します。
あなたがXMLのそれを切り取る小さなを投稿してくださいますか?私は通常、これとはちょっと違って、あなたがここにいるのとは少し違っています。私は以下の回答を投稿しました - それはあなたのケースに合っていませんが、それは参考になるかもしれません。私はあなたがXMLのスニップイットを掲示すれば調整してうれしい –
私はあなたの質問を誤解しているかもしれませんが、XMLのそれをスナップしています。私は助けることができると確信しています。 –
ありがとうIan。私は== XMLの後にサンプルを追加しました===。 – Vanessa