【题目和解决】NLTK7.6节nltk.sem碰到的题目

    添加时间:2013-5-15 点击量:

    Traceback (most recent call last):
    
    File
    <pyshell#155>, line 3, in <module>
    print nltk.sem.show_raw_rtuple(rel,Icon=True,rcon=True)
    AttributeError:
    module object has no attribute show_raw_rtuple


    在7.6关系抽取中,有如许一段代码



    >>>IN = re.compile(r.\bin\b(?!\b.+ing)
    >>>for docin nltk.corpus.ieer.parsed_docs(NYT_19980315):
    ...
    for rel in nltk.sem.extract_rels(ORGLOC, doc,
    ... corpus
    =ieer,pattern = IN):
    ...
    print nltk.sem.show_raw_rtuple(rel)
    [ORG:
    WHYY] in [LOC: Philadelphia]
    [ORG:
    McGlashan &AMP;Sarrail]firm in [LOC: San Mateo]
    [ORG:
    Freedom Forum]in [LOC: Arlington]
    [ORG:
    Brookings Institution] , the research group in [LOC: Washington]
    [ORG:
    Idealab] , a self-described businessincubator basedin [LOC: Los Angeles]
    [ORG:
    Open Text], basedin [LOC: Waterloo]
    [ORG:
    WGBH] in [LOC: Boston]
    [ORG:
    Bastille Opera]in [LOC: Paris]
    255
    [ORG:
    Omnicom] in [LOC: New York]
    [ORG:
    DDB Needham]in [LOC: New York]
    [ORG:
    Kaplan ThalerGroup]in [LOC: New York]
    [ORG:
    BBDO South]in [LOC: Atlanta]
    [ORG:
    Georgia-Pacific] in [LOC: Atlanta]


    此中有一句是


    nltk.sem.show_raw_rtuple(rel),然则运行呈现了错误,提示没有此办法。
    经过查询NLTK.sem的文档,发明这些函数都在更深的处所。也就是
    nltk.sem.relextract中。
    详情请参考:
    http://nltk.googlecode.com/svn/trunk/doc/api/nltk.sem.relextract-module.html
    读书,不要想着实用,更不要有功利心。读书只为了自身的修养。邂逅一本好书如同邂逅一位知己,邂逅一个完美之人。有时心生敬意,有时怦然心动。仿佛你心底埋藏多年的话,作者替你说了出来,你们在时光深处倾心相遇的一瞬间,情投意合,心旷神怡。
    分享到: