我想查询R包openNLP中是否可以提取名词+名词或(adj|noun)+名词?也就是说,我想使用语言过滤来提取候选名词短语。你能指导我怎么做吗?非常感谢。
感谢您的回复。这是代码:
library("openNLP")
acq <- "Gulf Applied Technologies Inc said it sold its subsidiaries engaged in
pipeline and terminal operations for 12.2 mln dlrs. The company said
the sale is subject to certain post closing adjustments,
which it did not explain. Reuter."
acqTag <- tagPOS(acq)
acqTagSplit = strsplit(acqTag," ")
acqTagSplit
qq = 0
tag = 0
for (i in 1:length(acqTagSplit[[1]])){
qq[i] <-strsplit(acqTagSplit[[1]][i],'/')
tag[i] = qq[i][[1]][2]
}
index = 0
k = 0
for (i in 1:(length(acqTagSplit[[1]])-1)) {
if ((tag[i] == "NN" && tag[i+1] == "NN") |
(tag[i] == "NNS" && tag[i+1] == "NNS") |
(tag[i] == "NNS" && tag[i+1] == "NN") |
(tag[i] == "NN" && tag[i+1] == "NNS") |
(tag[i] == "JJ" && tag[i+1] == "NN") |
(tag[i] == "JJ" && tag[i+1] == "NNS"))
{
k = k +1
index[k] = i
}
}
index
读者可以参考acqTagSplit上的索引来进行名词+名词或(adj|noun)+名词的提取。(代码不是最佳但可以工作。如果您有任何想法,请告诉我。)
此外,我还有一个问题。
Justeson 和 Katz (1995) 提出了另一种语言过滤来提取候选名词短语:
((Adj|Noun)+|((Adj|Noun) (Noun-Prep)?)(Adj|Noun) )名词
我不能很好地理解它的含义。您能否帮我解释一下或将这种表示形式转换为 R 语言。非常感谢。