从文本中提取名词+名词或(形容词|名词)+名词 [英] Extracting noun+noun or (adj|noun)+noun from Text

查看:90
本文介绍了从文本中提取名词+名词或(形容词|名词)+名词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请问R包openNLP中是否可以提取名词+名词或(adj|noun)+名词?也就是说,我想使用语言过滤来提取候选名词短语.你能指导我怎么做吗?非常感谢.

I would like to query if it is possible to extract noun+noun or (adj|noun)+noun in R package openNLP?That is, I would like to use linguistic filtering to extract candidate noun phrases. Could you direct me how to do? Many thanks.

感谢您的回复.这是代码:

Thanks for the responses. here is the code:

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上的index来提取名词+名词或(形容词|名词)+名词.(代码不是最佳的,但有效.如果您有任何想法,请告诉我.)


Reader can refer index on acqTagSplit to do noun+noun or (adj|noun)+noun extractation. (The code is not optimum but work. If you have any idea, please let me know.)

此外,我还有一个问题.

Furthermore, I still have a problem.

Justeson 和 Katz (1995) 提出了另一种语言过滤来提取候选名词短语:

Justeson and Katz (1995) proposed another linguistic filtering to extract candidate noun phrases:

((Adj|Noun)+|((Adj|Noun)(Noun-Prep)?)(Adj|Noun))名词

((Adj|Noun)+|((Adj|Noun)(Noun-Prep)?)(Adj|Noun))Noun

我不太明白它的意思.你能帮我解释一下或将这种表示形式转换成 R 语言吗?非常感谢.

I cannot well understand its meaning. Could you do me a favor to explain it or transform such representation into R language. Many thanks.

推荐答案

这是可能的.

你明白了.使用 POS 标记器并在空格上拆分:ll <- strsplit(acqTag,' ').从那里迭代输入列表的长度(ll 的长度),例如:for (i in 1:37){qq <-strsplit(ll[[1]][i],'/')} 并获取您正在寻找的词性序列.

You got it. Use the POS tagger and split on spaces: ll <- strsplit(acqTag,' '). From there iterate on the length of the input list (length of ll) like: for (i in 1:37){qq <-strsplit(ll[[1]][i],'/')} and get the part of speech sequence you're looking for.

在空格上拆分后,它只是在 R 中进行列表处理.

After splitting on spaces it is just list processing in R.

这篇关于从文本中提取名词+名词或(形容词|名词)+名词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆