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

Fix LT-18682 #170

Merged
merged 6 commits into from
Oct 4, 2024
Merged
Changes from 2 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
14 changes: 8 additions & 6 deletions Src/LexText/ParserCore/FwXmlTraceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,18 @@ public void PhonologicalRuleApplied(IPhonologicalRule rule, int subruleIndex, Wo
{
((XElement) output.CurrentTrace).Add(new XElement("PhonologicalRuleSynthesisTrace",
CreateHCRuleElement("PhonologicalRule", rule),
CreateWordElement("Input", input, false),
CreateWordElement("Output", output, false)));
// Show as regex to make debugging phonological rules easier (fixes LT-18682).
CreateWordElement("Input", input, true),
CreateWordElement("Output", output, true)));
}

public void PhonologicalRuleNotApplied(IPhonologicalRule rule, int subruleIndex, Word input, FailureReason reason, object failureObj)
{
var pruleTrace = new XElement("PhonologicalRuleSynthesisTrace",
CreateHCRuleElement("PhonologicalRule", rule),
CreateWordElement("Input", input, false),
CreateWordElement("Output", input, false));
// Show as regex to make debugging phonological rules easier (fixes LT-18682).
CreateWordElement("Input", input, true),
CreateWordElement("Output", input, true));

var rewriteRule = rule as RewriteRule;
if (rewriteRule != null)
Expand Down Expand Up @@ -386,13 +388,13 @@ private static XElement CreateInflFeaturesElement(string name, FeatureStruct fs)
return new XElement(name, fs.Head().ToString().Replace(",", ""));
}

private static XElement CreateWordElement(string name, Word word, bool analysis)
private static XElement CreateWordElement(string name, Word word, bool regex)
{
string wordStr;
if (word == null)
wordStr = "*None*";
else
wordStr = analysis ? word.Shape.ToRegexString(word.Stratum.CharacterDefinitionTable, true) : word.Shape.ToString(word.Stratum.CharacterDefinitionTable, true);
wordStr = regex ? word.Shape.ToRegexString(word.Stratum.CharacterDefinitionTable, true) : word.Shape.ToString(word.Stratum.CharacterDefinitionTable, true);
return new XElement(name, wordStr);
}

Expand Down
Loading