Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Build/SilVersions.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<SilLibPalasoL10nsVersion>18.0.0-beta0012</SilLibPalasoL10nsVersion>
<SilChorusVersion>6.0.0-beta0065</SilChorusVersion>
<SilChorusL10nsVersion>3.0.1</SilChorusL10nsVersion>
<SilMachineVersion>3.8.2</SilMachineVersion>
<SilMachineVersion>3.9.2</SilMachineVersion>
<SilIPCFrameworkVersion>1.1.1-beta0001</SilIPCFrameworkVersion>
<L10NSharpVersion>10.0.0-beta0004</L10NSharpVersion>
<EncodingConvertersCoreVersion>0.9.8</EncodingConvertersCoreVersion>
Expand Down
10 changes: 10 additions & 0 deletions Src/LexText/ParserCore/HCParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using SIL.Machine.Annotations;
using SIL.Machine.Morphology.HermitCrab;
using SIL.Machine.Morphology.HermitCrab.MorphologicalRules;
using SIL.Machine.Rules;
using SIL.ObjectModel;

namespace SIL.FieldWorks.WordWorks.Parser
Expand Down Expand Up @@ -149,6 +150,7 @@ private void LoadParser()
// For Hermit Crab, the maximum number of roots/stems allowed is between one and ten.
// The default is two in order to allow for compounding (which requires there be at least two roots/stems).
int maxStemCount = 2;
int maxAlternatives = 0;
string loadErrorsFile = Path.Combine(m_outputDirectory, m_cache.ProjectId.Name + "HCLoadErrors.xml");
using (XmlWriter writer = XmlWriter.Create(loadErrorsFile))
using (new WorkerThreadReadHelper(m_cache.ServiceLocator.GetInstance<IWorkerThreadReadHandler>()))
Expand All @@ -161,6 +163,7 @@ private void LoadParser()
XElement guessRootsElem = parserParamsElem.Elements("HC").Elements("GuessRoots").FirstOrDefault();
XElement mergeAnalysesElem = parserParamsElem.Elements("HC").Elements("MergeAnalyses").FirstOrDefault();
XElement maxRootsElem = parserParamsElem.Elements("HC").Elements("MaxRoots").FirstOrDefault();
XElement maxAlternativesElem = parserParamsElem.Elements("HC").Elements("MaxAlternatives").FirstOrDefault();
if (delReappsElem != null)
delReapps = (int) delReappsElem;
if (guessRootsElem != null)
Expand All @@ -169,10 +172,13 @@ private void LoadParser()
m_mergeAnalyses = (bool) mergeAnalysesElem;
if (maxRootsElem != null)
maxStemCount = int.Parse(maxRootsElem.Value);
if (maxAlternativesElem != null)
maxAlternatives = int.Parse(maxAlternativesElem.Value);
}
m_morpher = new Morpher(m_traceManager, m_language) { DeletionReapplications = delReapps };
m_morpher.MaxStemCount = maxStemCount;
m_morpher.MergeEquivalentAnalyses = m_mergeAnalyses;
m_morpher.MaxAlternatives = maxAlternatives;
}

private XDocument ParseToXml(string form, bool tracing, IEnumerable<int> selectTraceMorphs)
Expand Down Expand Up @@ -577,6 +583,10 @@ private string ProcessParseException(Exception e)
}
return string.Format(ParserCoreStrings.ksHCInvalidWordform, ise.String, ise.Position + 1, rest, phonemesFoundSoFar);
}
if (e is MaxAlternativesExceededException)
{
return ParserCoreStrings.ksMaxAlternativesExceeded;
}

return String.Format(ParserCoreStrings.ksHCDefaultErrorMsg, e.Message);
}
Expand Down
15 changes: 14 additions & 1 deletion Src/LexText/ParserCore/ParserCore.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>ParserCore</AssemblyName>
Expand Down Expand Up @@ -54,4 +54,17 @@
<Link>Properties\CommonAssemblyInfo.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Update="ParserCoreStrings.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>ParserCoreStrings.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="ParserCoreStrings.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>ParserCoreStrings.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>
13 changes: 11 additions & 2 deletions Src/LexText/ParserCore/ParserCoreStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Src/LexText/ParserCore/ParserCoreStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,7 @@
<data name="ksParsingX" xml:space="preserve">
<value>Parsing {0}</value>
</data>
<data name="ksMaxAlternativesExceeded" xml:space="preserve">
<value>MaxAlternatives exceeded</value>
</data>
</root>
8 changes: 7 additions & 1 deletion Src/LexText/ParserUI/ParserParametersDlg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class ParserParametersDlg : ParserParametersBase
private const string MaxInfixes = "MaxInfixes";
private const string MaxInterfixes = "MaxInterfixes";
private const string MaxRoots = "MaxRoots";
private const string MaxAlternatives = "MaxAlternatives";
private const string MaxAnalysesToReturn = "MaxAnalysesToReturn";

#region Data members
Expand Down Expand Up @@ -233,6 +234,7 @@ private void ValidateValues(XElement elem)
// For Hermit Crab, the maximum number of roots/stems allowed is between one and ten.
// The default is two in order to allow for compounding (which requires there be at least two roots/stems).
EnforceValidValue(elem, HC, MaxRoots, 1, 10, false);
EnforceValidValue(elem, HC, MaxAlternatives, 0, 1000000000, false);
}

private void EnforceValidValue(XElement elem, string parser, string item, int min, int max, bool useMinIfZero)
Expand Down Expand Up @@ -280,7 +282,8 @@ public void SetDlgInfo(string title, string parserParameters, ILcmOwningSequence
m_dataGrid2.TableStyles[0].GridColumnStyles[2].Width = 130;
m_dataGrid2.TableStyles[0].GridColumnStyles[4].Width = 160;
m_dataGrid2.TableStyles[0].GridColumnStyles[6].Width = 90;
m_dataGrid2.TableStyles[0].GridColumnStyles[7].Width = 400;
m_dataGrid2.TableStyles[0].GridColumnStyles[7].Width = 100;
m_dataGrid2.TableStyles[0].GridColumnStyles[8].Width = 400;

m_compoundRules = compoundRules;
if (m_compoundRules?.Count > 0)
Expand All @@ -305,6 +308,8 @@ private void LoadParserData(DataSet dsParserParameters)
hcElem.Add(new XElement(NoDefaultCompounding, false));
if (hcElem.Element(MaxRoots) == null)
hcElem.Add(new XElement(MaxRoots, 2));
if (hcElem.Element(MaxAlternatives) == null)
hcElem.Add(new XElement(MaxAlternatives, 0));
if (hcElem.Element(NotOnClitics) == null)
hcElem.Add(new XElement(NotOnClitics, true));
if (hcElem.Element(AcceptUnspecifiedGraphemes) == null)
Expand Down Expand Up @@ -367,6 +372,7 @@ private DataTable CreateHCDataTable()
tblHC.Columns.Add(AcceptUnspecifiedGraphemes, typeof(bool));
tblHC.Columns.Add(GuessRoots, typeof(bool));
tblHC.Columns.Add(MergeAnalyses, typeof(bool));
tblHC.Columns.Add(MaxAlternatives, typeof(int));
tblHC.Columns.Add(Strata, typeof(string));
return tblHC;
}
Expand Down
6 changes: 3 additions & 3 deletions Src/LexText/ParserUI/ParserParametersDlg.resx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
<value>8, 64</value>
</data>
<data name="m_dataGrid1.Size" type="System.Drawing.Size, System.Drawing">
<value>576, 72</value>
<value>546, 72</value>
</data>
<data name="m_dataGrid1.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
Expand Down Expand Up @@ -300,7 +300,7 @@
<value>8, 165</value>
</data>
<data name="m_dataGrid2.Size" type="System.Drawing.Size, System.Drawing">
<value>976, 100</value>
<value>1076, 100</value>
</data>
<data name="m_dataGrid2.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
Expand Down Expand Up @@ -351,7 +351,7 @@
<value>5, 13</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>1000, 388</value>
<value>1100, 388</value>
</data>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down
Loading