×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

PCFG and Prolog

PCFG and Prolog

PCFG and Prolog

(OP)
Hello guys,

I have a problem and I need your help. I'm a super beginner in Prolog, so all my efforts in the last few days didn't give me any result!
I have a parser (Probabilistic Context-Free Grammar) and 10 sentences. When I compile the parser, and parse each of these sentences, it gives me 2 or 3 parse trees with their probabilities. my problem is that for some of the sentences, the parse tree with highest probability is not what I expect (I have the desired parse trees and I can compare them with my result).

I want to improve the grammar (without changing the probabilities) to get correct results for all sentences. I know what the problem is. It's the relation of propositional phrases and the verb. I think I have to add some constraints to my code (i.e. when the verb is 'put' the propositional phrase should be in same level with verb and noun phrase [emphasize verb phrase], and when the verb is 'take' propositional phrase should emphasize the noun phrase). But I don't know how to do it!

Any help would be greatly appreciated.

Thanks,

Jonathan

RE: PCFG and Prolog

I take a look at your code.
I think that you can use dynamic facts to know what kind of verb is used.
Your code of pcfg2.pl could be

CODE

:- dynamic emphasis/1.

s(P0, s(V, NP)) --> 
	v(P1, V), 
	np(P2, NP), 
	{emphasis(Emph),
	 % use of Emph
	 %  P0 is ....
	 % instead of 
	 P0 is P1*P2*0.35
	}.
s(P0, s(V, NP, PP)) --> 
	v(P1, V), 
	np(P2, NP), 
	pp(P3, PP), 
	{emphasis(Emph),
	 % use of Emph (put or take)
	 %  P0 is ....
	 % instead of 
	 P0 is P1*P2*P3*0.65}.

np(P0, np(D, N)) --> det(P1, D), n(P2, N), {P0 is P1*P2*0.36}.
np(P0, np(D, A, N)) --> det(P1, D), a(P2, A), n(P3, N), {P0 is P1*P2*P3*0.46}.
np(P0, np(D, N, PP)) --> det(P1, D), n(P2, N), pp(P3, PP), {P0 is P1*P2*P3*0.13}.
np(P0, np(D, A, N, PP)) --> det(P1, D), a(P2, A), n(P3, N), pp(P4, PP), {P0 is P1*P2*P3*P4*0.05}.

pp(P0, pp(P, NP)) --> p(P1, P), np(P2, NP), {P0 is P1*P2*1.0}.

v(0.65, v(put)) --> {assert(emphasis(put)}, [put].
v(0.35, v(take)) --> {assert(emphasis(take)}, [take].
...... 
You must read manual for assert/retract to understand the way to use dynamic facts.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close