[Language Processing and Python] 10.5 paragraph semantic Layer

Source: Internet
Author: User
Tags nltk

A paragraph is a sequence of sentences.

Paragraph Representation Theory

The Quantization Standard Method in the first-order logic is limited to a single sentence, but some quantifiers can be expanded to more than two sentences.

See the following example:

(54&own(Angus, x)&bite(x, Irene))

The objective of Discourse RepresentationTheory (DRT) is to provide a way to process this and other semantic phenomena that seem to be the features of a paragraph.

DRS (discourse representation structure, DRS) Section representation structure

:

>>> Drs1 = dp. parse (>>>

You can view the visual effect:

>>>drs1.draw()

& Dog (y) & own (x, y ))

The DRT expression has the DRS join operator, which is expressed as +.

>>>drs2 = dp.parse(>>>+>>>

One DRS is embedded into another DRS. This is the way in which the full name quantifiers are processed.

 

>>>drs3 = dp.parse(>>>-> exists y.(ankle(y) &bite(x,y)))

If DRS contains conditions in the PRO (x) format, replace the resolve_anaphora () method with x = [...] format conditions, where [...] is a possible first-line word linked list.

>>>drs4 = dp.parse(>>>drs5 = dp.parse(>>>drs6 = drs4 +>>>>>>= [x,y,z]), irene(z), bite(u,z)])

The existing mechanism of DRS processing and processing λ abstraction is compatible.

Det[NUM=sg,SEM=<\P Q.([x],[])+ P(x)+ Q(x)>]-> =sg,SEM=<\P Q.exists x.(P(x)&Q(x))>]-> 

For example, a dog:

(NP[NUM=, SEM=<\Q.(([x],[dog(x)])+ Q(x))>, SEM=<\PQ.((([x],[])+ P(x))+ Q(x))>=, SEM=<\x.([],[dog(x)])>=, SEM=<\x.([],[dog(x)])>]dog)))))

We can use the DRT Parsing Method to parse sentences:

 

>>> nltk >>>parser= load_parser(, logic_parser=>>>trees = parser.nbest_parse(>>> trees[0].node[

Paragraph Processing

A paragraph is a sentence sequence, s1, s2, s3... The paragraph line is the sequential s1-ri of reading ,... Sn-f.

>>>dt =nltk.DiscourseTester([,>>>-r0: exists x.(student(x)&-r0: all x.(student(x)-> person(x))

We can add sentences and delete sentences at any time. Setting consistchk = True can check the reading sequence that can be received to check the consistency of the module:

>>>dt.add_sentence(,consistchk=, , -r0: exists x.(student(x)&-r0: all x.(student(x) ->-r0: -exists x.(person(x)&>>>dt.retract_sentence(,verbose= a person

We use informchk = True to check whether the new sentence.

 

>>>dt.add_sentence(,informchk=under reading 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.