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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,6 @@ Build/Agent/comment-hygiene-report.json
.claude/.jira-issue-prefs.json
# Local NuGet feed for packs made by build.ps1 -LocalLibraries
.localfeed/

# XLingPaper-based Documentation
XLingPaperPDFTemp/
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void PcPatrInvokerTest()
{
AndString = streamReader.ReadToEnd().Replace("\r", "");
}
var invoker = new PCPatrInvoker(grammarFile, anaFile, "Off");
var invoker = new PCPatrInvoker(grammarFile, anaFile, "Off", ShowFailures.Off);
invoker.Invoke();
Assert.AreEqual(true, invoker.InvocationSucceeded);
string andResult = "";
Expand Down Expand Up @@ -134,9 +134,25 @@ public void PcPatrInvokerFailureTest()
string grammarFile = "GrammarFail.grm";
File.Copy(Path.Combine(TestDataDir, grammarFile), Path.Combine(Path.GetTempPath(), grammarFile), true);
string anaFile = Path.Combine(TestDataDir, "InvokerFail.ana");
var invoker = new PCPatrInvoker(grammarFile, anaFile, "Off");
var invoker = new PCPatrInvoker(grammarFile, anaFile, "Off", ShowFailures.Off);
invoker.Invoke();
Assert.AreEqual(false, invoker.InvocationSucceeded);
}
[Test]
public void PcPatrInvokerHandleSetFeaturesAndShowFailuresTest()
{
var invoker = new PCPatrInvoker(null, null, null, ShowFailures.Off);
var sbTake = new StringBuilder();
invoker.HandleSetFeaturesAndShowFailures(sbTake);
Assert.AreEqual("set features all\n", sbTake.ToString());
sbTake.Clear();
invoker.ShowFailures = ShowFailures.PSROnly;
invoker.HandleSetFeaturesAndShowFailures(sbTake);
Assert.AreEqual("set features off\nset unification off\n", sbTake.ToString());
sbTake.Clear();
invoker.ShowFailures = ShowFailures.On;
invoker.HandleSetFeaturesAndShowFailures(sbTake);
Assert.AreEqual("set features all\nset failures on\n", sbTake.ToString());
}
}
}
33 changes: 30 additions & 3 deletions Src/Utilities/pcpatrflex/DisambiguateInFLExDB/PCPatrInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ public class PCPatrInvoker
public string LogFile { get; set; }
public string BatchFile { get; set; }
public string RootGlossState { get; set; }
public ShowFailures ShowFailures { get; set; }
public Boolean InvocationSucceeded { get; set; }
public string MaxAmbiguities { get; set; }
public string TimeLimit { get; set; }

public PCPatrInvoker(string grammarFile, string anaFile, string rootglossState)
public PCPatrInvoker(string grammarFile, string anaFile, string rootglossState, ShowFailures showFailures)
{
GrammarFile = grammarFile;
AnaFile = anaFile;
RootGlossState = rootglossState;
ShowFailures = showFailures;
LogFile = Path.Combine(Path.GetTempPath(), logFileName);
MaxAmbiguities = "100";
TimeLimit = "0";
Expand Down Expand Up @@ -81,7 +83,7 @@ public void Invoke()
process.PriorityClass = ProcessPriorityClass.High;
process.WaitForExit();
string error = process.StandardError.ReadToEnd();
if (error.Contains("ERROR "))
if (error.Contains("ERROR ") || error.Contains("WARNING"))
{
InvocationSucceeded = false;
}
Expand All @@ -108,7 +110,7 @@ private void CreateTakeFile()
sbTake.Append("\n");
sbTake.Append("set timing on\n");
sbTake.Append("set gloss on\n");
sbTake.Append("set features all\n");
HandleSetFeaturesAndShowFailures(sbTake);
HandleRootGloss(sbTake);
sbTake.Append("set tree xml\n");
sbTake.Append("set ambiguities ");
Expand Down Expand Up @@ -139,6 +141,25 @@ private void HandleRootGloss(StringBuilder sbTake)
result = GetRootGlossStateValue();
sbTake.Append(result + "\n");
}
// is public for testing
public void HandleSetFeaturesAndShowFailures(StringBuilder sbTake)
{
sbTake.Append("set features ");
switch (ShowFailures)
{
case ShowFailures.Off:
sbTake.Append("all\n");
break;
case ShowFailures.On:
sbTake.Append("all\n");
sbTake.Append("set failures on\n");
break;
case ShowFailures.PSROnly:
sbTake.Append("off\n");
sbTake.Append("set unification off\n");
break;
}
}

public string GetRootGlossStateValue()
{
Expand All @@ -163,4 +184,10 @@ public string GetRootGlossStateValue()
return result;
}
}
public enum ShowFailures
{
Off,
PSROnly,
On
}
}

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

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"?>
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -127,6 +127,10 @@ Please remove it or add words and try again.
<value>PC-PATR Grammar File (*.{0})|*.{0}|All Files (*.*)|*.*</value>
<comment>{0} is hard coded to be "grm"</comment>
</data>
<data name="ksFLExCategories" xml:space="preserve">
<value>Automatic FLEx to PAWS-generated PC-PATR categories</value>
<comment>Is only in English</comment>
</data>
<data name="ksGlossesWithSpace" xml:space="preserve">
<value>The following glosses contain a space.
Please fix them and try again.
Expand Down

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

Loading
Loading