Solved

Deleting anonymous variables in a Prolog list

Posted on 2007-11-17
6
383 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
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.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

743 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

14 Experts available now in Live!

Get 1:1 Help Now