Return-Path: X-Original-To: apmail-lucene-lucene-net-commits-archive@www.apache.org Delivered-To: apmail-lucene-lucene-net-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D95C32F14 for ; Sat, 7 May 2011 21:34:42 +0000 (UTC) Received: (qmail 48278 invoked by uid 500); 7 May 2011 21:34:42 -0000 Delivered-To: apmail-lucene-lucene-net-commits-archive@lucene.apache.org Received: (qmail 48248 invoked by uid 500); 7 May 2011 21:34:42 -0000 Mailing-List: contact lucene-net-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@lucene.apache.org Delivered-To: mailing list lucene-net-commits@lucene.apache.org Received: (qmail 48238 invoked by uid 99); 7 May 2011 21:34:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 May 2011 21:34:42 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 May 2011 21:34:40 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 20B9D2388901; Sat, 7 May 2011 21:34:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Sat, 07 May 2011 21:34:19 -0000 To: lucene-net-commits@lucene.apache.org From: pnasser@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110507213420.20B9D2388901@eris.apache.org> Subject: [Lucene.Net] svn commit: r1100632 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g: ./ build/vs2010/contrib/ build/vs2010/test/ src/contrib/Regex/ src/contrib/Regex/Properties/ src/core/ src/core/Search/Regex/ test/core/ test/core/Search/Regex/ Author: pnasser Date: Sat May 7 21:34:19 2011 New Revision: 1100632 URL: http://svn.apache.org/viewvc?rev=1100632&view=rev Log: LULUCENENET-371 & LUCENENET-330 - Moving to Contrib, created solution files in build/vs2010 Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/contrib/Contrib.Regex.sln incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/test/Contrib.Regex.Test.sln incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/CSharpRegexCapabilities.cs incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/Contrib.Regex.csproj incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/Contrib.Regex.suo (with props) incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/IRegexCapabilities.cs incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/IRegexQueryCapable.cs incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/Properties/ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/Properties/AssemblyInfo.cs incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/RegexQuery.cs incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/RegexTermEnum.cs incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/SpanRegexQuery.cs Removed: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Regex/ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Search/Regex/ Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/DIFFs FROM 2.9.4.txt incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/contrib/Contrib.All.sln incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/test/Contrib.All.Test.sln incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Lucene.Net.csproj incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Lucene.Net.Test.csproj Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/DIFFs FROM 2.9.4.txt URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/DIFFs%20FROM%202.9.4.txt?rev=1100632&r1=1100631&r2=1100632&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net_2_9_4g/DIFFs FROM 2.9.4.txt (original) +++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/DIFFs FROM 2.9.4.txt Sat May 7 21:34:19 2011 @@ -12,7 +12,7 @@ * LUCENENET-172 (fix for unexceptional exceptions ecountered in FastCharStream) -* LUCENENET-330 Search.Regex Minimal Port +* LUCENENET-330 Search.Regex Minimal Port * LUCENENET-371 Unit test for Search.Regex port Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/contrib/Contrib.All.sln URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/contrib/Contrib.All.sln?rev=1100632&r1=1100631&r2=1100632&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/contrib/Contrib.All.sln (original) +++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/contrib/Contrib.All.sln Sat May 7 21:34:19 2011 @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual C# Express 2010 +# Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net", "..\..\..\src\core\Lucene.Net.csproj", "{5D4AD9BE-1FFB-41AB-9943-25737971BF57}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contrib.Core", "..\..\..\src\contrib\Core\Contrib.Core.csproj", "{FEF899EB-610C-4D3C-A556-A01F56F4AFE0}" @@ -27,6 +27,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contrib.WordNet.Syns2Index", "..\..\..\src\contrib\WordNet\Syns2Index\Contrib.WordNet.Syns2Index.csproj", "{7563D4D9-AE91-42BA-A270-1D264660F6DF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contrib.Regex", "..\..\..\src\contrib\Regex\Contrib.Regex.csproj", "{A26BD3B7-DF90-43B4-99E2-6A617CDE1579}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -85,6 +87,10 @@ Global {7563D4D9-AE91-42BA-A270-1D264660F6DF}.Debug|Any CPU.Build.0 = Debug|Any CPU {7563D4D9-AE91-42BA-A270-1D264660F6DF}.Release|Any CPU.ActiveCfg = Release|Any CPU {7563D4D9-AE91-42BA-A270-1D264660F6DF}.Release|Any CPU.Build.0 = Release|Any CPU + {A26BD3B7-DF90-43B4-99E2-6A617CDE1579}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A26BD3B7-DF90-43B4-99E2-6A617CDE1579}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A26BD3B7-DF90-43B4-99E2-6A617CDE1579}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A26BD3B7-DF90-43B4-99E2-6A617CDE1579}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/contrib/Contrib.Regex.sln URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/contrib/Contrib.Regex.sln?rev=1100632&view=auto ============================================================================== --- incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/contrib/Contrib.Regex.sln (added) +++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/contrib/Contrib.Regex.sln Sat May 7 21:34:19 2011 @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net", "..\..\..\src\core\Lucene.Net.csproj", "{5D4AD9BE-1FFB-41AB-9943-25737971BF57}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contrib.Core", "..\..\..\src\contrib\Regex\Contrib.Regex.csproj", "{A26BD3B7-DF90-43B4-99E2-6A617CDE1579}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A26BD3B7-DF90-43B4-99E2-6A617CDE1579}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A26BD3B7-DF90-43B4-99E2-6A617CDE1579}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A26BD3B7-DF90-43B4-99E2-6A617CDE1579}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A26BD3B7-DF90-43B4-99E2-6A617CDE1579}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/test/Contrib.All.Test.sln URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/test/Contrib.All.Test.sln?rev=1100632&r1=1100631&r2=1100632&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/test/Contrib.All.Test.sln (original) +++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/test/Contrib.All.Test.sln Sat May 7 21:34:19 2011 @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual C# Express 2010 +# Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net", "..\..\..\src\core\Lucene.Net.csproj", "{5D4AD9BE-1FFB-41AB-9943-25737971BF57}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contrib.Core", "..\..\..\src\contrib\Core\Contrib.Core.csproj", "{FEF899EB-610C-4D3C-A556-A01F56F4AFE0}" @@ -39,6 +39,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.Common", "..\..\..\src\demo\Demo.Common\Demo.Common.csproj", "{F04CA2F4-E182-46A8-B914-F46AF5319E83}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contrib.Regex.Test", "..\..\..\test\contrib\Regex\Contrib.Regex.Test.csproj", "{F1875552-0E59-46AA-976E-6183733FD2AB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contrib.Regex", "..\..\..\src\contrib\Regex\Contrib.Regex.csproj", "{A26BD3B7-DF90-43B4-99E2-6A617CDE1579}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -121,6 +125,14 @@ Global {F04CA2F4-E182-46A8-B914-F46AF5319E83}.Debug|Any CPU.Build.0 = Debug|Any CPU {F04CA2F4-E182-46A8-B914-F46AF5319E83}.Release|Any CPU.ActiveCfg = Release|Any CPU {F04CA2F4-E182-46A8-B914-F46AF5319E83}.Release|Any CPU.Build.0 = Release|Any CPU + {F1875552-0E59-46AA-976E-6183733FD2AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F1875552-0E59-46AA-976E-6183733FD2AB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1875552-0E59-46AA-976E-6183733FD2AB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F1875552-0E59-46AA-976E-6183733FD2AB}.Release|Any CPU.Build.0 = Release|Any CPU + {A26BD3B7-DF90-43B4-99E2-6A617CDE1579}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A26BD3B7-DF90-43B4-99E2-6A617CDE1579}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A26BD3B7-DF90-43B4-99E2-6A617CDE1579}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A26BD3B7-DF90-43B4-99E2-6A617CDE1579}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/test/Contrib.Regex.Test.sln URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/test/Contrib.Regex.Test.sln?rev=1100632&view=auto ============================================================================== --- incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/test/Contrib.Regex.Test.sln (added) +++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/build/vs2010/test/Contrib.Regex.Test.sln Sat May 7 21:34:19 2011 @@ -0,0 +1,29 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net", "..\..\..\src\core\Lucene.Net.csproj", "{5D4AD9BE-1FFB-41AB-9943-25737971BF57}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contrib.Regex", "..\..\..\src\contrib\Regex\Contrib.Regex.csproj", "{481CF6E3-52AF-4621-9DEB-022122079AF6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Test", "..\..\..\test\core\Lucene.Net.Test.csproj", "{AAF68BCF-F781-45FC-98B3-2B9CEE411E01}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contrib.Regex.Test", "..\..\..\test\contrib\Regex\Contrib.Regex.Test.csproj", "{F1875552-0E59-46AA-976E-6183733FD2AB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.Common", "..\..\..\src\demo\Demo.Common\Demo.Common.csproj", "{F04CA2F4-E182-46A8-B914-F46AF5319E83}" +EndProject + +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F1875552-0E59-46AA-976E-6183733FD2AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F1875552-0E59-46AA-976E-6183733FD2AB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1875552-0E59-46AA-976E-6183733FD2AB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F1875552-0E59-46AA-976E-6183733FD2AB}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/CSharpRegexCapabilities.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/CSharpRegexCapabilities.cs?rev=1100632&view=auto ============================================================================== --- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/CSharpRegexCapabilities.cs (added) +++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/CSharpRegexCapabilities.cs Sat May 7 21:34:19 2011 @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Lucene.Net.Search.Regex +{ + /// + /// C# Regex based implementation of . + /// + /// http://www.java2s.com/Open-Source/Java-Document/Net/lucene-connector/org/apache/lucene/search/regex/JavaUtilRegexCapabilities.java.htm + public class CSharpRegexCapabilities : IRegexCapabilities, IEquatable + { + private System.Text.RegularExpressions.Regex _rPattern; + + /// + /// Called by the constructor of allowing implementations to cache + /// a compiled version of the regular expression pattern. + /// + /// regular expression pattern + public void Compile(string pattern) + { + _rPattern = new System.Text.RegularExpressions.Regex(pattern, + System.Text.RegularExpressions.RegexOptions.Compiled); + } + + /// + /// True on match. + /// + /// text to match + /// true on match + public bool Match(string s) + { + return _rPattern.IsMatch(s); + } + + /// + /// A wise prefix implementation can reduce the term enumeration (and thus performance) + /// of RegexQuery dramatically. + /// + /// static non-regex prefix of the pattern last passed to . + /// May return null + public string Prefix() + { + return null; + } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// + /// true if the current object is equal to the parameter; otherwise, false. + /// + /// An object to compare with this object + public bool Equals(CSharpRegexCapabilities other) + { + if (other == null) return false; + if (this == other) return true; + + if (_rPattern != null ? !_rPattern.Equals(other._rPattern) : other._rPattern != null) + return false; + + return true; + } + + public override bool Equals(object obj) + { + if (obj as CSharpRegexCapabilities == null) return false; + return Equals((CSharpRegexCapabilities) obj); + } + + public override int GetHashCode() + { + return (_rPattern != null ? _rPattern.GetHashCode() : 0); + } + } +} Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/Contrib.Regex.csproj URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/Contrib.Regex.csproj?rev=1100632&view=auto ============================================================================== --- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/Contrib.Regex.csproj (added) +++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/Contrib.Regex.csproj Sat May 7 21:34:19 2011 @@ -0,0 +1,59 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {A26BD3B7-DF90-43B4-99E2-6A617CDE1579} + Library + Properties + Contrib.Regex + Contrib.Regex + v4.0 + 512 + + + true + full + false + ..\..\..\bin\contrib\Regex\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + {5D4AD9BE-1FFB-41AB-9943-25737971BF57} + Lucene.Net + + + + + \ No newline at end of file Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/Contrib.Regex.suo URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/Contrib.Regex.suo?rev=1100632&view=auto ============================================================================== Binary file - no diff available. Propchange: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/Contrib.Regex.suo ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/IRegexCapabilities.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/IRegexCapabilities.cs?rev=1100632&view=auto ============================================================================== --- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/IRegexCapabilities.cs (added) +++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/IRegexCapabilities.cs Sat May 7 21:34:19 2011 @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Lucene.Net.Search.Regex +{ + /// + /// Defines basic operations needed by {@link RegexQuery} for a regular expression implementation. + /// + /// http://www.java2s.com/Open-Source/Java-Document/Net/lucene-connector/org/apache/lucene/search/regex/RegexCapabilities.java.htm + public interface IRegexCapabilities + { + /// + /// Called by the constructor of allowing implementations to cache + /// a compiled version of the regular expression pattern. + /// + /// regular expression pattern + void Compile(string pattern); + + /// + /// True on match. + /// + /// text to match + /// true on match + bool Match(string s); + + /// + /// A wise prefix implementation can reduce the term enumeration (and thus performance) + /// of RegexQuery dramatically. + /// + /// static non-regex prefix of the pattern last passed to . + /// May return null + string Prefix(); + } +} Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/IRegexQueryCapable.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/IRegexQueryCapable.cs?rev=1100632&view=auto ============================================================================== --- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/IRegexQueryCapable.cs (added) +++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/IRegexQueryCapable.cs Sat May 7 21:34:19 2011 @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Lucene.Net.Search.Regex +{ + /// + /// Defines methods for regular expression supporting queries to use. + /// + /// http://www.java2s.com/Open-Source/Java-Document/Net/lucene-connector/org/apache/lucene/search/regex/RegexQueryCapable.java.htm + public interface IRegexQueryCapable + { + void SetRegexImplementation(IRegexCapabilities impl); + IRegexCapabilities GetRegexImplementation(); + } +} Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/Properties/AssemblyInfo.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/Properties/AssemblyInfo.cs?rev=1100632&view=auto ============================================================================== --- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/Properties/AssemblyInfo.cs (added) +++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/Properties/AssemblyInfo.cs Sat May 7 21:34:19 2011 @@ -0,0 +1,53 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Lucene.Net.Contrib.Regex")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("The Apache Software Foundation")] +[assembly: AssemblyProduct("Lucene.Net.Contrib.Regex")] +[assembly: AssemblyCopyright("Copyright 2006 - 2011 The Apache Software Foundation")] +[assembly: AssemblyTrademark("Copyright 2006 - 2011 The Apache Software Foundation")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("7c479233-95a2-4d53-b0fd-0ad2389556b1")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("2.9.4")] +[assembly: AssemblyFileVersion("2.9.4")] Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/RegexQuery.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/RegexQuery.cs?rev=1100632&view=auto ============================================================================== --- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/RegexQuery.cs (added) +++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/RegexQuery.cs Sat May 7 21:34:19 2011 @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using Lucene.Net.Index; + +namespace Lucene.Net.Search.Regex +{ + /// + /// Regular expression based query. + /// + /// http://www.java2s.com/Open-Source/Java-Document/Net/lucene-connector/org/apache/lucene/search/regex/RegexQuery.java.htm + public class RegexQuery : MultiTermQuery, IRegexQueryCapable, IEquatable + { + private IRegexCapabilities _regexImpl = new CSharpRegexCapabilities(); + + public RegexQuery(Term term) : base(term) + { + } + + /// Construct the enumeration to be used, expanding the pattern term. + public override FilteredTermEnum GetEnum(IndexReader reader) + { + Term term = new Term(GetTerm().Field(), GetTerm().Text()); + return new RegexTermEnum(reader, term, _regexImpl); + } + + public void SetRegexImplementation(IRegexCapabilities impl) + { + _regexImpl = impl; + } + + public IRegexCapabilities GetRegexImplementation() + { + return _regexImpl; + } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// + /// true if the current object is equal to the parameter; otherwise, false. + /// + /// An object to compare with this object + public bool Equals(RegexQuery other) + { + if (other == null) return false; + if (this == other) return true; + + if (!base.Equals(other)) return false; + return _regexImpl.Equals(other._regexImpl); + } + + public override bool Equals(object obj) + { + if ((obj == null) || (obj as RegexQuery == null)) return false; + if (this == obj) return true; + + return Equals((RegexQuery) obj); + } + + public override int GetHashCode() + { + return 29 * base.GetHashCode() + _regexImpl.GetHashCode(); + } + } +} Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/RegexTermEnum.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/RegexTermEnum.cs?rev=1100632&view=auto ============================================================================== --- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/RegexTermEnum.cs (added) +++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/RegexTermEnum.cs Sat May 7 21:34:19 2011 @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using Lucene.Net.Index; + +namespace Lucene.Net.Search.Regex +{ + /// + /// Subclass of FilteredTermEnum for enumerating all terms that match the + /// specified regular expression term using the specified regular expression + /// implementation. + /// Term enumerations are always ordered by Term.compareTo(). Each term in + /// the enumeration is greater than all that precede it. + /// + /// http://www.java2s.com/Open-Source/Java-Document/Net/lucene-connector/org/apache/lucene/search/regex/RegexTermEnum.java.htm + public class RegexTermEnum : FilteredTermEnum + { + private string _sField = ""; + private string _sPre = ""; + private bool _bEndEnum; + private readonly IRegexCapabilities _regexImpl; + + public RegexTermEnum(IndexReader reader, Term term, IRegexCapabilities regexImpl) + { + _sField = term.Field(); + string sText = term.Text(); + + _regexImpl = regexImpl; + + _regexImpl.Compile(sText); + + _sPre = _regexImpl.Prefix() ?? ""; + + SetEnum(reader.Terms(new Term(term.Field(), _sPre))); + } + + /// Equality compare on the term + public override bool TermCompare(Term term) + { + if (_sField == term.Field()) + { + string sSearchText = term.Text(); + if (sSearchText.StartsWith(_sPre)) return _regexImpl.Match(sSearchText); + } //eif + + _bEndEnum = true; + return false; + } + + /// Equality measure on the term + public override float Difference() + { + // TODO: adjust difference based on distance of searchTerm.text() and term().text() + return 1.0F; + } + + /// Indicates the end of the enumeration has been reached + public override bool EndEnum() + { + return _bEndEnum; + } + + //public override void Close() + //{ + // base.Close(); + // _sField = null; + //} + } +} Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/SpanRegexQuery.cs URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/SpanRegexQuery.cs?rev=1100632&view=auto ============================================================================== --- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/SpanRegexQuery.cs (added) +++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/contrib/Regex/SpanRegexQuery.cs Sat May 7 21:34:19 2011 @@ -0,0 +1,161 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using Lucene.Net.Index; +using Lucene.Net.Search.Spans; +using Lucene.Net.Util; + +namespace Lucene.Net.Search.Regex +{ + /// + /// A SpanQuery version of allowing regular expression queries to be nested + /// within other SpanQuery subclasses. + /// + /// http://www.java2s.com/Open-Source/Java-Document/Net/lucene-connector/org/apache/lucene/search/regex/SpanRegexQuery.java.htm + public class SpanRegexQuery : SpanQuery, IRegexQueryCapable, IEquatable + { + private IRegexCapabilities _regexImpl = new CSharpRegexCapabilities(); + private readonly Term _term; + + public SpanRegexQuery(Term term) + { + _term = term; + } + + public Term GetTerm() + { + return _term; + } + + public override string ToString(string field) + { + StringBuilder sb = new StringBuilder(); + sb.Append("SpanRegexQuery("); + sb.Append(_term); + sb.Append(')'); + sb.Append(ToStringUtils.Boost(GetBoost())); + return sb.ToString(); + } + + public override Query Rewrite(IndexReader reader) + { + RegexQuery orig = new RegexQuery(_term); + orig.SetRegexImplementation(_regexImpl); + + // RegexQuery (via MultiTermQuery).Rewrite always returns a BooleanQuery + orig.SetRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE); //@@ + BooleanQuery bq = (BooleanQuery) orig.Rewrite(reader); + + BooleanClause[] clauses = bq.GetClauses(); + SpanQuery[] sqs = new SpanQuery[clauses.Length]; + for (int i = 0; i < clauses.Length; i++) + { + BooleanClause clause = clauses[i]; + + // Clauses from RegexQuery.Rewrite are always TermQuery's + TermQuery tq = (TermQuery) clause.GetQuery(); + + sqs[i] = new SpanTermQuery(tq.GetTerm()); + sqs[i].SetBoost(tq.GetBoost()); + } //efor + + SpanOrQuery query = new SpanOrQuery(sqs); + query.SetBoost(orig.GetBoost()); + + return query; + } + + /// Expert: Returns the matches for this query in an index. Used internally + /// to search for spans. + /// + public override Spans.Spans GetSpans(IndexReader reader) + { + throw new InvalidOperationException("Query should have been rewritten"); + } + + /// Returns the name of the field matched by this query. + public override string GetField() + { + return _term.Field(); + } + + /// Returns a collection of all terms matched by this query. + /// use extractTerms instead + /// + /// + /// + public override IList GetTerms() + { + IList terms = new List {_term}; + return terms; + } + + public void SetRegexImplementation(IRegexCapabilities impl) + { + _regexImpl = impl; + } + + public IRegexCapabilities GetRegexImplementation() + { + return _regexImpl; + } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// + /// true if the current object is equal to the parameter; otherwise, false. + /// + /// An object to compare with this object. + /// + public bool Equals(SpanRegexQuery other) + { + if (other == null) return false; + if (this == other) return true; + + if (!_regexImpl.Equals(other._regexImpl)) return false; + if (!_term.Equals(other._term)) return false; + + return true; + } + + /// + /// True if this object equals the specified object. + /// + /// object + /// true on equality + public override bool Equals(object obj) + { + if (obj as SpanRegexQuery == null) return false; + + return Equals((SpanRegexQuery) obj); + } + + /// + /// Get hash code for this object. + /// + /// hash code + public override int GetHashCode() + { + return 29 * _regexImpl.GetHashCode() + _term.GetHashCode(); + } + } +} Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Lucene.Net.csproj URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Lucene.Net.csproj?rev=1100632&r1=1100631&r2=1100632&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Lucene.Net.csproj (original) +++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Lucene.Net.csproj Sat May 7 21:34:19 2011 @@ -527,7 +527,6 @@ Code - Code @@ -620,8 +619,6 @@ Code - - Code @@ -684,8 +681,6 @@ Code - - Code @@ -732,7 +727,6 @@ - Code Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Lucene.Net.Test.csproj URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Lucene.Net.Test.csproj?rev=1100632&r1=1100631&r2=1100632&view=diff ============================================================================== --- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Lucene.Net.Test.csproj (original) +++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Lucene.Net.Test.csproj Sat May 7 21:34:19 2011 @@ -386,7 +386,6 @@ -