?
Solved

Deleting anonymous variables in a Prolog list

Posted on 2007-11-17
6
Medium Priority
?
420 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
5 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

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

599 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