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/mkall.targets
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
<ParatextNugetVersion>9.4.0.1-beta</ParatextNugetVersion>
<LcmNugetVersion>11.0.0-beta0131</LcmNugetVersion>
<IcuNugetVersion>70.1.123</IcuNugetVersion>
<HermitCrabNugetVersion>3.6.6</HermitCrabNugetVersion>
<HermitCrabNugetVersion>3.6.7</HermitCrabNugetVersion>
<IPCFrameworkVersion>1.1.1-beta0001</IPCFrameworkVersion>
<!-- bt393 is the master branch build of ExCss for Windows development. Update when appropriate. -->
<ExCssBuildType Condition="'$(OS)'=='Windows_NT'">bt393</ExCssBuildType>
Expand Down
4 changes: 2 additions & 2 deletions Build/nuget-common/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
<package id="SIL.libpalaso.l10ns" version="6.0.0" targetFramework="net461" />
<package id="SIL.Lift" version="15.0.0-beta0117" targetFramework="net462" />
<package id="SIL.Media" version="15.0.0-beta0117" targetFramework="net462" />
<package id="SIL.Machine" version="3.6.6" targetFramework="netstandard2.0" />
<package id="SIL.Machine.Morphology.HermitCrab" version="3.6.6" targetFramework="netstandard2.0" />
<package id="SIL.Machine" version="3.6.7" targetFramework="netstandard2.0" />
<package id="SIL.Machine.Morphology.HermitCrab" version="3.6.7" targetFramework="netstandard2.0" />
<package id="SIL.ParatextShared" version="7.4.0.1" targetFramework="net40" /> <!-- REVIEW (Hasso) 2023.05: do we still integrate with PT 7? -->
<package id="SIL.Scripture" version="15.0.0-beta0117" targetFramework="net461" />
<package id="SIL.TestUtilities" version="15.0.0-beta0117" targetFramework="net461" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,22 @@
<layout class="MoStemMsa" type="detail" name="Category">
<part ref="Category"/>
<part ref="InflectionClass"/>
<part ref="ProdRestrict" visibility="ifdata"/>
</layout>
<layout class="MoStemMsa" type="detail" name="CategoryDisabled">
<part ref="CategoryDisabled"/>
<part ref="InflectionClassDisabled"/>
<part ref="ProdRestrictDisabled" visibility="ifdata"/>
</layout>
<layout class="MoStemMsa" type="detail" name="Result">
<part ref="Category"/>
<part ref="InflectionClass"/>
<part ref="ProdRestrict" visibility="ifdata"/>
</layout>
<layout class="MoStemMsa" type="detail" name="ResultDisabled">
<part ref="CategoryDisabled"/>
<part ref="InflectionClassDisabled"/>
<part ref="ProdRestrictDisabled" visibility="ifdata"/>
</layout>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,11 @@
</chooserInfo>
</slice>
</part>
<part id="MoStemMsa-Detail-ProdRestrictDisabled" type="Detail">
<slice field="ProdRestrict" label='Exception "Features"' textStyle="Disabled Text" editor="Custom" assemblyPath="MorphologyEditorDll.dll" class="SIL.FieldWorks.XWorks.MorphologyEditor.AdhocCoProhibVectorReferenceDisabledSlice" menu="mnuDataTree-Help">
<deParams displayProperty="LongName" ws="vernacular"/>
</slice>
</part>
<part id="MoStemMsa-Detail-PartOfSpeech" type="Detail">
<slice field="PartOfSpeech" label="Category" editor="atomicreferencepos" menu="mnuDataTree-Help">
<deParams ws="best analorvern"/>
Expand Down Expand Up @@ -2106,6 +2111,14 @@
<part id="MoBinaryCompoundRule-Detail-LeftMsa" type="Detail">
<obj field="LeftMsa" label="Left MSA" layout="LeftMsa"/>
</part>
<part id="MoBinaryCompoundRule-Detail-ProdRestrict" type="Detail">
<slice field="ProdRestrict" label='Exception "Features"' editor="possVectorReference" menu="mnuDataTree-Help">
<deParams ws="best analorvern"/>
<chooserInfo text='The following exception "features" are available.'>
<chooserLink type="goto" label='Edit the Exception "Features"' tool="ProdRestrictEdit"/>
</chooserInfo>
</slice>
</part>
<part id="MoBinaryCompoundRule-Detail-RightMsa" type="Detail">
<obj field="RightMsa" label="Right MSA" layout="RightMsa"/>
</part>
Expand Down
36 changes: 36 additions & 0 deletions Src/LexText/ParserCore/FwXmlTraceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
using SIL.Machine.Annotations;
using System.Collections.Generic;
using System.Text;
using SIL.Machine.Rules;
using SIL.Core.ClearShare;

namespace SIL.FieldWorks.WordWorks.Parser
{
Expand Down Expand Up @@ -91,6 +93,40 @@ public void MorphologicalRuleNotUnapplied(IMorphologicalRule rule, int subruleIn
{
}

public void CompoundingRuleNotUnapplied(IMorphologicalRule rule, int subruleIndex, Word input, FailureReason reason, object obj)
{
var trace = new XElement("CompoundingRuleAnalysisTrace",
CreateMorphologicalRuleElement(rule));
var crule = rule as CompoundingRule;
if (crule != null)
{
var stremProdRestricts = obj as MprFeatureSet;
if (stremProdRestricts != null)
{
trace.Add(new XElement("FailureReason", new XAttribute("type", "missingProdRestrict"),
new XElement("StemProdRestricts", stremProdRestricts.Select(f => new XElement("MprFeature", f))),
new XElement("RuleProdRestricts", crule.NonHeadProdRestrictionsMprFeatures.Select(f => new XElement("MprFeature", f)))));
}
}
trace.Add(new XElement("Output", "*None*"));
((XElement)input.CurrentTrace).Add(trace);
}

public void CompoundingRuleNotApplied(IMorphologicalRule rule, int subruleIndex, Word input, FailureReason reason, object failureObj)
{
var trace = new XElement("CompoundingRuleSynthesisTrace",
CreateMorphologicalRuleElement(rule));
var crule = rule as CompoundingRule;
if (crule != null)
{
trace.Add(new XElement("FailureReason", new XAttribute("type", "missingProdRestrict"),
new XElement("StemProdRestricts", input.MprFeatures.Select(f => new XElement("MprFeature", f))),
new XElement("RuleProdRestricts", crule.HeadProdRestrictionsMprFeatures.Select(f => new XElement("MprFeature", f)))));
}
trace.Add(new XElement("Output", "*None*"));
((XElement)input.CurrentTrace).Add(trace);
}

public void LexicalLookup(Stratum stratum, Word input)
{
var trace = new XElement("LexLookupTrace",
Expand Down
33 changes: 33 additions & 0 deletions Src/LexText/ParserCore/HCLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ private void LoadLanguage()

var prodRestrictsGroup = new MprFeatureGroup { Name = "exceptionFeatures", MatchType = MprFeatureGroupMatchType.All };
foreach (ICmPossibility prodRestrict in m_cache.LanguageProject.MorphologicalDataOA.ProdRestrictOA.ReallyReallyAllPossibilities)
{
LoadMprFeature(prodRestrict, prodRestrictsGroup);

}
if (prodRestrictsGroup.MprFeatures.Count > 0)
m_language.MprFeatureGroups.Add(prodRestrictsGroup);

Expand Down Expand Up @@ -1838,19 +1841,29 @@ private CompoundingRule LoadEndoCompoundingRule(IMoEndoCompound compoundRule)
{
var headRequiredFS = new FeatureStruct();
var nonheadRequiredFS = new FeatureStruct();
var headProdResticts = new MprFeatureSet();
var nonheadProdResticts = new MprFeatureSet();
if (compoundRule.HeadLast)
{
if (compoundRule.RightMsaOA.PartOfSpeechRA != null)
headRequiredFS.AddValue(m_posFeature, LoadAllPartsOfSpeech(compoundRule.RightMsaOA.PartOfSpeechRA));
if (compoundRule.LeftMsaOA.PartOfSpeechRA != null)
nonheadRequiredFS.AddValue(m_posFeature, LoadAllPartsOfSpeech(compoundRule.LeftMsaOA.PartOfSpeechRA));
if (compoundRule.RightMsaOA.ProdRestrictRC.Count > 0)
CreateProdRestricts(compoundRule.RightMsaOA.ProdRestrictRC, headProdResticts);
if (compoundRule.LeftMsaOA.ProdRestrictRC.Count > 0)
CreateProdRestricts(compoundRule.LeftMsaOA.ProdRestrictRC, nonheadProdResticts);
}
else
{
if (compoundRule.RightMsaOA.PartOfSpeechRA != null)
nonheadRequiredFS.AddValue(m_posFeature, LoadAllPartsOfSpeech(compoundRule.RightMsaOA.PartOfSpeechRA));
if (compoundRule.LeftMsaOA.PartOfSpeechRA != null)
headRequiredFS.AddValue(m_posFeature, LoadAllPartsOfSpeech(compoundRule.LeftMsaOA.PartOfSpeechRA));
if (compoundRule.RightMsaOA.ProdRestrictRC.Count > 0)
CreateProdRestricts(compoundRule.RightMsaOA.ProdRestrictRC, nonheadProdResticts);
if (compoundRule.LeftMsaOA.ProdRestrictRC.Count > 0)
CreateProdRestricts(compoundRule.LeftMsaOA.ProdRestrictRC, headProdResticts);
}
headRequiredFS.Freeze();
nonheadRequiredFS.Freeze();
Expand All @@ -1870,6 +1883,8 @@ private CompoundingRule LoadEndoCompoundingRule(IMoEndoCompound compoundRule)
Name = compoundRule.Name.BestAnalysisAlternative.Text,
HeadRequiredSyntacticFeatureStruct = headRequiredFS,
NonHeadRequiredSyntacticFeatureStruct = nonheadRequiredFS,
HeadProdRestrictionsMprFeatures = headProdResticts,
NonHeadProdRestrictionsMprFeatures = nonheadProdResticts,
OutSyntacticFeatureStruct = outFS,
Properties = { { HCParser.CRuleID, compoundRule.Hvo } }
};
Expand All @@ -1894,6 +1909,14 @@ private CompoundingRule LoadEndoCompoundingRule(IMoEndoCompound compoundRule)
return hcCompoundRule;
}

private void CreateProdRestricts(ILcmReferenceCollection<ICmPossibility> ruleProdRestricts, MprFeatureSet prodResticts)
{
foreach (var prodRstrict in ruleProdRestricts)
{
prodResticts.Add(m_mprFeatures[prodRstrict]);
}
}

private IEnumerable<CompoundingRule> LoadExoCompoundingRule(IMoExoCompound compoundRule)
{
var rightRequiredFS = new FeatureStruct();
Expand All @@ -1908,6 +1931,12 @@ private IEnumerable<CompoundingRule> LoadExoCompoundingRule(IMoExoCompound compo
if (compoundRule.ToMsaOA.PartOfSpeechRA != null)
outFS.AddValue(m_posFeature, m_posFeature.PossibleSymbols["pos" + compoundRule.ToMsaOA.PartOfSpeechRA.Hvo]);
outFS.Freeze();
var headProdResticts = new MprFeatureSet();
var nonheadProdResticts = new MprFeatureSet();
if (compoundRule.RightMsaOA.ProdRestrictRC.Count > 0)
CreateProdRestricts(compoundRule.RightMsaOA.ProdRestrictRC, headProdResticts);
if (compoundRule.LeftMsaOA.ProdRestrictRC.Count > 0)
CreateProdRestricts(compoundRule.LeftMsaOA.ProdRestrictRC, nonheadProdResticts);

var headPattern = new Pattern<Word, ShapeNode>("head", AnyPlus());
headPattern.Freeze();
Expand All @@ -1919,6 +1948,8 @@ private IEnumerable<CompoundingRule> LoadExoCompoundingRule(IMoExoCompound compo
Name = compoundRule.Name.BestAnalysisAlternative.Text,
HeadRequiredSyntacticFeatureStruct = rightRequiredFS,
NonHeadRequiredSyntacticFeatureStruct = leftRequiredFS,
HeadProdRestrictionsMprFeatures = headProdResticts,
NonHeadProdRestrictionsMprFeatures = nonheadProdResticts,
OutSyntacticFeatureStruct = outFS,
Properties = { { HCParser.CRuleID, compoundRule.Hvo } }
};
Expand All @@ -1944,6 +1975,8 @@ private IEnumerable<CompoundingRule> LoadExoCompoundingRule(IMoExoCompound compo
Name = compoundRule.Name.BestAnalysisAlternative.Text,
HeadRequiredSyntacticFeatureStruct = leftRequiredFS,
NonHeadRequiredSyntacticFeatureStruct = rightRequiredFS,
HeadProdRestrictionsMprFeatures = nonheadProdResticts,
NonHeadProdRestrictionsMprFeatures = headProdResticts,
OutSyntacticFeatureStruct = outFS,
Properties = { { HCParser.CRuleID, compoundRule.Hvo } }
};
Expand Down
43 changes: 43 additions & 0 deletions Src/LexText/ParserCore/ParserCoreTests/HCLoaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,27 @@ public void EndoCompoundRule()
Assert.That(subrule.HeadLhs.Select(p => p.ToString()), Is.EqualTo(new[] {AnyPlus}));
Assert.That(subrule.NonHeadLhs.Select(p => p.ToString()), Is.EqualTo(new[] {AnyPlus}));
Assert.That(subrule.Rhs.Select(a => a.ToString()), Is.EqualTo(new[] {"<nonhead>", "+", "<head>"}));

// test for exception "features"
compoundRule.LeftMsaOA.ProdRestrictRC.Add(AddExceptionFeature("Left prod restrict"));
LoadLanguage();

Assert.That(m_lang.Strata[0].MorphologicalRules.Count, Is.EqualTo(1));
hcCompoundRule = (CompoundingRule)m_lang.Strata[0].MorphologicalRules[0];

Assert.That(hcCompoundRule.HeadProdRestrictionsMprFeatures.Count, Is.EqualTo(0));
Assert.That(hcCompoundRule.NonHeadProdRestrictionsMprFeatures.Count, Is.EqualTo(1));
Assert.That(hcCompoundRule.NonHeadProdRestrictionsMprFeatures.ElementAt(0).Name, Is.EqualTo("Left prod restrict"));

compoundRule.RightMsaOA.ProdRestrictRC.Add(AddExceptionFeature("Right prod restrict"));
LoadLanguage();

Assert.That(m_lang.Strata[0].MorphologicalRules.Count, Is.EqualTo(1));
hcCompoundRule = (CompoundingRule)m_lang.Strata[0].MorphologicalRules[0];

Assert.That(hcCompoundRule.NonHeadProdRestrictionsMprFeatures.Count, Is.EqualTo(1));
Assert.That(hcCompoundRule.HeadProdRestrictionsMprFeatures.Count, Is.EqualTo(1));
Assert.That(hcCompoundRule.HeadProdRestrictionsMprFeatures.ElementAt(0).Name, Is.EqualTo("Right prod restrict"));
}

[Test]
Expand Down Expand Up @@ -984,6 +1005,28 @@ public void ExoCompoundRule()
Assert.That(subrule.NonHeadLhs.Select(p => p.ToString()), Is.EqualTo(new[] {AnyPlus}));
Assert.That(subrule.Rhs.Select(a => a.ToString()), Is.EqualTo(new[] {"<head>", "+", "<nonhead>"}));
Assert.That(subrule.OutMprFeatures.Select(mf => mf.ToString()), Is.EquivalentTo(new[] {"inflClass"}));

// test for exception "features"
compoundRule.LeftMsaOA.ProdRestrictRC.Add(AddExceptionFeature("Left prod restrict"));
LoadLanguage();

Assert.That(m_lang.Strata[0].MorphologicalRules.Count, Is.EqualTo(2));
hcCompoundRule = (CompoundingRule)m_lang.Strata[0].MorphologicalRules[0];

Assert.That(hcCompoundRule.HeadProdRestrictionsMprFeatures.Count, Is.EqualTo(0));
Assert.That(hcCompoundRule.NonHeadProdRestrictionsMprFeatures.Count, Is.EqualTo(1));
Assert.That(hcCompoundRule.NonHeadProdRestrictionsMprFeatures.ElementAt(0).Name, Is.EqualTo("Left prod restrict"));

compoundRule.RightMsaOA.ProdRestrictRC.Add(AddExceptionFeature("Right prod restrict"));
LoadLanguage();

Assert.That(m_lang.Strata[0].MorphologicalRules.Count, Is.EqualTo(2));
hcCompoundRule = (CompoundingRule)m_lang.Strata[0].MorphologicalRules[0];

Assert.That(hcCompoundRule.NonHeadProdRestrictionsMprFeatures.Count, Is.EqualTo(1));
Assert.That(hcCompoundRule.HeadProdRestrictionsMprFeatures.Count, Is.EqualTo(1));
Assert.That(hcCompoundRule.HeadProdRestrictionsMprFeatures.ElementAt(0).Name, Is.EqualTo("Right prod restrict"));

}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class M3ToXAmpleTransformerTests
string m_sM3FXTIrregularlyInflectedFormsDump;
string m_sM3FXTQuechuaMYLDump;
string m_sM3FXTEmiFLExDump;
string m_sM3FXTCompundRulesWithExceptionFeaturesFLExDump;
private string m_sAbazaOrderClassPlayDump;
readonly Dictionary<string, XPathDocument> m_mapXmlDocs = new Dictionary<string, XPathDocument>();

Expand Down Expand Up @@ -87,6 +88,7 @@ private void SetUpM3FXTDump()
m_sAbazaOrderClassPlayDump = Path.Combine(m_sTestPath, "Abaza-OrderclassPlay.xml");
m_sM3FXTQuechuaMYLDump = Path.Combine(m_sTestPath, "QuechuaMYLFxtResult.xml");
m_sM3FXTEmiFLExDump = Path.Combine(m_sTestPath, "emi-flexFxtResult.xml");
m_sM3FXTCompundRulesWithExceptionFeaturesFLExDump = Path.Combine(m_sTestPath, "CompundRulesWithExceptionFeatures.xml");

SetupXmlDocument(m_sM3FXTDump);
SetupXmlDocument(m_sM3FXTCircumfixDump);
Expand All @@ -105,6 +107,7 @@ private void SetUpM3FXTDump()
SetupXmlDocument(m_sAbazaOrderClassPlayDump);
SetupXmlDocument(m_sM3FXTQuechuaMYLDump);
SetupXmlDocument(m_sM3FXTEmiFLExDump);
SetupXmlDocument(m_sM3FXTCompundRulesWithExceptionFeaturesFLExDump);
}

private void SetupXmlDocument(string filepath)
Expand Down Expand Up @@ -182,6 +185,7 @@ public void CreateXAmpleWordGrammarFile()
ApplyTransform(m_sM3FXTAffixAlloFeatsDump, m_gramTransform, "AffixAlloFeatsWordGrammar.txt");
ApplyTransform(m_sM3FXTLatinDump, m_gramTransform, "LatinWordGrammar.txt");
ApplyTransform(m_sM3FXTQuechuaMYLDump, m_gramTransform, "QuechuaMYLgram.txt");
ApplyTransform(m_sM3FXTCompundRulesWithExceptionFeaturesFLExDump, m_gramTransform, "CompundRulesWithExceptionFeaturesWordGrammar.txt");
}
private void ApplyTransform(string sInput, XslCompiledTransform transform, string sExpectedOutput)
{
Expand Down
Loading
Loading