Prolog and Regexp

Prolog and Regexp

Post by DjamSedda » Thu, 21 Oct 2004 22:34:50


ello,
I've found a paper which deals with treatments of regular expression in
prolog here
(http://www.cs.sfu.ca/people/Faculty/cameron/Teaching/384/99-3/regexp-plg.html

and whereas the provided exemple works for short amout of data
it didn't for large chunk of text...
In fact, i'm feaching webpage and I put them into a string, I just have
to fetch some pattern, no need to write a true parser with the ppp...
Of course before I've tried with unification pattern (transforming
string to atom and using atom_concat), I tried with substring search and
the result was "bof", so I digged to find this package
and I'm not happy whith the result....

look at this exemple


%%%%%% copy the entire predicate until its end
test_def(chien,'<TITLE> Dictionnaire
Français-Anglais</TITLE>\n<META HTTP-EQUIV="Expires"
CONTENT="\nTue Oct 19 14:30:04 WET DST 2004\n">\n<BODY BGCOLOR=#8FAAAA
BACKGROUND = "/textures/paper.gif">\n<HTML>\nBienvenue à <b>
</b><DT>\nutilisant <b>SWI-Prolog (http://www.swi-prolog.org)
</b><DT>\n<H3>\n19 Octobre 2004\n14:30:13\n<br>\nRultat de la
recherche pour le mot : \nchien\n<DT> </H3> \n<table border=0><tr><th
align=left bgcolor=white>\n<b><pre>\n<font color=green>\nchien = dog
(nom masculin)\n<hr></font><font color=red>\nchien = dog (n/a)\nchien =
dog (nom masculin)\nchien = dog (n/a)\nchien = dog (n/a)\nchien = dot
(n/a)\nmaison de chien = doghouse (n/a)\nchien = cat (n/a)\nchien = dog
(nom masculin)\nchien = dog (nom masculin)\nchien = dog (n/a)\nchien =
dog (n/a)\nchien = dog (nom masculin)\nchien = god (nom masculin)\nchien
= dog (nom masculin)\nchien = chien (nom finin)\nchien = chien
(verbe)\ngod = chien (verbe)\nchien = dog (n/a)\nCHIEN = DOG
(n/a)\nCHIEN = HOON (nom masculin)\nchien = cat (n/a)\nchien = crote
(n/a)\nchien = dog (nom masculin)\nchien = dog (n/a)\nchien = dog
(n/a)\nchien = dog (n/a)\nchien = chien (nom masculin)\nchien = chien
(nom masculin)\nchien = cat (nom masculin)\nchien = dog (nom
masculin)\nchien = dog (nom masculin)\nchien = dog (n/a)\nchien = drop
(n/a)\npanier chien = basket (n/a)\nchien = dog (nom masculin)\nun
chien = a cabot-cat (prosition, autre)\nchien = crawler (n/a)\nun
chien = the dog (n/a)\nchien = dog (nom masculin)\nthug life = vie de
chien (n/a)\nCHIEN = DOG (n/a)\nchien = dog (n/a)\nchien = dog
(n/a)\nchien = dog (n/a)\nchien = yes (n/a)\nchien = dog (nom
masculin)\nchien = dog (nom masculin)\nchien = dog (nom masculin)\nchien
= dog (nom masculin)\nchien = dog (nom masculin)\nchien = dog
(n/a)\nchien = dog (nom masculin)\nchien = dog (n/a)\nChien = Dog (nom
masculin)\nchien = dog (nom masculin)\nCHIEN = palps (n/a)\nchien = dog
(n/a)\nle chien = dog (n/a)\nCHIEN = DOG (n/a)\<<* TEXTE EN
ROUGE * =< trouvdans les propositions rentes (found in recent
submissions< CAN BE
WRON<!<n<><><n SRC="/cgi-bin/count2_a?tradu>"><n<>R>\nSi cette recherche n`a pas
abouti, ou si le résultat ne vous convient pas.<n<>3>Maintenant
sur ce serveur < \n Proposez votre traduction! < <><><n<><>\<[Recherch<|<>a<
 
 
 

Prolog and Regexp

Post by DjamSedda » Thu, 21 Oct 2004 22:37:02

ello,
I've found a paper which deals with treatments of regular expression in
prolog here
(http://www.cs.sfu.ca/people/Faculty/cameron/Teaching/384/99-3/regexp-plg.html

and whereas the provided exemple works for short amout of data
it didn't for large chunk of text...
In fact, i'm feaching webpage and I put them into a string, I just have
to fetch some pattern, no need to write a true parser with the ppp...
Of course before I've tried with unification pattern (transforming
string to atom and using atom_concat), I tried with substring search and
the result was "bof", so I digged to find this package
and I'm not happy whith the result....

look at this exemple


%%%%%% copy the entire predicate until its end
test_def(chien,'<TITLE> Dictionnaire
Français-Anglais</TITLE>\n<META HTTP-EQUIV="Expires"
CONTENT="\nTue Oct 19 14:30:04 WET DST 2004\n">\n<BODY BGCOLOR=#8FAAAA
BACKGROUND = "/textures/paper.gif">\n<HTML>\nBienvenue à <b>
</b><DT>\nutilisant <b>SWI-Prolog (http://www.swi-prolog.org)
</b><DT>\n<H3>\n19 Octobre 2004\n14:30:13\n<br>\nRultat de la
recherche pour le mot : \nchien\n<DT> </H3> \n<table border=0><tr><th
align=left bgcolor=white>\n<b><pre>\n<font color=green>\nchien = dog
(nom masculin)\n<hr></font><font color=red>\nchien = dog (n/a)\nchien =
dog (nom masculin)\nchien = dog (n/a)\nchien = dog (n/a)\nchien = dot
(n/a)\nmaison de chien = doghouse (n/a)\nchien = cat (n/a)\nchien = dog
(nom masculin)\nchien = dog (nom masculin)\nchien = dog (n/a)\nchien =
dog (n/a)\nchien = dog (nom masculin)\nchien = god (nom masculin)\nchien
= dog (nom masculin)\nchien = chien (nom finin)\nchien = chien
(verbe)\ngod = chien (verbe)\nchien = dog (n/a)\nCHIEN = DOG
(n/a)\nCHIEN = HOON (nom masculin)\nchien = cat (n/a)\nchien = crote
(n/a)\nchien = dog (nom masculin)\nchien = dog (n/a)\nchien = dog
(n/a)\nchien = dog (n/a)\nchien = chien (nom masculin)\nchien = chien
(nom masculin)\nchien = cat (nom masculin)\nchien = dog (nom
masculin)\nchien = dog (nom masculin)\nchien = dog (n/a)\nchien = drop
(n/a)\npanier chien = basket (n/a)\nchien = dog (nom masculin)\nun
chien = a cabot-cat (prosition, autre)\nchien = crawler (n/a)\nun
chien = the dog (n/a)\nchien = dog (nom masculin)\nthug life = vie de
chien (n/a)\nCHIEN = DOG (n/a)\nchien = dog (n/a)\nchien = dog
(n/a)\nchien = dog (n/a)\nchien = yes (n/a)\nchien = dog (nom
masculin)\nchien = dog (nom masculin)\nchien = dog (nom masculin)\nchien
= dog (nom masculin)\nchien = dog (nom masculin)\nchien = dog
(n/a)\nchien = dog (nom masculin)\nchien = dog (n/a)\nChien = Dog (nom
masculin)\nchien = dog (nom masculin)\nCHIEN = palps (n/a)\nchien = dog
(n/a)\nle chien = dog (n/a)\nCHIEN = DOG (n/a)\<<* TEXTE EN
ROUGE * =< trouvdans les propositions rentes (found in recent
submissions< CAN BE
WRON<!<n<><><n SRC="/cgi-bin/count2_a?tradu>"><n<>R>\nSi cette recherche n`a pas
abouti, ou si le résultat ne vous convient pas.<n<>3>Maintenant
sur ce serveur < \n Proposez votre traduction! < <><><n<><>\<[Recherch<|<>a<
 
 
 

Prolog and Regexp

Post by vannoor » Thu, 28 Oct 2004 22:40:28


>> Hello, >> I've found a paper which deals with treatments of regular expression in >> prolog here >> ( http://www.yqcomputer.com/ >> >> and whereas the provided exemple works for short amout of data >> it didn't for large chunk of text... >> In fact, i'm feaching webpage and I put them into a string, I just have >> to fetch some pattern, no need to write a true parser with the ppp... >> Of course before I've tried with unification pattern (transforming >> string to atom and using atom_concat), I tried with substring search and >> the result was "bof", so I digged to find this package >> and I'm not happy whith the result.... >> >>

for other regular expression tools in Prolog, cf
http://www.yqcomputer.com/ ~vannoord/prolog-rx/PrologAndRegex.html
 
 
 

Prolog and Regexp

Post by djam » Fri, 29 Oct 2004 03:09:11

Gertjan van Noord a rit :
>> >>>Hello, >>>I've found a paper which deals with treatments of regular expression in >>>prolog here >>>( http://www.yqcomputer.com/ >>> >>>and whereas the provided exemple works for short amout of data >>>it didn't for large chunk of text... >>>In fact, i'm feaching webpage and I put them into a string, I just have >>>to fetch some pattern, no need to write a true parser with the ppp... >>>Of course before I've tried with unification pattern (transforming >>>string to atom and using atom_concat), I tried with substring search and >>>the result was "bof", so I digged to find this package >>>and I'm not happy whith the result.... >>> >>> >> >> >> for other regular expression tools in Prolog, cf >> http://www.yqcomputer.com/ ~vannoord/prolog-rx/PrologAndRegex.html
Thanks a lot, I just realized why I didn't find your page first : my
google request was Prolog+regexp, the one to find your page is Prolog+regex.


Thanks a lot, really.


Djam
ps : by the way, do you know why the treatment of string by regexp is
not an official part of the common Prolog ? is this because there's a
"double emploi" (I don't know the english translation, maybe "double
work" ?) between pure regexp and pattern matching ? some times regexp
are reallys usefull :), now my work will be to make some of these
packages work with some of prolog2java interface.......

Cheers
 
 
 

Prolog and Regexp

Post by W » Thu, 04 Nov 2004 08:42:52

Because its origin is in 1st order logic, where there are things (atoms) and
relations among them. there was a nod to decimal arithmetic for efficiency.
3 doesn't have to be represented as +(+(+(0))). but generally people were
not trying to state truths about strings. grammars got introduced as DCGs.
which seem to work fine.

I love Prolog but usually do my string processing with Perl or awk.

Walter Wilson




news<<41766a2b$0$533$ XXXX@XXXXX.COM >>... >>>> >> . . . >> ps : by the way, do you know why the treatment of string by regexp is >> not an official part of the common Prolog ? ...
 
 
 

Prolog and Regexp

Post by Tom Howlan » Mon, 20 Dec 2004 08:26:40

Once upon a time I did a careful comparison of regex processors in C and
found that regex over giant strings is best optimized by the regex in
Emacs. Perl regex is optimized for line processing but Emacs works over
the entire buffer.