Solved

Deleting anonymous variables in a Prolog list

Posted on 2007-11-17
6
386 Views
Last Modified: 2012-05-05
HI,
I have a list in Prolog containing elements and anonymous variables. I extract some elements with unification like

is_NP('NP'|Rest):-
...

the problem is that the list contains anonymous variables like _G123 which will unify with 'NP' f.e. What I want to do is to delete all the anonymous variables before I extract the needed elements. How can this be done? Normally I'd go for regex to match underscore and 'G', but SWI Prolog doesn't really support regex.

One way to do it would be to convert each element to a list itself and then proceed the list and check for the sequence underscore and 'G', but that's ugly and inefficient.
Is there a more simple way to do it?
0
Comment
Question by:Don_T
  • 3
6 Comments
 

Author Comment

by:Don_T
ID: 20311155
EDIT: I upped the points to 250
0
 
LVL 24

Expert Comment

by:fridom
ID: 20311298
I don't understand your problem. Who has put the "anonymous" variables into the list? Why were they put there? Why not simply not add them first? And how about some code which shows your problem? That one can have an idea on what'd you mean?

Regards
Friedrich
0
 

Author Comment

by:Don_T
ID: 20312015
Hi Friedrich
I'm coding a module for a bigger project and the list is generated elsewhere. It needs the anonymous variables for consistency reasons (sometimes the place held by the anonymous variables has a value). The list looks like this f.e.:

[he, PRP, He_PRP, _G229, succeed, VBN, will_MD, be_VB, succeeded_VBN, succeeded,
 by, IN, by_IN, by, ledford, NNP, Rob_NNP, Ledford_NNP, Rob Ledford, of, IN, of_
IN, of, gainesville, NNP, Gainesville_NNP, Gainesville, c, COMMA, C_COMMA, _G346
, who, WP, who_WP, _G364, be, VBN, has_VBZ, been_VBN, been, assistant, NN, an_DT
, assistant_NN, assistant, year, NNS, more_RBR, than_IN, three_CD, years_NNS, ye
ars]

What I do is extracting all NNPs, NNs, NNs, etc. for anaphora resolution. The problem is that if I pass the list to a predicate like:

is_NNP('NNP'|Rest):-
nextto(X, 'NNP', List),
...accept X as possible reference for anaphora resolution...

the anonymous variables in the list will unify with everything (because they hold no value) and deliver any results for X. So what I want is to get rid of all the anonymous variables before I look for possible referents.

0
 

Author Comment

by:Don_T
ID: 20320292
OK, I thought of a solution yesterday, I can check the list elements and see if they're atoms using atom/1 or atomic/1 and rebuild it without the anonymous variables. still not a regex to use delete/1, but works,
regards
Don
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 20633885
PAQed with points refunded (250)

Computer101
EE Admin
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This is about my first experience with programming Arduino.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now