caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Ingo Bormuth <ibormuth@efil.de>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] ocamlagrep anybody ?
Date: Mon, 08 May 2006 14:10:55 +0200	[thread overview]
Message-ID: <445F354F.1060301@inria.fr> (raw)
In-Reply-To: <20060508075730.GA19558@kruemel>

> ocamlagrep produces strange results in my hands:
>
>   let p =  Agrep.pattern "test" ;;
>   let s = "Hello test world." ;;
>   let l = String.length s ;;
>
>   Agrep.errors_substring_match p s ~numerrs:0 ~pos:0 ~len:l
>
>     ==> returns 0   ( as expected )
>
>   Agrep.errors_substring_match p s ~numerrs:3 ~pos:0 ~len:l
>
>     ==> returns 3   ( why ??? Should be 0 !!! )
>
> I tried many other combinations and do not get what's going on.

It's been a long time since I wrote this library, but AFAIK
Agrep stops at the first (approximate) match found.
So, in your example with numerrs=0 it scans s all the way to "test"
and reports success; and in your example with numerrs=3 it stops
at "Hell" (a 3-error match) and reports success.

In other terms, the integer returned by errors_substring_match
is not the minimal number of errors for a match over the whole text.
If that's what you want, you can obtain that number by repeated calls
to errors_substring_match using binary search on the value of numerrs.

- Xavier Leroy


  reply	other threads:[~2006-05-08 12:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-08  7:57 Ingo Bormuth
2006-05-08 12:10 ` Xavier Leroy [this message]
2006-05-08 15:35   ` [Caml-list] " Ingo Bormuth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=445F354F.1060301@inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=ibormuth@efil.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).