Solved

Deleting anonymous variables in a Prolog list

Posted on 2007-11-17
6
396 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

630 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