Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
abjerner committed Apr 21, 2020
0 parents commit a734ce2
Show file tree
Hide file tree
Showing 20 changed files with 1,053 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src/packages/
src/Skybrud.TextAnalysis/bin/
src/Skybrud.TextAnalysis/obj/
src/.vs/
25 changes: 25 additions & 0 deletions src/Skybrud.TextAnalysis.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29806.167
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Skybrud.TextAnalysis", "Skybrud.TextAnalysis\Skybrud.TextAnalysis.csproj", "{1D28A1E8-826F-4A30-AF13-944A1365A5B1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1D28A1E8-826F-4A30-AF13-944A1365A5B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D28A1E8-826F-4A30-AF13-944A1365A5B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D28A1E8-826F-4A30-AF13-944A1365A5B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D28A1E8-826F-4A30-AF13-944A1365A5B1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0A8CE6D2-0910-4D2F-BA5B-09F729847D33}
EndGlobalSection
EndGlobal
49 changes: 49 additions & 0 deletions src/Skybrud.TextAnalysis/Hunspell/Affix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Skybrud.TextAnalysis.Hunspell {

public class Affix {

public Dictionary<string, SuffixRuleSet> SuffixRuleSets { get; }

private Affix(string raw) {

string[] lines = raw.Split('\n');

SuffixRuleSets = new Dictionary<string, SuffixRuleSet>();

for (int i = 0; i < lines.Length; i++) {

if (lines[i].Length == 0 || lines[i][0] == '#') continue;

string last = i == 0 ? null : lines[i - 1];

if (lines[i].StartsWith("SFX ")) {

string[] pieces = lines[i].Split(' ', '\t');

string name = pieces[1];
string comment = last != null && last.StartsWith("#") ? last.Substring(1).Trim() : null;
int count = int.Parse(pieces[3]);
string[] rules = lines.Skip(i + 1).Take(count).ToArray();

var set = new SuffixRuleSet(name, comment, rules);
SuffixRuleSets.Add(set.Name, set);

i += count;

}

}

}

public static Affix Load(string path) {
return new Affix(File.ReadAllText(path));
}

}

}
Loading

0 comments on commit a734ce2

Please sign in to comment.