Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Adding additional languages support #27

Draft
wants to merge 35 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b13a222
lazy stash
danielcrenna Dec 30, 2020
a3e65eb
Merge branch 'main' into multi
danielcrenna Dec 31, 2020
2632d56
fixes and tests for Among
danielcrenna Dec 31, 2020
22d8cd6
add french stop word filter and tests
danielcrenna Dec 31, 2020
9938467
add FrenchTrimmer and tests
danielcrenna Dec 31, 2020
f49dba2
add French search tests
danielcrenna Dec 31, 2020
008509c
Merge branch 'main' into multi
danielcrenna Jan 1, 2021
f688881
add all language trimmers
danielcrenna Jan 2, 2021
6f0fe59
add arabic stop word filter; use string parse approach per lunr-langu…
danielcrenna Jan 2, 2021
29faf11
add all stop word filters (thai does not use one)
danielcrenna Jan 2, 2021
e5eff94
port ItalianStemmer and tests
danielcrenna Jan 2, 2021
e382b1e
add non-lmdb italian search tests
danielcrenna Jan 2, 2021
2b52c5e
nit: nullability warnings
danielcrenna Jan 2, 2021
2c05a22
re-org into i18n folders
danielcrenna Jan 2, 2021
1e18c81
add German stemmer and tests (stemmed word test fails!)
danielcrenna Jan 3, 2021
f0428d0
add test for failing stemmed word
danielcrenna Jan 3, 2021
1d8e0ff
remove dumb attrib again
danielcrenna Jan 3, 2021
d22a2b6
remove unnecessary usings
danielcrenna Jan 9, 2021
7bb449b
remove unnecessary usings
danielcrenna Jan 9, 2021
6117609
make SnowballProgram a little more idiomatic
danielcrenna Jan 9, 2021
31210b7
fix Among equal comparison
danielcrenna Jan 9, 2021
069ed0d
rename main stem method to StemImpl
danielcrenna Jan 9, 2021
dd215b6
use idiomatic ArgumentNullException
danielcrenna Jan 9, 2021
b0f360c
add .editorconfig to help linting per project preferences
danielcrenna Jan 9, 2021
e2dcd7c
lint branch code
danielcrenna Jan 9, 2021
1ab7162
convert to unicode
danielcrenna Jan 9, 2021
d92b9a4
fix Among hashcode, cleanup tests
danielcrenna Jan 9, 2021
c69bba5
make Among fields read-only properties; add attribution for lunr-lang…
danielcrenna Jan 9, 2021
8162a92
finish unicode conversion for FrenchStemmer
danielcrenna Jan 9, 2021
07551ea
remove param tags for non-existing params
danielcrenna Jan 9, 2021
7361656
unescape remaining unicode chars in stemmers
danielcrenna Jan 9, 2021
87909d2
remove static ctors in stemmers + linting
danielcrenna Jan 9, 2021
896812d
string.Empty => ""
danielcrenna Jan 9, 2021
f30515f
remote static ctors in trimmers
danielcrenna Jan 9, 2021
c086b31
combine trimmers into single regex replacement
danielcrenna Jan 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# See: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules

[*.cs]
indent_style=tab
indent_size=tab
Comment on lines +4 to +5
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aaaaargh! Nooooooo! Spaces, please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed one of the better parts of SV...

tab_width=4

[*.{appxmanifest,axml,build,config,csproj,dbml,discomap,dtd,json,jsproj,lsproj,njsproj,nuspec,proj,props,resjson,resw,resx,StyleCop,targets,tasks,vbproj,xml,xsd}]
indent_style=space
indent_size=2
tab_width=2

[*.cs]
csharp_prefer_braces = true
csharp_new_line_before_open_brace = methods, properties, control_blocks, types
3 changes: 2 additions & 1 deletion LunrCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LunrCoreTests", "LunrCoreTe
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Metadata", "Metadata", "{333885CB-3ADF-4462-8910-27A16B6C5F55}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md
LICENSE = LICENSE
README.md = README.md
Expand All @@ -20,7 +21,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LunrCoreLmdb", "LunrCoreLmd
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LunrCoreLmdbTests", "LunrCoreLmdbTests\LunrCoreLmdbTests.csproj", "{2EF25270-1D0D-4450-ADBB-BCFD08FB9BB6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LunrCoreLmdbPerf", "LunrCoreLmdbPerf\LunrCoreLmdbPerf.csproj", "{41BB51FD-462C-4AAB-9B4D-127FD784B566}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LunrCoreLmdbPerf", "LunrCoreLmdbPerf\LunrCoreLmdbPerf.csproj", "{41BB51FD-462C-4AAB-9B4D-127FD784B566}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
57 changes: 57 additions & 0 deletions LunrCore/Globalization/Among.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System;
using System.Linq;

namespace Lunr.Globalization
{
public readonly struct Among : IEquatable<Among>
bleroy marked this conversation as resolved.
Show resolved Hide resolved
{
public int Size { get; }
public char[] StringArray { get; }
public int Result { get; }
public Func<bool>? Method { get; }
public int Substring { get; }

public Among(string s, int substring, int result, Func<bool> method = default!)
{
if (s == null)
{
throw new ArgumentNullException(nameof(s));
}

Size = s.Length;
StringArray = s.ToCharArray();
Substring = substring;
Result = result;
Method = method;
}

public bool Equals(Among other)
{
return Size == other.Size &&
StringArray.SequenceEqual(other.StringArray) &&
Result == other.Result &&
Method == other.Method &&
Substring == other.Substring;
}

public override bool Equals(object? obj)
{
return obj is Among other && Equals(other);
}

public override int GetHashCode()
{
return (Size, StringArray, Result, Method, Substring).GetHashCode();
}

public static bool operator ==(Among left, Among right)
{
return left.Equals(right);
}

public static bool operator !=(Among left, Among right)
{
return !left.Equals(right);
}
}
}
Loading