Skip to content

Commit

Permalink
https://issues.apache.org/jira/browse/LUCENENET-607
Browse files Browse the repository at this point in the history
modified to be a generic IList<char[]>. Created methods for readability.
  • Loading branch information
Michael Condillac committed Apr 13, 2020
1 parent e737158 commit 77e95d7
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/Lucene.Net.Analysis.Common/Analysis/Ar/ArabicStemmer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Lucene.Net.Analysis.Util;
using System;
using System.Collections.Generic;

namespace Lucene.Net.Analysis.Ar
{
Expand Down Expand Up @@ -44,22 +46,23 @@ public class ArabicStemmer
public const char WAW = '\u0648';
public const char YEH = '\u064A';

// LUCENENET TODO: API - Make property, change datatype to regular array or collection
public static readonly char[][] prefixes = new char[][] // LUCENENET: Avoid static constructors (see https://github.com/apache/lucenenet/pull/224#issuecomment-469284006)
// LUCENENET: Avoid static constructors (see https://github.com/apache/lucenenet/pull/224#issuecomment-469284006)
public static readonly IList<char[]> prefixes = InitializePrefix();
public static readonly IList<char[]> suffixes = InitializeSuffix();

private static IList<char[]> InitializePrefix()
{
("" + ALEF + LAM).ToCharArray(),
return new List<char[]>(){ ("" + ALEF + LAM).ToCharArray(),
("" + WAW + ALEF + LAM).ToCharArray(),
("" + BEH + ALEF + LAM).ToCharArray(),
("" + KAF + ALEF + LAM).ToCharArray(),
("" + FEH + ALEF + LAM).ToCharArray(),
("" + LAM + LAM).ToCharArray(),
("" + WAW).ToCharArray(),
};

// LUCENENET TODO: API - Make property, change datatype to regular array or collection
public static readonly char[][] suffixes = new char[][] // LUCENENET: Avoid static constructors (see https://github.com/apache/lucenenet/pull/224#issuecomment-469284006)
("" + WAW).ToCharArray() };
}
private static IList<char[]> InitializeSuffix()
{
("" + HEH + ALEF).ToCharArray(),
return new List<char[]>(){ ("" + HEH + ALEF).ToCharArray(),
("" + ALEF + NOON).ToCharArray(),
("" + ALEF + TEH).ToCharArray(),
("" + WAW + NOON).ToCharArray(),
Expand All @@ -68,9 +71,9 @@ public class ArabicStemmer
("" + YEH + TEH_MARBUTA).ToCharArray(),
("" + HEH).ToCharArray(),
("" + TEH_MARBUTA).ToCharArray(),
("" + YEH).ToCharArray(),
};

("" + YEH).ToCharArray() };
}
/// <summary>
/// Stem an input buffer of Arabic text.
/// </summary>
Expand All @@ -92,7 +95,7 @@ public virtual int Stem(char[] s, int len)
/// <returns> new length of input buffer after stemming. </returns>
public virtual int StemPrefix(char[] s, int len)
{
for (int i = 0; i < prefixes.Length; i++)
for (int i = 0; i < prefixes.Count; i++)
{
if (StartsWithCheckLength(s, len, prefixes[i]))
{
Expand All @@ -109,7 +112,7 @@ public virtual int StemPrefix(char[] s, int len)
/// <returns> new length of input buffer after stemming </returns>
public virtual int StemSuffix(char[] s, int len)
{
for (int i = 0; i < suffixes.Length; i++)
for (int i = 0; i < suffixes.Count; i++)
{
if (EndsWithCheckLength(s, len, suffixes[i]))
{
Expand Down

0 comments on commit 77e95d7

Please sign in to comment.