From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id E465BBB84 for ; Mon, 8 May 2006 14:10:59 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k48CAxYC021002 for ; Mon, 8 May 2006 14:10:59 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA10776 for ; Mon, 8 May 2006 14:10:58 +0200 (MET DST) Received: from smtp1-g19.free.fr (smtp1-g19.free.fr [212.27.42.27]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k48CAw1P020997 for ; Mon, 8 May 2006 14:10:58 +0200 Received: from [192.168.1.2] (che78-2-82-237-71-191.fbx.proxad.net [82.237.71.191]) by smtp1-g19.free.fr (Postfix) with ESMTP id C76989AA23; Mon, 8 May 2006 14:10:57 +0200 (CEST) Message-ID: <445F354F.1060301@inria.fr> Date: Mon, 08 May 2006 14:10:55 +0200 From: Xavier Leroy User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Ingo Bormuth Cc: caml-list@inria.fr Subject: Re: [Caml-list] ocamlagrep anybody ? References: <20060508075730.GA19558@kruemel> In-Reply-To: <20060508075730.GA19558@kruemel> X-Enigmail-Version: 0.91.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 445F3553.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 445F3552.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ocamlagrep:01 ocamlagrep:01 agrep:01 agrep:01 afaik:01 binary:01 wrote:01 caml-list:01 integer:01 match:02 match:02 len:02 len:02 string:02 pattern:03 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 > 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