diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 6528a5153..97f37dcc4 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,10 +3,11 @@ "isRoot": true, "tools": { "csharpier": { - "version": "0.27.2", + "version": "1.2.6", "commands": [ - "dotnet-csharpier" - ] + "csharpier" + ], + "rollForward": false } } } \ No newline at end of file diff --git a/.csharpierignore b/.csharpierignore new file mode 100644 index 000000000..b5df929f0 --- /dev/null +++ b/.csharpierignore @@ -0,0 +1,5 @@ +*.config +*.csproj +*.props +*.targets +*.xml \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e8322726..c5b3fa788 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,14 +26,14 @@ jobs: cmake-args: "-A x64" steps: - - uses: actions/checkout@v4 - - uses: lukka/get-cmake@v3.31.6 + - uses: actions/checkout@v6 + - uses: lukka/get-cmake@v4.2.3 - name: Setup .NET - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 with: dotnet-version: | - 8.0.x + 10.0.x - name: Restore dotnet tools run: dotnet tool restore @@ -51,7 +51,7 @@ jobs: cmake --build ${{ github.workspace }}/src/sentencepiece4c/build --config Release --target sentencepiece4c - name: Upload sentencepiece4c artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: ${{ matrix.sentencepiece4c-artifact }} path: ${{ github.workspace }}/src/sentencepiece4c/bin/${{ matrix.sentencepiece4c-dll }} @@ -59,13 +59,13 @@ jobs: - name: Restore dependencies run: dotnet restore - name: Check formatting - run: dotnet csharpier --check . + run: dotnet csharpier check . - name: Build run: dotnet build --no-restore -c Release - name: Test run: dotnet test --verbosity normal --collect:"Xplat Code Coverage" - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} @@ -75,20 +75,20 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Setup .NET - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 with: dotnet-version: | - 8.0.x + 10.0.x - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@v7 with: name: sp4c-linux-x64 path: ${{ github.workspace }}/src/sentencepiece4c/bin - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@v7 with: name: sp4c-win-x64 path: ${{ github.workspace }}/src/sentencepiece4c/bin @@ -105,7 +105,7 @@ jobs: dotnet pack src\SIL.Machine.Translation.TensorFlow\SIL.Machine.Translation.TensorFlow.csproj -c Release -o artifacts - name: Upload package - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: nuget-package path: artifacts/*.nupkg diff --git a/.gitignore b/.gitignore index 48d81876f..af6b4a93c 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,4 @@ tests/SIL.Machine.Tests/Corpora/TestData/usfm/source/* tests/SIL.Machine.Tests/Corpora/TestData/usfm/target/* tests/SIL.Machine.Tests/Corpora/TestData/project/* tests/SIL.Machine.Tests/Corpora/TestData/pretranslations.json +.idea diff --git a/local_check.sh b/local_check.sh index 1635960c4..44d78c087 100755 --- a/local_check.sh +++ b/local_check.sh @@ -1,7 +1,7 @@ #!/bin/bash dotnet tool restore dotnet restore -dotnet csharpier --check . +dotnet csharpier check . if [ $? -ne 0 ]; then exit 1 fi diff --git a/src/SIL.Machine.Morphology.HermitCrab.Tool/Program.cs b/src/SIL.Machine.Morphology.HermitCrab.Tool/Program.cs index ab9003996..ff8e86bcc 100644 --- a/src/SIL.Machine.Morphology.HermitCrab.Tool/Program.cs +++ b/src/SIL.Machine.Morphology.HermitCrab.Tool/Program.cs @@ -31,7 +31,7 @@ public static int Main(string[] args) "continues when an error occurs while loading the configuration", value => quitOnError = value == null }, - { "h|help", "show this help message and exit", value => showHelp = value != null } + { "h|help", "show this help message and exit", value => showHelp = value != null }, }; try @@ -91,7 +91,7 @@ public static int Main(string[] args) new ParseCommand(context), new TracingCommand(context), new TestCommand(context), - new StatsCommand(context) + new StatsCommand(context), }; string input; diff --git a/src/SIL.Machine.Morphology.HermitCrab.Tool/SIL.Machine.Morphology.HermitCrab.Tool.csproj b/src/SIL.Machine.Morphology.HermitCrab.Tool/SIL.Machine.Morphology.HermitCrab.Tool.csproj index a2277af99..622c9e3bd 100644 --- a/src/SIL.Machine.Morphology.HermitCrab.Tool/SIL.Machine.Morphology.HermitCrab.Tool.csproj +++ b/src/SIL.Machine.Morphology.HermitCrab.Tool/SIL.Machine.Morphology.HermitCrab.Tool.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net10.0 SIL.Machine.Morphology.HermitCrab true hc diff --git a/src/SIL.Machine.Morphology.HermitCrab/AllomorphEnvironment.cs b/src/SIL.Machine.Morphology.HermitCrab/AllomorphEnvironment.cs index ff272ee92..c1ac4f768 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/AllomorphEnvironment.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/AllomorphEnvironment.cs @@ -38,7 +38,7 @@ Pattern rightEnv Filter = ann => ann.Type() .IsOneOf(HCFeatureSystem.Segment, HCFeatureSystem.Boundary, HCFeatureSystem.Anchor) - && !ann.IsDeleted() + && !ann.IsDeleted(), } ); } @@ -55,7 +55,7 @@ Pattern rightEnv Filter = ann => ann.Type() .IsOneOf(HCFeatureSystem.Segment, HCFeatureSystem.Boundary, HCFeatureSystem.Anchor) - && !ann.IsDeleted() + && !ann.IsDeleted(), } ); } diff --git a/src/SIL.Machine.Morphology.HermitCrab/CompileException.cs b/src/SIL.Machine.Morphology.HermitCrab/CompileException.cs index ac33bd384..9a40af9e5 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/CompileException.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/CompileException.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace SIL.Machine.Morphology.HermitCrab { diff --git a/src/SIL.Machine.Morphology.HermitCrab/ConstraintType.cs b/src/SIL.Machine.Morphology.HermitCrab/ConstraintType.cs index 740b7e607..35737b17b 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/ConstraintType.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/ConstraintType.cs @@ -3,6 +3,6 @@ public enum ConstraintType { Require, - Exclude + Exclude, } } diff --git a/src/SIL.Machine.Morphology.HermitCrab/HCFeatureSystem.cs b/src/SIL.Machine.Morphology.HermitCrab/HCFeatureSystem.cs index b5478c5eb..43c821fd1 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/HCFeatureSystem.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/HCFeatureSystem.cs @@ -42,7 +42,7 @@ static HCFeatureSystem() Type = new SymbolicFeature(Guid.NewGuid().ToString(), Anchor, Segment, Boundary, Morph) { - Description = "Type" + Description = "Type", }; Dirty = new FeatureSymbol(Guid.NewGuid().ToString()) { Description = "Dirty" }; @@ -51,7 +51,7 @@ static HCFeatureSystem() Modified = new SymbolicFeature(Guid.NewGuid().ToString(), Dirty, Clean) { Description = "Modified", - DefaultValue = new SymbolicFeatureValue(Clean) + DefaultValue = new SymbolicFeatureValue(Clean), }; Deleted = new FeatureSymbol(Guid.NewGuid().ToString()) { Description = "Deleted" }; @@ -60,7 +60,7 @@ static HCFeatureSystem() Deletion = new SymbolicFeature(Guid.NewGuid().ToString(), Deleted, NotDeleted) { Description = "Deletion", - DefaultValue = new SymbolicFeatureValue(NotDeleted) + DefaultValue = new SymbolicFeatureValue(NotDeleted), }; LeftSide = new FeatureSymbol(Guid.NewGuid().ToString()) { Description = "LeftSide" }; @@ -68,7 +68,7 @@ static HCFeatureSystem() AnchorType = new SymbolicFeature(Guid.NewGuid().ToString(), LeftSide, RightSide) { - Description = "AnchorType" + Description = "AnchorType", }; StrRep = new StringFeature(Guid.NewGuid().ToString()) { Description = "StrRep" }; diff --git a/src/SIL.Machine.Morphology.HermitCrab/ITraceManager.cs b/src/SIL.Machine.Morphology.HermitCrab/ITraceManager.cs index 52ff79129..31d8fa497 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/ITraceManager.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/ITraceManager.cs @@ -25,7 +25,7 @@ public enum FailureReason BoundRoot, NonPartialRuleProhibitedAfterFinalTemplate, NonPartialRuleRequiredAfterNonFinalTemplate, - MaxApplicationCount + MaxApplicationCount, } public interface ITraceManager diff --git a/src/SIL.Machine.Morphology.HermitCrab/MorphCoOccurrenceRule.cs b/src/SIL.Machine.Morphology.HermitCrab/MorphCoOccurrenceRule.cs index cf50bdeae..f44d5abdc 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/MorphCoOccurrenceRule.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/MorphCoOccurrenceRule.cs @@ -33,7 +33,7 @@ public enum MorphCoOccurrenceAdjacency /// /// Adjacent to the right /// - AdjacentToRight + AdjacentToRight, } /// diff --git a/src/SIL.Machine.Morphology.HermitCrab/Morpher.cs b/src/SIL.Machine.Morphology.HermitCrab/Morpher.cs index 7837ef624..e4fd1879d 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/Morpher.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/Morpher.cs @@ -14,7 +14,6 @@ #if !SINGLE_THREADED using System.Collections.Concurrent; using System.Threading.Tasks; -using System.Text; #endif namespace SIL.Machine.Morphology.HermitCrab diff --git a/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AffixProcessAllomorph.cs b/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AffixProcessAllomorph.cs index 0efcfafdb..cf4200c2a 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AffixProcessAllomorph.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AffixProcessAllomorph.cs @@ -22,7 +22,7 @@ public enum ReduplicationHint /// /// Suffix /// - Suffix + Suffix, } public class AffixProcessAllomorph : Allomorph diff --git a/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AnalysisAffixProcessRule.cs b/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AnalysisAffixProcessRule.cs index af296a883..4e89fef97 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AnalysisAffixProcessRule.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AnalysisAffixProcessRule.cs @@ -29,7 +29,7 @@ public AnalysisAffixProcessRule(Morpher morpher, AffixProcessRule rule) MatchingMethod = MatchingMethod.Unification, AnchoredToStart = true, AnchoredToEnd = true, - AllSubmatches = true + AllSubmatches = true, } ) ); diff --git a/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AnalysisCompoundingRule.cs b/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AnalysisCompoundingRule.cs index 079d6f590..6dc2a0c28 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AnalysisCompoundingRule.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AnalysisCompoundingRule.cs @@ -29,7 +29,7 @@ public AnalysisCompoundingRule(Morpher morpher, CompoundingRule rule) MatchingMethod = MatchingMethod.Unification, AnchoredToStart = true, AnchoredToEnd = true, - AllSubmatches = true + AllSubmatches = true, } ) ); diff --git a/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AnalysisRealizationalAffixProcessRule.cs b/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AnalysisRealizationalAffixProcessRule.cs index 77651fcd8..749aa7b4d 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AnalysisRealizationalAffixProcessRule.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/AnalysisRealizationalAffixProcessRule.cs @@ -30,7 +30,7 @@ public AnalysisRealizationalAffixProcessRule(Morpher morpher, RealizationalAffix MatchingMethod = MatchingMethod.Unification, AnchoredToStart = true, AnchoredToEnd = true, - AllSubmatches = true + AllSubmatches = true, } ) ); diff --git a/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/SynthesisAffixProcessRule.cs b/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/SynthesisAffixProcessRule.cs index 4dd36d39a..f7dc9c0dc 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/SynthesisAffixProcessRule.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/SynthesisAffixProcessRule.cs @@ -31,7 +31,7 @@ public SynthesisAffixProcessRule(Morpher morpher, AffixProcessRule rule) ann.Type().IsOneOf(HCFeatureSystem.Segment, HCFeatureSystem.Boundary) && !ann.IsDeleted(), AnchoredToStart = true, - AnchoredToEnd = true + AnchoredToEnd = true, } ) ); diff --git a/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/SynthesisCompoundingRule.cs b/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/SynthesisCompoundingRule.cs index 49af87957..a8f16e650 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/SynthesisCompoundingRule.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/SynthesisCompoundingRule.cs @@ -37,7 +37,7 @@ private Matcher BuildMatcher(IEnumerable ann.Type().IsOneOf(HCFeatureSystem.Segment, HCFeatureSystem.Boundary) && !ann.IsDeleted(), AnchoredToStart = true, - AnchoredToEnd = true + AnchoredToEnd = true, } ); } diff --git a/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/SynthesisRealizationalAffixProcessRule.cs b/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/SynthesisRealizationalAffixProcessRule.cs index caf399c80..1ea640909 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/SynthesisRealizationalAffixProcessRule.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/MorphologicalRules/SynthesisRealizationalAffixProcessRule.cs @@ -31,7 +31,7 @@ public SynthesisRealizationalAffixProcessRule(Morpher morpher, RealizationalAffi ann.Type().IsOneOf(HCFeatureSystem.Segment, HCFeatureSystem.Boundary) && !ann.IsDeleted(), AnchoredToStart = true, - AnchoredToEnd = true + AnchoredToEnd = true, } ) ); diff --git a/src/SIL.Machine.Morphology.HermitCrab/MprFeatureGroup.cs b/src/SIL.Machine.Morphology.HermitCrab/MprFeatureGroup.cs index cd52f2c9f..26dea8ee7 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/MprFeatureGroup.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/MprFeatureGroup.cs @@ -17,7 +17,7 @@ public enum MprFeatureGroupMatchType /// /// only if all features match within the group /// - All + All, } /// @@ -33,7 +33,7 @@ public enum MprFeatureGroupOutput /// /// appends features /// - Append + Append, } /// diff --git a/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/AnalysisMetathesisRule.cs b/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/AnalysisMetathesisRule.cs index 66dcb16ab..8b21c1853 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/AnalysisMetathesisRule.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/AnalysisMetathesisRule.cs @@ -29,7 +29,7 @@ public AnalysisMetathesisRule(Morpher morpher, MetathesisRule rule) UseDefaults = true, // during analysis shape nodes can have features that are underspecified, // so this must be non-deterministic - Nondeterministic = true + Nondeterministic = true, }; _patternRule = new IterativePhonologicalPatternRule(ruleSpec, settings); diff --git a/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/AnalysisRewriteRule.cs b/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/AnalysisRewriteRule.cs index 1915e5ccd..95eacbf73 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/AnalysisRewriteRule.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/AnalysisRewriteRule.cs @@ -16,7 +16,7 @@ private enum ReapplyType { Normal, Deletion, - SelfOpaquing + SelfOpaquing, } private readonly Morpher _morpher; @@ -35,7 +35,7 @@ public AnalysisRewriteRule(Morpher morpher, RewriteRule rule) MatchingMethod = MatchingMethod.Unification, UseDefaults = true, // during analysis shape nodes can have features that are underspecified, so this must be non-deterministic - Nondeterministic = true + Nondeterministic = true, }; _rules = new List>(); @@ -142,7 +142,6 @@ public IEnumerable Apply(Word input) switch (sr.Item1) { case ReapplyType.Normal: - { if (sr.Item2.Apply(input).Any()) srApplied = true; @@ -150,7 +149,6 @@ public IEnumerable Apply(Word input) break; case ReapplyType.Deletion: - { int j = 0; Word data = sr.Item2.Apply(input).SingleOrDefault(); @@ -166,7 +164,6 @@ public IEnumerable Apply(Word input) break; case ReapplyType.SelfOpaquing: - { Word data = sr.Item2.Apply(input).SingleOrDefault(); while (data != null) diff --git a/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/RewriteRule.cs b/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/RewriteRule.cs index 592f43b04..30aa423c6 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/RewriteRule.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/RewriteRule.cs @@ -9,7 +9,7 @@ namespace SIL.Machine.Morphology.HermitCrab.PhonologicalRules public enum RewriteApplicationMode { Iterative, - Simultaneous + Simultaneous, } public class RewriteRule : HCRuleBase, IPhonologicalRule diff --git a/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/SynthesisMetathesisRule.cs b/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/SynthesisMetathesisRule.cs index 19d8ef86d..2ea546df2 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/SynthesisMetathesisRule.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/SynthesisMetathesisRule.cs @@ -26,7 +26,7 @@ public SynthesisMetathesisRule(Morpher morpher, MetathesisRule rule) Filter = ann => ann.Type().IsOneOf(HCFeatureSystem.Segment, HCFeatureSystem.Boundary, HCFeatureSystem.Anchor) && !ann.IsDeleted(), - UseDefaults = true + UseDefaults = true, }; _patternRule = new IterativePhonologicalPatternRule(ruleSpec, settings); diff --git a/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/SynthesisRewriteRule.cs b/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/SynthesisRewriteRule.cs index 15f2088ec..1dc7e3ca5 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/SynthesisRewriteRule.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/PhonologicalRules/SynthesisRewriteRule.cs @@ -25,7 +25,7 @@ public SynthesisRewriteRule(Morpher morpher, RewriteRule rule) Filter = ann => ann.Type().IsOneOf(HCFeatureSystem.Segment, HCFeatureSystem.Boundary, HCFeatureSystem.Anchor) && !ann.IsDeleted(), - UseDefaults = true + UseDefaults = true, }; var ruleSpec = new SynthesisRewriteRuleSpec( diff --git a/src/SIL.Machine.Morphology.HermitCrab/Stratum.cs b/src/SIL.Machine.Morphology.HermitCrab/Stratum.cs index 025af7e50..f0fc7e197 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/Stratum.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/Stratum.cs @@ -9,7 +9,7 @@ namespace SIL.Machine.Morphology.HermitCrab public enum MorphologicalRuleOrder { Linear, - Unordered + Unordered, } /// diff --git a/src/SIL.Machine.Morphology.HermitCrab/SyntacticFeatureSystem.cs b/src/SIL.Machine.Morphology.HermitCrab/SyntacticFeatureSystem.cs index fb7310dc4..e6ac031c2 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/SyntacticFeatureSystem.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/SyntacticFeatureSystem.cs @@ -7,7 +7,7 @@ namespace SIL.Machine.Morphology.HermitCrab public enum SyntacticFeatureType { Head, - Foot + Foot, } public class SyntacticFeatureSystem : FeatureSystem diff --git a/src/SIL.Machine.Morphology.HermitCrab/SynthesisAffixTemplatesRule.cs b/src/SIL.Machine.Morphology.HermitCrab/SynthesisAffixTemplatesRule.cs index cf47988f1..1d878cd75 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/SynthesisAffixTemplatesRule.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/SynthesisAffixTemplatesRule.cs @@ -99,7 +99,7 @@ private Word ChooseInflectionalStem(Word input) { best = new Word(relative.PrimaryAllomorph, input.RealizationalFeatureStruct.Clone()) { - CurrentTrace = input.CurrentTrace + CurrentTrace = input.CurrentTrace, }; best.Freeze(); } diff --git a/src/SIL.Machine.Morphology.HermitCrab/Trace.cs b/src/SIL.Machine.Morphology.HermitCrab/Trace.cs index a0145ed87..10abc27ab 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/Trace.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/Trace.cs @@ -112,7 +112,7 @@ public enum TraceType /// /// Parse failed trace /// - Failed + Failed, } /// diff --git a/src/SIL.Machine.Morphology.HermitCrab/TraceManager.cs b/src/SIL.Machine.Morphology.HermitCrab/TraceManager.cs index 03da55987..56a4119a5 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/TraceManager.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/TraceManager.cs @@ -35,7 +35,7 @@ public void PhonologicalRuleUnapplied(IPhonologicalRule rule, int subruleIndex, { SubruleIndex = subruleIndex, Input = input, - Output = output.Clone() + Output = output.Clone(), } ); } @@ -46,7 +46,7 @@ public void PhonologicalRuleNotUnapplied(IPhonologicalRule rule, int subruleInde new Trace(TraceType.PhonologicalRuleAnalysis, rule) { SubruleIndex = subruleIndex, - Input = input.Clone() + Input = input.Clone(), } ); } @@ -71,7 +71,7 @@ public void MorphologicalRuleUnapplied(IMorphologicalRule rule, int subruleIndex { SubruleIndex = subruleIndex, Input = input, - Output = output + Output = output, }; ((Trace)output.CurrentTrace).Children.Add(trace); output.CurrentTrace = trace; @@ -97,7 +97,7 @@ object failureObj { SubruleIndex = subruleIndex, Input = input, - FailureReason = reason + FailureReason = reason, } ); } @@ -115,7 +115,7 @@ object failureObj { SubruleIndex = subruleIndex, Input = input, - FailureReason = reason + FailureReason = reason, } ); } @@ -148,7 +148,7 @@ public void NonFinalTemplateAppliedLast(Stratum stratum, Word word) new Trace(TraceType.StratumSynthesisOutput, stratum) { Output = word, - FailureReason = FailureReason.PartialParse + FailureReason = FailureReason.PartialParse, } ); } @@ -159,7 +159,7 @@ public void ApplicableTemplatesNotApplied(Stratum stratum, Word word) new Trace(TraceType.StratumSynthesisOutput, stratum) { Output = word, - FailureReason = FailureReason.PartialParse + FailureReason = FailureReason.PartialParse, } ); } @@ -178,7 +178,7 @@ public void PhonologicalRuleApplied(IPhonologicalRule rule, int subruleIndex, Wo { SubruleIndex = subruleIndex, Input = input, - Output = output.Clone() + Output = output.Clone(), } ); } @@ -196,7 +196,7 @@ object failureObj { SubruleIndex = subruleIndex, Input = input.Clone(), - FailureReason = reason + FailureReason = reason, } ); } @@ -221,7 +221,7 @@ public void MorphologicalRuleApplied(IMorphologicalRule rule, int subruleIndex, { SubruleIndex = subruleIndex, Input = input, - Output = output + Output = output, }; ((Trace)output.CurrentTrace).Children.Add(trace); output.CurrentTrace = trace; @@ -240,7 +240,7 @@ object failureObj { SubruleIndex = subruleIndex, Input = input, - FailureReason = reason + FailureReason = reason, } ); } diff --git a/src/SIL.Machine.Morphology.HermitCrab/Word.cs b/src/SIL.Machine.Morphology.HermitCrab/Word.cs index 73ed28f19..9b29429e9 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/Word.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/Word.cs @@ -486,7 +486,7 @@ internal bool CheckBlocking(out Word word) { word = new Word(entry.PrimaryAllomorph, RealizationalFeatureStruct.Clone()) { - CurrentTrace = CurrentTrace + CurrentTrace = CurrentTrace, }; word.Freeze(); return true; diff --git a/src/SIL.Machine.Morphology.HermitCrab/XmlLanguageLoader.cs b/src/SIL.Machine.Morphology.HermitCrab/XmlLanguageLoader.cs index 97d69dad3..6469f7990 100644 --- a/src/SIL.Machine.Morphology.HermitCrab/XmlLanguageLoader.cs +++ b/src/SIL.Machine.Morphology.HermitCrab/XmlLanguageLoader.cs @@ -210,7 +210,7 @@ private Language Load() { DtdProcessing = DtdProcessing.Parse, ValidationType = Type.GetType("Mono.Runtime") == null ? ValidationType.DTD : ValidationType.None, - XmlResolver = new ResourceXmlResolver() + XmlResolver = new ResourceXmlResolver(), }; using (XmlReader reader = XmlReader.Create(_configPath, settings)) @@ -362,7 +362,7 @@ private void LoadStratum(XElement stratumElem) Name = (string)stratumElem.Element("Name"), MorphologicalRuleOrder = GetMorphologicalRuleOrder( (string)stratumElem.Attribute("morphologicalRuleOrder") - ) + ), }; var pruleIdsStr = (string)stratumElem.Attribute("phonologicalRules"); @@ -701,7 +701,7 @@ private void LoadNaturalClass(XElement natClassElem) case "FeatureNaturalClass": nc = new NaturalClass(LoadFeatureStruct(natClassElem, _language.PhonologicalFeatureSystem)) { - Name = (string)natClassElem.Element("Name") + Name = (string)natClassElem.Element("Name"), }; break; @@ -710,7 +710,7 @@ private void LoadNaturalClass(XElement natClassElem) natClassElem.Elements("Segment").Select(se => _charDefs[(string)se.Attribute("segment")]) ) { - Name = (string)natClassElem.Element("Name") + Name = (string)natClassElem.Element("Name"), }; break; } @@ -754,7 +754,7 @@ private void LoadRewriteRule(XElement pruleElem) { Name = (string)pruleElem.Element("Name"), ApplicationMode = GetApplicationMode(multAppOrderStr), - Direction = GetDirection(multAppOrderStr) + Direction = GetDirection(multAppOrderStr), }; Dictionary> variables = LoadVariables( pruleElem.Element("VariableFeatures") @@ -830,13 +830,13 @@ private void LoadMetathesisRule(XElement metathesisElem) Name = (string)metathesisElem.Element("Name"), Direction = GetDirection((string)metathesisElem.Attribute("multipleApplicationOrder")), LeftSwitchName = "r", - RightSwitchName = "l" + RightSwitchName = "l", }; var groupNames = new Dictionary { { (string)metathesisElem.Attribute("leftSwitch"), "r" }, - { (string)metathesisElem.Attribute("rightSwitch"), "l" } + { (string)metathesisElem.Attribute("rightSwitch"), "l" }, }; metathesisRule.Pattern = LoadPhoneticTemplate( metathesisElem.Elements("StructuralDescription").Elements("PhoneticTemplate").Single(), @@ -862,7 +862,7 @@ out IMorphologicalRule mrule Id = (string)mruleElem.Element("MorphemeId"), Gloss = (string)mruleElem.Element("Gloss"), Blockable = (bool?)mruleElem.Attribute("blockable") ?? true, - IsPartial = (bool?)mruleElem.Attribute("partial") ?? false + IsPartial = (bool?)mruleElem.Attribute("partial") ?? false, }; var multApp = (string)mruleElem.Attribute("multipleApplication"); if (!string.IsNullOrEmpty(multApp)) @@ -956,7 +956,7 @@ out IMorphologicalRule mrule Name = (string)realRuleElem.Element("Name"), Id = (string)realRuleElem.Element("MorphemeId"), Gloss = (string)realRuleElem.Element("Gloss"), - Blockable = (bool?)realRuleElem.Attribute("blockable") ?? true + Blockable = (bool?)realRuleElem.Attribute("blockable") ?? true, }; var fs = new FeatureStruct(); @@ -1149,7 +1149,7 @@ out IMorphologicalRule mrule var compRule = new CompoundingRule { Name = (string)compRuleElem.Element("Name"), - Blockable = (bool?)compRuleElem.Attribute("blockable") ?? true + Blockable = (bool?)compRuleElem.Attribute("blockable") ?? true, }; var multApp = (string)compRuleElem.Attribute("multipleApplication"); if (!string.IsNullOrEmpty(multApp)) @@ -1301,7 +1301,7 @@ private AffixTemplate LoadAffixTemplate(XElement tempElem, Dictionary groupNames segments.Shape.Select(n => new Constraint(n.Annotation.FeatureStruct)) ) { - Tag = segments + Tag = segments, }; break; } diff --git a/src/SIL.Machine.Plugin/SIL.Machine.Plugin.csproj b/src/SIL.Machine.Plugin/SIL.Machine.Plugin.csproj index faf3831a6..b311b2571 100644 --- a/src/SIL.Machine.Plugin/SIL.Machine.Plugin.csproj +++ b/src/SIL.Machine.Plugin/SIL.Machine.Plugin.csproj @@ -1,7 +1,7 @@ - net8.0 + net10.0 A plugin framework for the Machine library. true true @@ -12,7 +12,7 @@ - + diff --git a/src/SIL.Machine.Tokenization.SentencePiece/SentencePieceApi.cs b/src/SIL.Machine.Tokenization.SentencePiece/SentencePieceApi.cs index 32288aeba..09cb42dd3 100644 --- a/src/SIL.Machine.Tokenization.SentencePiece/SentencePieceApi.cs +++ b/src/SIL.Machine.Tokenization.SentencePiece/SentencePieceApi.cs @@ -22,7 +22,7 @@ internal enum StatusCode Internal = 13, Unavailable = 14, DataLoss = 15, - Unauthenticated = 16 + Unauthenticated = 16, } internal static class SentencePieceApi diff --git a/src/SIL.Machine.Tokenization.SentencePiece/SentencePieceTrainer.cs b/src/SIL.Machine.Tokenization.SentencePiece/SentencePieceTrainer.cs index c6862981f..19c726c99 100644 --- a/src/SIL.Machine.Tokenization.SentencePiece/SentencePieceTrainer.cs +++ b/src/SIL.Machine.Tokenization.SentencePiece/SentencePieceTrainer.cs @@ -8,7 +8,7 @@ public enum SentencePieceModelType Unigram, Bpe, Word, - Char + Char, } public class SentencePieceTrainer diff --git a/src/SIL.Machine.Tool/AlignCommand.cs b/src/SIL.Machine.Tool/AlignCommand.cs index 7888c7396..d0a4dbe4d 100644 --- a/src/SIL.Machine.Tool/AlignCommand.cs +++ b/src/SIL.Machine.Tool/AlignCommand.cs @@ -106,7 +106,7 @@ protected override async Task ExecuteCommandAsync(CancellationToken cancell new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = processorCount - 1, - BoundedCapacity = 100000 + BoundedCapacity = 100000, } ); diff --git a/src/SIL.Machine.Tool/AlignmentModelCommandSpec.cs b/src/SIL.Machine.Tool/AlignmentModelCommandSpec.cs index 130679d3f..3e5153d7d 100644 --- a/src/SIL.Machine.Tool/AlignmentModelCommandSpec.cs +++ b/src/SIL.Machine.Tool/AlignmentModelCommandSpec.cs @@ -203,7 +203,7 @@ public ITrainer CreateAlignmentModelTrainer( return new ThotWordAlignmentModelTrainer(modelType, trainCorpus, $"{modelPath}_{modelStr}", thotParameters) { - MaxCorpusCount = maxSize + MaxCorpusCount = maxSize, }; } @@ -234,7 +234,7 @@ private static bool ValidateAlignmentModelTypeOption(string value, IEnumerable ExecuteCommandAsync(CancellationToken cancellationTo protected void AddCommand(CommandBase command) { command.Parent = this; - Commands.Add(command); + AddSubcommand(command); } protected TSpec AddSpec(TSpec spec) diff --git a/src/SIL.Machine.Tool/SIL.Machine.Tool.csproj b/src/SIL.Machine.Tool/SIL.Machine.Tool.csproj index e36b89085..77d2874ce 100644 --- a/src/SIL.Machine.Tool/SIL.Machine.Tool.csproj +++ b/src/SIL.Machine.Tool/SIL.Machine.Tool.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net10.0 SIL.Machine true machine @@ -18,8 +18,8 @@ - - + + diff --git a/src/SIL.Machine.Tool/ToolHelpers.cs b/src/SIL.Machine.Tool/ToolHelpers.cs index 9d5907dfb..4cfd8bd14 100644 --- a/src/SIL.Machine.Tool/ToolHelpers.cs +++ b/src/SIL.Machine.Tool/ToolHelpers.cs @@ -177,7 +177,7 @@ int maxSize return new ThotSmtModelTrainer(wordAlignmentModelType, corpus, modelConfigFileName) { - MaxCorpusCount = maxSize + MaxCorpusCount = maxSize, }; } @@ -191,7 +191,7 @@ public static bool ValidateSymmetrizationHeuristicOption(string value, bool none Grow, GrowDiag, GrowDiagFinal, - GrowDiagFinalAnd + GrowDiagFinalAnd, }; if (noneAllowed) validHeuristics.Add(None); diff --git a/src/SIL.Machine.Tool/TrainAlignmentModelCommand.cs b/src/SIL.Machine.Tool/TrainAlignmentModelCommand.cs index bbe64558f..c1772656e 100644 --- a/src/SIL.Machine.Tool/TrainAlignmentModelCommand.cs +++ b/src/SIL.Machine.Tool/TrainAlignmentModelCommand.cs @@ -69,7 +69,7 @@ protected override async Task ExecuteCommandAsync(CancellationToken cancell new Phase("Training direct model", 0.48), new Phase("Saving direct model", 0.02), new Phase("Training inverse model", 0.48), - new Phase("Saving inverse model", 0.02) + new Phase("Saving inverse model", 0.02), }; } var reporter = new PhasedProgressReporter(progress, phases); diff --git a/src/SIL.Machine.Translation.TensorFlow/SavedModelNmtEngine.cs b/src/SIL.Machine.Translation.TensorFlow/SavedModelNmtEngine.cs index b6ffaba5e..c2fea6b9a 100644 --- a/src/SIL.Machine.Translation.TensorFlow/SavedModelNmtEngine.cs +++ b/src/SIL.Machine.Translation.TensorFlow/SavedModelNmtEngine.cs @@ -219,7 +219,7 @@ IReadOnlyList> segments long end = start + outputLength; var builder = new TranslationResultBuilder(sourceTokenStrs[i]) { - TargetDetokenizer = TargetDetokenizer + TargetDetokenizer = TargetDetokenizer, }; for (long k = start; k < end; k++) builder.AppendToken(outputTokenStrs[k], TranslationSources.Nmt, 1); diff --git a/src/SIL.Machine.Translation.Thot/Thot.cs b/src/SIL.Machine.Translation.Thot/Thot.cs index 31a090cce..a6c96562f 100644 --- a/src/SIL.Machine.Translation.Thot/Thot.cs +++ b/src/SIL.Machine.Translation.Thot/Thot.cs @@ -21,7 +21,7 @@ public enum AlignmentModelType FastAlign = 5, IncrIbm1 = 6, IncrIbm2 = 7, - IncrHmm = 8 + IncrHmm = 8, } [DllImport("thot", CallingConvention = CallingConvention.Cdecl)] diff --git a/src/SIL.Machine.Translation.Thot/ThotSmtDecoder.cs b/src/SIL.Machine.Translation.Thot/ThotSmtDecoder.cs index e35958a26..8f98ae9c4 100644 --- a/src/SIL.Machine.Translation.Thot/ThotSmtDecoder.cs +++ b/src/SIL.Machine.Translation.Thot/ThotSmtDecoder.cs @@ -294,7 +294,7 @@ IntPtr dataPtr { var builder = new TranslationResultBuilder(sourceTokens) { - TargetDetokenizer = _smtModel.TargetDetokenizer + TargetDetokenizer = _smtModel.TargetDetokenizer, }; var confidenceEstimator = new Ibm1WordConfidenceEstimator( _smtModel.SymmetrizedWordAlignmentModel.GetTranslationScore, diff --git a/src/SIL.Machine.Translation.Thot/ThotSmtModel.cs b/src/SIL.Machine.Translation.Thot/ThotSmtModel.cs index 88e790a0d..fe12451f0 100644 --- a/src/SIL.Machine.Translation.Thot/ThotSmtModel.cs +++ b/src/SIL.Machine.Translation.Thot/ThotSmtModel.cs @@ -263,7 +263,7 @@ public async Task> TranslateBatchAsync( new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = MaxDecoderPoolSize, - CancellationToken = cancellationToken + CancellationToken = cancellationToken, } ); @@ -293,7 +293,7 @@ public async Task> TranslateBatchAsync( new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = MaxDecoderPoolSize, - CancellationToken = cancellationToken + CancellationToken = cancellationToken, } ); @@ -324,7 +324,7 @@ public async Task>> TranslateBatc new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = MaxDecoderPoolSize, - CancellationToken = cancellationToken + CancellationToken = cancellationToken, } ); @@ -355,7 +355,7 @@ public async Task>> TranslateBatc new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = MaxDecoderPoolSize, - CancellationToken = cancellationToken + CancellationToken = cancellationToken, } ); diff --git a/src/SIL.Machine.Translation.Thot/ThotSmtModelTrainer.cs b/src/SIL.Machine.Translation.Thot/ThotSmtModelTrainer.cs index 4ffe129fe..d7a1ed7a2 100644 --- a/src/SIL.Machine.Translation.Thot/ThotSmtModelTrainer.cs +++ b/src/SIL.Machine.Translation.Thot/ThotSmtModelTrainer.cs @@ -459,7 +459,7 @@ CancellationToken cancellationToken { HmmP0 = 0.1, HmmLexicalSmoothingFactor = 0.1, - HmmAlignmentSmoothingFactor = 0.3 + HmmAlignmentSmoothingFactor = 0.3, }; if (_wordAlignmentModelType == ThotWordAlignmentModelType.FastAlign) { diff --git a/src/SIL.Machine.Translation.Thot/ThotSmtParameters.cs b/src/SIL.Machine.Translation.Thot/ThotSmtParameters.cs index 656629cf6..47ae8e934 100644 --- a/src/SIL.Machine.Translation.Thot/ThotSmtParameters.cs +++ b/src/SIL.Machine.Translation.Thot/ThotSmtParameters.cs @@ -12,14 +12,14 @@ public enum ModelHeuristic : uint { NoHeuristic = 0, LocalT = 4, - LocalTD = 6 + LocalTD = 6, } public enum LearningAlgorithm : uint { BasicIncrementalTraining = 0, MinibatchTraining = 1, - BatchRetraining = 2 + BatchRetraining = 2, } public enum LearningRatePolicy : uint @@ -27,7 +27,7 @@ public enum LearningRatePolicy : uint Fixed = 0, Liang = 1, Own = 2, - WerBased = 3 + WerBased = 3, } public class ThotSmtParameters : Freezable, ICloneable diff --git a/src/SIL.Machine.Translation.Thot/ThotTrainProgressReporter.cs b/src/SIL.Machine.Translation.Thot/ThotTrainProgressReporter.cs index de0b4ee30..628dafb67 100644 --- a/src/SIL.Machine.Translation.Thot/ThotTrainProgressReporter.cs +++ b/src/SIL.Machine.Translation.Thot/ThotTrainProgressReporter.cs @@ -17,7 +17,7 @@ public class ThotTrainProgressReporter : PhasedProgressReporter new Phase("Generating phrase table"), new Phase("Tuning language model"), new Phase("Tuning translation model", 0.4, reportSteps: false), - new Phase("Finalizing", 0.05, reportSteps: false) + new Phase("Finalizing", 0.05, reportSteps: false), }; private readonly CancellationToken _cancellationToken; diff --git a/src/SIL.Machine.Translation.Thot/ThotWordAlignmentModelType.cs b/src/SIL.Machine.Translation.Thot/ThotWordAlignmentModelType.cs index 5492f62a1..c8ed14b9b 100644 --- a/src/SIL.Machine.Translation.Thot/ThotWordAlignmentModelType.cs +++ b/src/SIL.Machine.Translation.Thot/ThotWordAlignmentModelType.cs @@ -7,7 +7,7 @@ public enum ThotWordAlignmentModelType Ibm2, Hmm, Ibm3, - Ibm4 + Ibm4, } public class ThotWordAlignmentModelTypeHelpers diff --git a/src/SIL.Machine/Annotations/Shape.cs b/src/SIL.Machine/Annotations/Shape.cs index 3f7ec11a2..ecea24a02 100644 --- a/src/SIL.Machine/Annotations/Shape.cs +++ b/src/SIL.Machine/Annotations/Shape.cs @@ -277,7 +277,7 @@ Annotation ann in annList : Range.Create(ann.Range.Start, node.Prev); var newAnn = new Annotation(range, ann.FeatureStruct.Clone()) { - Optional = ann.Optional + Optional = ann.Optional, }; if (!ann.IsLeaf) { diff --git a/src/SIL.Machine/Corpora/AlignedWordPair.cs b/src/SIL.Machine/Corpora/AlignedWordPair.cs index 7579dc88d..a031a7be4 100644 --- a/src/SIL.Machine/Corpora/AlignedWordPair.cs +++ b/src/SIL.Machine/Corpora/AlignedWordPair.cs @@ -73,12 +73,12 @@ out translationScore ? new AlignedWordPair(j, i) { TranslationScore = translationScore, - AlignmentScore = alignmentScore + AlignmentScore = alignmentScore, } : new AlignedWordPair(i, j) { TranslationScore = translationScore, - AlignmentScore = alignmentScore + AlignmentScore = alignmentScore, } ); } @@ -104,7 +104,7 @@ public AlignedWordPair Invert() { IsSure = IsSure, TranslationScore = TranslationScore, - AlignmentScore = AlignmentScore + AlignmentScore = AlignmentScore, }; } diff --git a/src/SIL.Machine/Corpora/AlignmentRow.cs b/src/SIL.Machine/Corpora/AlignmentRow.cs index d6d3a4e82..c87254a77 100644 --- a/src/SIL.Machine/Corpora/AlignmentRow.cs +++ b/src/SIL.Machine/Corpora/AlignmentRow.cs @@ -24,7 +24,7 @@ public AlignmentRow Invert() { return new AlignmentRow(TextId, Ref) { - AlignedWordPairs = new HashSet(AlignedWordPairs.Select(wp => wp.Invert())) + AlignedWordPairs = new HashSet(AlignedWordPairs.Select(wp => wp.Invert())), }; } } diff --git a/src/SIL.Machine/Corpora/CorporaExtensions.cs b/src/SIL.Machine/Corpora/CorporaExtensions.cs index 372ba2014..e757c297c 100644 --- a/src/SIL.Machine/Corpora/CorporaExtensions.cs +++ b/src/SIL.Machine/Corpora/CorporaExtensions.cs @@ -241,7 +241,7 @@ public static IParallelTextCorpus AlignRows( return new ParallelTextCorpus(sourceCorpus, targetCorpus, alignmentCorpus, rowRefComparer) { AllSourceRows = allSourceRows, - AllTargetRows = allTargetRows + AllTargetRows = allTargetRows, }; } diff --git a/src/SIL.Machine/Corpora/MergeRule.cs b/src/SIL.Machine/Corpora/MergeRule.cs index be9a2ceec..bb0c94f59 100644 --- a/src/SIL.Machine/Corpora/MergeRule.cs +++ b/src/SIL.Machine/Corpora/MergeRule.cs @@ -3,6 +3,6 @@ namespace SIL.Machine.Corpora public enum MergeRule { First, - Random + Random, } } diff --git a/src/SIL.Machine/Corpora/MergedTextCorpus.cs b/src/SIL.Machine/Corpora/MergedTextCorpus.cs index 5e85b60bf..67f7586fa 100644 --- a/src/SIL.Machine/Corpora/MergedTextCorpus.cs +++ b/src/SIL.Machine/Corpora/MergedTextCorpus.cs @@ -69,7 +69,7 @@ public override IEnumerable GetRows(IEnumerable textIds) yield return new TextRow(nRow.TextId, nRow.Ref) { Segment = nRow.NSegments[indexOfSelectedRow], - Flags = nRow.NFlags[indexOfSelectedRow] + Flags = nRow.NFlags[indexOfSelectedRow], }; } } diff --git a/src/SIL.Machine/Corpora/NParallelTextCorpus.cs b/src/SIL.Machine/Corpora/NParallelTextCorpus.cs index 94673413d..f51970fd2 100644 --- a/src/SIL.Machine/Corpora/NParallelTextCorpus.cs +++ b/src/SIL.Machine/Corpora/NParallelTextCorpus.cs @@ -101,7 +101,7 @@ private IEnumerable GetRows(IList> enumer var rangeInfo = new NRangeInfo(N) { Versifications = Corpora.Select(c => c.Versification).ToArray(), - RowRefComparer = RowRefComparer + RowRefComparer = RowRefComparer, }; List> sameRefRows = new List>(); for (int i = 0; i < N; i++) @@ -332,7 +332,7 @@ private IEnumerable CreateRows( yield return new NParallelTextRow(textId, refs, contentType) { NSegments = rows.Select(r => r?.Segment ?? Array.Empty()).ToArray(), - NFlags = flags.ToReadOnlyList() + NFlags = flags.ToReadOnlyList(), }; } @@ -511,7 +511,7 @@ public NParallelTextRow CreateRow() { NSegments = Rows.Select(r => r.Segment.ToArray()).ToArray(), NFlags = Rows.Select(r => r.IsSentenceStart ? TextRowFlags.SentenceStart : TextRowFlags.None) - .ToArray() + .ToArray(), }; TextId = ""; foreach (RangeRow r in Rows) diff --git a/src/SIL.Machine/Corpora/NParallelTextRow.cs b/src/SIL.Machine/Corpora/NParallelTextRow.cs index d939534c8..babc09cd9 100644 --- a/src/SIL.Machine/Corpora/NParallelTextRow.cs +++ b/src/SIL.Machine/Corpora/NParallelTextRow.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; diff --git a/src/SIL.Machine/Corpora/ParallelTextCorpus.cs b/src/SIL.Machine/Corpora/ParallelTextCorpus.cs index f7d8f6700..28c54c014 100644 --- a/src/SIL.Machine/Corpora/ParallelTextCorpus.cs +++ b/src/SIL.Machine/Corpora/ParallelTextCorpus.cs @@ -70,7 +70,7 @@ public override IEnumerable GetRows(IEnumerable textIds SourceSegment = nRow.NSegments[0], TargetSegment = nRow.NSegments[1], AlignedWordPairs = - compareAlignmentCorpus == 0 ? alignmentEnumerator.Current.AlignedWordPairs.ToArray() : null + compareAlignmentCorpus == 0 ? alignmentEnumerator.Current.AlignedWordPairs.ToArray() : null, }; } } diff --git a/src/SIL.Machine/Corpora/ParallelTextRow.cs b/src/SIL.Machine/Corpora/ParallelTextRow.cs index 7cc981300..a0bd33b9b 100644 --- a/src/SIL.Machine/Corpora/ParallelTextRow.cs +++ b/src/SIL.Machine/Corpora/ParallelTextRow.cs @@ -67,7 +67,7 @@ public ParallelTextRow Invert() ? null : new HashSet(AlignedWordPairs.Select(wp => wp.Invert())), SourceFlags = TargetFlags, - TargetFlags = SourceFlags + TargetFlags = SourceFlags, }; } } diff --git a/src/SIL.Machine/Corpora/ParatextBackupTermsCorpus.cs b/src/SIL.Machine/Corpora/ParatextBackupTermsCorpus.cs index e8db5d93c..30640657a 100644 --- a/src/SIL.Machine/Corpora/ParatextBackupTermsCorpus.cs +++ b/src/SIL.Machine/Corpora/ParatextBackupTermsCorpus.cs @@ -29,7 +29,7 @@ public ParatextBackupTermsCorpus( keyTerms.SelectMany(keyTerm => keyTerm.Renderings.Select(gloss => new TextRow(textId, keyTerm.Id, TextRowContentType.Word) { - Segment = new string[] { gloss } + Segment = new string[] { gloss }, }) ) ); diff --git a/src/SIL.Machine/Corpora/ParatextBackupTextCorpus.cs b/src/SIL.Machine/Corpora/ParatextBackupTextCorpus.cs index 11fb9cb97..28e0a654a 100644 --- a/src/SIL.Machine/Corpora/ParatextBackupTextCorpus.cs +++ b/src/SIL.Machine/Corpora/ParatextBackupTextCorpus.cs @@ -29,7 +29,7 @@ public ParatextBackupTextCorpus(string fileName, bool includeMarkers = false, bo includeAllText ) { - Project = settings.Name + Project = settings.Name, } ); } diff --git a/src/SIL.Machine/Corpora/ParatextProjectTermsParserBase.cs b/src/SIL.Machine/Corpora/ParatextProjectTermsParserBase.cs index fdc3f2ac3..56f9de96c 100644 --- a/src/SIL.Machine/Corpora/ParatextProjectTermsParserBase.cs +++ b/src/SIL.Machine/Corpora/ParatextProjectTermsParserBase.cs @@ -18,7 +18,7 @@ public abstract class ParatextProjectTermsParserBase "Major", "All", "SilNt", - "Pt6" + "Pt6", }; private static readonly Dictionary SupportedLanguageTermsLocalizationXmls = new Dictionary< @@ -30,7 +30,7 @@ public abstract class ParatextProjectTermsParserBase { "es", "SIL.Machine.Corpora.BiblicalTermsEs.xml" }, { "fr", "SIL.Machine.Corpora.BiblicalTermsFr.xml" }, { "id", "SIL.Machine.Corpora.BiblicalTermsId.xml" }, - { "pt", "SIL.Machine.Corpora.BiblicalTermsPt.xml" } + { "pt", "SIL.Machine.Corpora.BiblicalTermsPt.xml" }, }; private static readonly Regex ContentInBracketsRegex = new Regex(@"^\[(.+?)\]$", RegexOptions.Compiled); diff --git a/src/SIL.Machine/Corpora/ParatextTextCorpus.cs b/src/SIL.Machine/Corpora/ParatextTextCorpus.cs index fff01300f..486fbfb2b 100644 --- a/src/SIL.Machine/Corpora/ParatextTextCorpus.cs +++ b/src/SIL.Machine/Corpora/ParatextTextCorpus.cs @@ -31,7 +31,7 @@ string sfmFileName in Directory.EnumerateFiles( includeAllText ) { - Project = settings.Name + Project = settings.Name, } ); } diff --git a/src/SIL.Machine/Corpora/ScriptureRefUsfmParserHandlerBase.cs b/src/SIL.Machine/Corpora/ScriptureRefUsfmParserHandlerBase.cs index e017c308b..ec2429b07 100644 --- a/src/SIL.Machine/Corpora/ScriptureRefUsfmParserHandlerBase.cs +++ b/src/SIL.Machine/Corpora/ScriptureRefUsfmParserHandlerBase.cs @@ -9,7 +9,7 @@ public enum ScriptureTextType None, NonVerse, Verse, - Embed + Embed, } public abstract class ScriptureRefUsfmParserHandlerBase : UsfmParserHandlerBase diff --git a/src/SIL.Machine/Corpora/TextBase.cs b/src/SIL.Machine/Corpora/TextBase.cs index 3db21d542..e8b3d5825 100644 --- a/src/SIL.Machine/Corpora/TextBase.cs +++ b/src/SIL.Machine/Corpora/TextBase.cs @@ -37,7 +37,7 @@ protected TextRow CreateRow(string text, object segRef, TextRowFlags flags = Tex return new TextRow(Id, segRef, DefaultContentType) { Segment = text.Length == 0 ? Array.Empty() : new[] { text }, - Flags = flags + Flags = flags, }; } diff --git a/src/SIL.Machine/Corpora/TextCorpusEnumerator.cs b/src/SIL.Machine/Corpora/TextCorpusEnumerator.cs index 7653a135c..7d9547f53 100644 --- a/src/SIL.Machine/Corpora/TextCorpusEnumerator.cs +++ b/src/SIL.Machine/Corpora/TextCorpusEnumerator.cs @@ -95,7 +95,7 @@ private void CollectVerses() new TextRow(rangeStartRow.TextId, rangeStartRow.Ref) { Segment = rangeStartRow.Segment.Concat(row.Segment).ToArray(), - Flags = flags + Flags = flags, } ); row = new TextRow(row.TextId, row.Ref) { Flags = TextRowFlags.InRange }; diff --git a/src/SIL.Machine/Corpora/TextRow.cs b/src/SIL.Machine/Corpora/TextRow.cs index 3b4298f2a..b2d48d737 100644 --- a/src/SIL.Machine/Corpora/TextRow.cs +++ b/src/SIL.Machine/Corpora/TextRow.cs @@ -9,7 +9,7 @@ public enum TextRowFlags None = 0x0, SentenceStart = 0x1, InRange = 0x2, - RangeStart = 0x4 + RangeStart = 0x4, } public class TextRow : IRow diff --git a/src/SIL.Machine/Corpora/UpdateUsfmParserHandler.cs b/src/SIL.Machine/Corpora/UpdateUsfmParserHandler.cs index c6354ec62..76a59336c 100644 --- a/src/SIL.Machine/Corpora/UpdateUsfmParserHandler.cs +++ b/src/SIL.Machine/Corpora/UpdateUsfmParserHandler.cs @@ -9,7 +9,7 @@ public enum UpdateUsfmTextBehavior { PreferExisting, PreferNew, - StripExisting + StripExisting, } public enum UpdateUsfmMarkerBehavior diff --git a/src/SIL.Machine/Corpora/UsfmParserState.cs b/src/SIL.Machine/Corpora/UsfmParserState.cs index 66f9e3e0b..40adc6f9b 100644 --- a/src/SIL.Machine/Corpora/UsfmParserState.cs +++ b/src/SIL.Machine/Corpora/UsfmParserState.cs @@ -217,7 +217,7 @@ public enum UsfmElementType Row, Cell, Note, - Sidebar + Sidebar, }; /// diff --git a/src/SIL.Machine/Corpora/UsfmStylesheet.cs b/src/SIL.Machine/Corpora/UsfmStylesheet.cs index e63f8c96b..422624ea4 100644 --- a/src/SIL.Machine/Corpora/UsfmStylesheet.cs +++ b/src/SIL.Machine/Corpora/UsfmStylesheet.cs @@ -20,7 +20,7 @@ public class UsfmStylesheet { "left", UsfmJustification.Left }, { "center", UsfmJustification.Center }, { "right", UsfmJustification.Right }, - { "both", UsfmJustification.Both } + { "both", UsfmJustification.Both }, }; private static readonly Dictionary StyleMappings = new Dictionary( @@ -30,7 +30,7 @@ public class UsfmStylesheet { "character", UsfmStyleType.Character }, { "paragraph", UsfmStyleType.Paragraph }, { "note", UsfmStyleType.Note }, - { "milestone", UsfmStyleType.Milestone } + { "milestone", UsfmStyleType.Milestone }, }; private static readonly Dictionary TextTypeMappings = new Dictionary< @@ -46,7 +46,7 @@ public class UsfmStylesheet { "backtranslation", UsfmTextType.BackTranslation }, { "translationnote", UsfmTextType.TranslationNote }, { "versenumber", UsfmTextType.VerseText }, - { "chapternumber", UsfmTextType.Other } + { "chapternumber", UsfmTextType.Other }, }; private static readonly Dictionary TextPropertyMappings = new Dictionary< @@ -69,7 +69,7 @@ public class UsfmStylesheet { "nonpublishable", UsfmTextProperties.Nonpublishable }, { "nonvernacular", UsfmTextProperties.Nonvernacular }, { "book", UsfmTextProperties.Book }, - { "note", UsfmTextProperties.Note } + { "note", UsfmTextProperties.Note }, }; private readonly Dictionary _tags; diff --git a/src/SIL.Machine/Corpora/UsfmTag.cs b/src/SIL.Machine/Corpora/UsfmTag.cs index 3a2cdf580..12dc53e7b 100644 --- a/src/SIL.Machine/Corpora/UsfmTag.cs +++ b/src/SIL.Machine/Corpora/UsfmTag.cs @@ -13,7 +13,7 @@ public enum UsfmTextType NoteText = 0x8, Other = 0x10, BackTranslation = 0x20, - TranslationNote = 0x40 + TranslationNote = 0x40, } public enum UsfmJustification @@ -21,7 +21,7 @@ public enum UsfmJustification Left, Center, Right, - Both + Both, } public enum UsfmStyleType @@ -32,7 +32,7 @@ public enum UsfmStyleType Paragraph, End, Milestone, - MilestoneEnd + MilestoneEnd, } [Flags] @@ -56,7 +56,7 @@ public enum UsfmTextProperties Nonpublishable = 0x4000, Nonvernacular = 0x8000, Book = 0x10000, - Note = 0x20000 + Note = 0x20000, } public sealed class UsfmStyleAttribute diff --git a/src/SIL.Machine/Corpora/UsfmToken.cs b/src/SIL.Machine/Corpora/UsfmToken.cs index 90b934f29..43a621b7a 100644 --- a/src/SIL.Machine/Corpora/UsfmToken.cs +++ b/src/SIL.Machine/Corpora/UsfmToken.cs @@ -19,7 +19,7 @@ public enum UsfmTokenType Milestone, MilestoneEnd, Attribute, - Unknown + Unknown, } public class UsfmToken : IEquatable diff --git a/src/SIL.Machine/Corpora/UsfmTokenizer.cs b/src/SIL.Machine/Corpora/UsfmTokenizer.cs index c03b836d1..f07886df9 100644 --- a/src/SIL.Machine/Corpora/UsfmTokenizer.cs +++ b/src/SIL.Machine/Corpora/UsfmTokenizer.cs @@ -10,7 +10,7 @@ public enum RtlReferenceOrder { NotSet, BookChapterVerse, - BookVerseChapter + BookVerseChapter, } public class UsfmTokenizer @@ -78,7 +78,7 @@ public IReadOnlyList Tokenize(string usfm, bool preserveWhitespace = new UsfmToken(UsfmTokenType.Text, null, text, null) { LineNumber = lineNum, - ColumnNumber = colNum + ColumnNumber = colNum, } ); } @@ -179,7 +179,7 @@ public IReadOnlyList Tokenize(string usfm, bool preserveWhitespace = ) { LineNumber = lineNum, - ColumnNumber = colNum + ColumnNumber = colNum, } ); } @@ -189,7 +189,7 @@ public IReadOnlyList Tokenize(string usfm, bool preserveWhitespace = new UsfmToken(UsfmTokenType.Character, marker, null, endMarker) { LineNumber = lineNum, - ColumnNumber = colNum + ColumnNumber = colNum, } ); } @@ -208,7 +208,7 @@ public IReadOnlyList Tokenize(string usfm, bool preserveWhitespace = ) { LineNumber = lineNum, - ColumnNumber = colNum + ColumnNumber = colNum, } ); } @@ -224,7 +224,7 @@ public IReadOnlyList Tokenize(string usfm, bool preserveWhitespace = ) { LineNumber = lineNum, - ColumnNumber = colNum + ColumnNumber = colNum, } ); } @@ -234,7 +234,7 @@ public IReadOnlyList Tokenize(string usfm, bool preserveWhitespace = new UsfmToken(UsfmTokenType.Paragraph, marker, null, endMarker) { LineNumber = lineNum, - ColumnNumber = colNum + ColumnNumber = colNum, } ); } @@ -251,7 +251,7 @@ public IReadOnlyList Tokenize(string usfm, bool preserveWhitespace = ) { LineNumber = lineNum, - ColumnNumber = colNum + ColumnNumber = colNum, } ); break; @@ -260,7 +260,7 @@ public IReadOnlyList Tokenize(string usfm, bool preserveWhitespace = new UsfmToken(UsfmTokenType.End, marker, null, null) { LineNumber = lineNum, - ColumnNumber = colNum + ColumnNumber = colNum, } ); break; @@ -272,7 +272,7 @@ public IReadOnlyList Tokenize(string usfm, bool preserveWhitespace = new UsfmToken(UsfmTokenType.End, marker, null, null) { LineNumber = lineNum, - ColumnNumber = colNum + ColumnNumber = colNum, } ); } @@ -286,7 +286,7 @@ public IReadOnlyList Tokenize(string usfm, bool preserveWhitespace = new UsfmToken(UsfmTokenType.Paragraph, marker, null, endMarker) { LineNumber = lineNum, - ColumnNumber = colNum + ColumnNumber = colNum, } ); break; @@ -296,7 +296,7 @@ public IReadOnlyList Tokenize(string usfm, bool preserveWhitespace = new UsfmToken(UsfmTokenType.Unknown, marker, null, marker + "*") { LineNumber = lineNum, - ColumnNumber = colNum + ColumnNumber = colNum, } ); } @@ -319,7 +319,7 @@ public IReadOnlyList Tokenize(string usfm, bool preserveWhitespace = new UsfmToken(UsfmTokenType.Text, null, @"\" + marker + milestoneText, null) { LineNumber = lineNum, - ColumnNumber = colNum + ColumnNumber = colNum, } ); index = endOfText; @@ -330,7 +330,7 @@ public IReadOnlyList Tokenize(string usfm, bool preserveWhitespace = new UsfmToken(UsfmTokenType.Milestone, marker, null, endMarker) { LineNumber = lineNum, - ColumnNumber = colNum + ColumnNumber = colNum, } ); } @@ -340,7 +340,7 @@ public IReadOnlyList Tokenize(string usfm, bool preserveWhitespace = new UsfmToken(UsfmTokenType.MilestoneEnd, marker, null, null) { LineNumber = lineNum, - ColumnNumber = colNum + ColumnNumber = colNum, } ); } @@ -400,7 +400,7 @@ public IReadOnlyList Tokenize(string usfm, bool preserveWhitespace = new UsfmToken(UsfmTokenType.Text, null, " ", null) { LineNumber = lineNum, - ColumnNumber = colNum + ColumnNumber = colNum, } ); i++; @@ -655,7 +655,7 @@ int columnNumber ) { LineNumber = lineNumber, - ColumnNumber = columnNumber + attributeIndex + ColumnNumber = columnNumber + attributeIndex, }; attributeToken.CopyAttributes(matchingToken); } diff --git a/src/SIL.Machine/Corpora/UsfmUpdateBlockElement.cs b/src/SIL.Machine/Corpora/UsfmUpdateBlockElement.cs index a407af348..953b03677 100644 --- a/src/SIL.Machine/Corpora/UsfmUpdateBlockElement.cs +++ b/src/SIL.Machine/Corpora/UsfmUpdateBlockElement.cs @@ -8,7 +8,7 @@ public enum UsfmUpdateBlockElementType Paragraph, Embed, Style, - Other + Other, } public class UsfmUpdateBlockElement diff --git a/src/SIL.Machine/Corpora/UsfmVersificationErrorDetector.cs b/src/SIL.Machine/Corpora/UsfmVersificationErrorDetector.cs index 1cd72f488..f12e15cc3 100644 --- a/src/SIL.Machine/Corpora/UsfmVersificationErrorDetector.cs +++ b/src/SIL.Machine/Corpora/UsfmVersificationErrorDetector.cs @@ -14,7 +14,7 @@ public enum UsfmVersificationErrorType MissingVerseSegment, ExtraVerseSegment, InvalidChapterNumber, - InvalidVerseNumber + InvalidVerseNumber, } public class UsfmVersificationError diff --git a/src/SIL.Machine/DataStructures/Direction.cs b/src/SIL.Machine/DataStructures/Direction.cs index 7413ee4a1..37a03a0cd 100644 --- a/src/SIL.Machine/DataStructures/Direction.cs +++ b/src/SIL.Machine/DataStructures/Direction.cs @@ -3,6 +3,6 @@ namespace SIL.Machine.DataStructures public enum Direction { LeftToRight, - RightToLeft + RightToLeft, }; } diff --git a/src/SIL.Machine/FiniteState/Arc.cs b/src/SIL.Machine/FiniteState/Arc.cs index 1b632f6b5..188d48e2c 100644 --- a/src/SIL.Machine/FiniteState/Arc.cs +++ b/src/SIL.Machine/FiniteState/Arc.cs @@ -12,7 +12,7 @@ public enum ArcPriorityType High = 0, Medium, Low, - VeryLow + VeryLow, } public class Arc diff --git a/src/SIL.Machine/FiniteState/Fst.cs b/src/SIL.Machine/FiniteState/Fst.cs index f56d8f86d..04fb681c4 100644 --- a/src/SIL.Machine/FiniteState/Fst.cs +++ b/src/SIL.Machine/FiniteState/Fst.cs @@ -609,7 +609,7 @@ private static IEnumerable< Tuple, IEnumerable> > { - Tuple.Create((FeatureStruct)null, Enumerable.Empty(), Enumerable.Empty()) + Tuple.Create((FeatureStruct)null, Enumerable.Empty(), Enumerable.Empty()), }; foreach (IGrouping cond in conditions) { @@ -832,7 +832,7 @@ bool deterministic _nextTag = _nextTag, Direction = _dir, Filter = _filter, - UseUnification = _unification + UseUnification = _unification, }; foreach (KeyValuePair kvp in _groups) newFst._groups[kvp.Key] = kvp.Value; @@ -1332,7 +1332,7 @@ private Fst ExtractTransducer(State startState, { Direction = _dir, Filter = _filter, - UseUnification = _unification + UseUnification = _unification, }; fst.StartState = startState.IsAccepting ? fst.CreateAcceptingState(startState.AcceptInfos) @@ -1442,7 +1442,7 @@ public Fst GetOutputAcceptor() _registerCount = _registerCount, Direction = _dir, Filter = _filter, - UseUnification = _unification + UseUnification = _unification, }; foreach (KeyValuePair kvp in _groups) fst._groups[kvp.Key] = kvp.Value; @@ -1486,7 +1486,7 @@ public Fst GetInputAcceptor() _registerCount = _registerCount, Direction = _dir, Filter = _filter, - UseUnification = _unification + UseUnification = _unification, }; foreach (KeyValuePair kvp in _groups) fst._groups[kvp.Key] = kvp.Value; @@ -1527,7 +1527,7 @@ public bool IsEquivalentTo(Fst otherFst) var sets = new List>> { - new HashSet> { StartState, otherFst.StartState } + new HashSet> { StartState, otherFst.StartState }, }; var stack = new Stack, State>>(); @@ -1772,7 +1772,7 @@ public Fst Intersect(Fst other) { Direction = _dir, Filter = _filter, - UseUnification = _unification + UseUnification = _unification, }; newFst.StartState = StartState.IsAccepting && other.StartState.IsAccepting @@ -1890,7 +1890,7 @@ public Fst Compose(Fst other) { Direction = _dir, Filter = _filter, - UseUnification = _unification + UseUnification = _unification, }; newFst.StartState = StartState.IsAccepting && other.StartState.IsAccepting @@ -2065,11 +2065,9 @@ public void ToGraphViz(TextWriter writer) " {0} [shape=\"{1}\", color=\"{2}\"", state.Index, state.Equals(StartState) ? "diamond" : "circle", - state.Equals(StartState) - ? "green" - : state.IsAccepting - ? "red" - : "black" + state.Equals(StartState) ? "green" + : state.IsAccepting ? "red" + : "black" ); if (state.IsAccepting) writer.Write(", peripheries=\"2\""); diff --git a/src/SIL.Machine/Matching/Matcher.cs b/src/SIL.Machine/Matching/Matcher.cs index ebc24b0e9..9d73cfe4e 100644 --- a/src/SIL.Machine/Matching/Matcher.cs +++ b/src/SIL.Machine/Matching/Matcher.cs @@ -65,7 +65,7 @@ private void Compile(Pattern pattern) { Direction = _settings.Direction, Filter = _settings.Filter, - UseUnification = _settings.MatchingMethod == MatchingMethod.Unification + UseUnification = _settings.MatchingMethod == MatchingMethod.Unification, }; _fsa.StartState = _fsa.CreateState(); int nextPriority = 0; diff --git a/src/SIL.Machine/Matching/MatcherSettings.cs b/src/SIL.Machine/Matching/MatcherSettings.cs index f2f866011..7a6089e25 100644 --- a/src/SIL.Machine/Matching/MatcherSettings.cs +++ b/src/SIL.Machine/Matching/MatcherSettings.cs @@ -8,7 +8,7 @@ namespace SIL.Machine.Matching public enum MatchingMethod { Subsumption, - Unification + Unification, } public sealed class MatcherSettings diff --git a/src/SIL.Machine/Matching/Quantifier.cs b/src/SIL.Machine/Matching/Quantifier.cs index f154c7120..8f3e9ded7 100644 --- a/src/SIL.Machine/Matching/Quantifier.cs +++ b/src/SIL.Machine/Matching/Quantifier.cs @@ -36,7 +36,6 @@ public Quantifier(int minOccur, int maxOccur) /// /// The minimum number of occurrences. /// The maximum number of occurrences. - /// The pattern node. public Quantifier(int minOccur, int maxOccur, PatternNode node) : base(node == null ? Enumerable.Empty>() : node.ToEnumerable()) diff --git a/src/SIL.Machine/Morphology/Affix.cs b/src/SIL.Machine/Morphology/Affix.cs index 390b42019..3b1eb7c5c 100644 --- a/src/SIL.Machine/Morphology/Affix.cs +++ b/src/SIL.Machine/Morphology/Affix.cs @@ -5,7 +5,7 @@ namespace SIL.Machine.Morphology public enum AffixType { Prefix, - Suffix + Suffix, } public class Affix diff --git a/src/SIL.Machine/Morphology/IMorpheme.cs b/src/SIL.Machine/Morphology/IMorpheme.cs index 0511e0e6a..0190b7287 100644 --- a/src/SIL.Machine/Morphology/IMorpheme.cs +++ b/src/SIL.Machine/Morphology/IMorpheme.cs @@ -3,7 +3,7 @@ public enum MorphemeType { Stem, - Affix + Affix, } /// diff --git a/src/SIL.Machine/Morphology/PoorMansStemmingAlgorithmBase.cs b/src/SIL.Machine/Morphology/PoorMansStemmingAlgorithmBase.cs index 688d5a2ad..a0c9745f8 100644 --- a/src/SIL.Machine/Morphology/PoorMansStemmingAlgorithmBase.cs +++ b/src/SIL.Machine/Morphology/PoorMansStemmingAlgorithmBase.cs @@ -136,7 +136,7 @@ protected IEnumerable ComputeAffixes(ICollection sequences, Aff .ObservedSamples.Select(item => new { Item = item, - Curve = (double)affixFreqDist[affix.Ngram.Length + 1][affix.Ngram.Concat(item, dir)] / freq + Curve = (double)affixFreqDist[affix.Ngram.Length + 1][affix.Ngram.Concat(item, dir)] / freq, }) .MaxBy(item => item.Curve); double curveDrop = (1 - maxCurveItem.Curve) / (1 - itemProbDist[maxCurveItem.Item]); diff --git a/src/SIL.Machine/Optimization/MinimizationResult.cs b/src/SIL.Machine/Optimization/MinimizationResult.cs index 00f765981..acf445e0d 100644 --- a/src/SIL.Machine/Optimization/MinimizationResult.cs +++ b/src/SIL.Machine/Optimization/MinimizationResult.cs @@ -4,7 +4,7 @@ public enum MinimizationExitCondition { None, Converged, - MaxFunctionEvaluations + MaxFunctionEvaluations, } public class MinimizationResult diff --git a/src/SIL.Machine/PunctuationAnalysis/DepthBasedQuotationMarkResolver.cs b/src/SIL.Machine/PunctuationAnalysis/DepthBasedQuotationMarkResolver.cs index e48e6a7e1..0149575a5 100644 --- a/src/SIL.Machine/PunctuationAnalysis/DepthBasedQuotationMarkResolver.cs +++ b/src/SIL.Machine/PunctuationAnalysis/DepthBasedQuotationMarkResolver.cs @@ -79,7 +79,7 @@ public enum QuoteContinuerStyle { Undetermined, English, - Spanish + Spanish, } public class QuoteContinuerState diff --git a/src/SIL.Machine/PunctuationAnalysis/QuotationMarkDirection.cs b/src/SIL.Machine/PunctuationAnalysis/QuotationMarkDirection.cs index 52d63b333..824ad853f 100644 --- a/src/SIL.Machine/PunctuationAnalysis/QuotationMarkDirection.cs +++ b/src/SIL.Machine/PunctuationAnalysis/QuotationMarkDirection.cs @@ -3,6 +3,6 @@ namespace SIL.Machine.PunctuationAnalysis public enum QuotationMarkDirection { Opening, - Closing + Closing, } } diff --git a/src/SIL.Machine/PunctuationAnalysis/QuotationMarkResolutionIssue.cs b/src/SIL.Machine/PunctuationAnalysis/QuotationMarkResolutionIssue.cs index 233dc45c7..d9b065976 100644 --- a/src/SIL.Machine/PunctuationAnalysis/QuotationMarkResolutionIssue.cs +++ b/src/SIL.Machine/PunctuationAnalysis/QuotationMarkResolutionIssue.cs @@ -6,6 +6,6 @@ public enum QuotationMarkResolutionIssue TooDeepNesting, IncompatibleQuotationMark, AmbiguousQuotationMark, - UnexpectedQuotationMark + UnexpectedQuotationMark, } } diff --git a/src/SIL.Machine/PunctuationAnalysis/QuotationMarkUpdateStrategy.cs b/src/SIL.Machine/PunctuationAnalysis/QuotationMarkUpdateStrategy.cs index ae62e2304..21d386426 100644 --- a/src/SIL.Machine/PunctuationAnalysis/QuotationMarkUpdateStrategy.cs +++ b/src/SIL.Machine/PunctuationAnalysis/QuotationMarkUpdateStrategy.cs @@ -4,6 +4,6 @@ public enum QuotationMarkUpdateStrategy { ApplyFull, ApplyFallback, - Skip + Skip, } } diff --git a/src/SIL.Machine/PunctuationAnalysis/QuoteConvention.cs b/src/SIL.Machine/PunctuationAnalysis/QuoteConvention.cs index 756d1efb2..7c9137efa 100644 --- a/src/SIL.Machine/PunctuationAnalysis/QuoteConvention.cs +++ b/src/SIL.Machine/PunctuationAnalysis/QuoteConvention.cs @@ -18,7 +18,7 @@ public class SingleLevelQuoteConvention { "\u300a", '"' }, { "\u300b", '"' }, { "\u300c", '"' }, - { "\u300d", '"' } + { "\u300d", '"' }, }; public string OpeningQuotationMark { get; } public string ClosingQuotationMark { get; } diff --git a/src/SIL.Machine/Rules/BatchPatternRuleSpec.cs b/src/SIL.Machine/Rules/BatchPatternRuleSpec.cs index 817bef5ad..614a1cff2 100644 --- a/src/SIL.Machine/Rules/BatchPatternRuleSpec.cs +++ b/src/SIL.Machine/Rules/BatchPatternRuleSpec.cs @@ -62,7 +62,7 @@ Pattern node in startNode _ruleIds[id] = ruleSpec; var subpattern = new Pattern(id, ruleSpec.Pattern.Children.CloneItems()) { - Acceptable = match => ruleSpec.IsApplicable(match.Input) && ruleSpec.Pattern.Acceptable(match) + Acceptable = match => ruleSpec.IsApplicable(match.Input) && ruleSpec.Pattern.Acceptable(match), }; startNode.AddAfter(subpattern); startNode = subpattern; diff --git a/src/SIL.Machine/SIL.Machine.csproj b/src/SIL.Machine/SIL.Machine.csproj index 0307d3749..6b308db18 100644 --- a/src/SIL.Machine/SIL.Machine.csproj +++ b/src/SIL.Machine/SIL.Machine.csproj @@ -36,13 +36,13 @@ - + - + - - - + + + diff --git a/src/SIL.Machine/SequenceAlignment/PairwiseAlignmentAlgorithm.cs b/src/SIL.Machine/SequenceAlignment/PairwiseAlignmentAlgorithm.cs index c7907808b..07a6ceeb4 100644 --- a/src/SIL.Machine/SequenceAlignment/PairwiseAlignmentAlgorithm.cs +++ b/src/SIL.Machine/SequenceAlignment/PairwiseAlignmentAlgorithm.cs @@ -9,7 +9,7 @@ public enum AlignmentMode Global = 0, SemiGlobal, HalfLocal, - Local + Local, } public delegate IEnumerable ItemsSelector( @@ -172,7 +172,6 @@ private IEnumerable> GetAlignments(int threshold) switch (Mode) { case AlignmentMode.Global: - { foreach ( Alignment alignment in GetAlignments( @@ -188,7 +187,6 @@ Alignment alignment in GetAlignments( break; case AlignmentMode.SemiGlobal: - { if (_sim.GetLength(0) == 1 && _sim.GetLength(1) == 1) { @@ -230,7 +228,6 @@ Alignment alignment in GetAlignments( case AlignmentMode.Local: case AlignmentMode.HalfLocal: - { if (_sim.GetLength(0) == 1 && _sim.GetLength(1) == 1) { diff --git a/src/SIL.Machine/Tokenization/LatinWordDetokenizer.cs b/src/SIL.Machine/Tokenization/LatinWordDetokenizer.cs index 51710aa59..20371e4a0 100644 --- a/src/SIL.Machine/Tokenization/LatinWordDetokenizer.cs +++ b/src/SIL.Machine/Tokenization/LatinWordDetokenizer.cs @@ -11,7 +11,7 @@ private enum QuoteType DoubleQuotation, SingleQuotation, DoubleAngle, - SingleAngle + SingleAngle, } private static readonly Dictionary QuotationMarks = new Dictionary @@ -29,7 +29,7 @@ private enum QuoteType { '«', QuoteType.DoubleAngle }, { '»', QuoteType.DoubleAngle }, { '‹', QuoteType.SingleAngle }, - { '›', QuoteType.SingleAngle } + { '›', QuoteType.SingleAngle }, }; protected override object CreateContext() diff --git a/src/SIL.Machine/Tokenization/StringDetokenizer.cs b/src/SIL.Machine/Tokenization/StringDetokenizer.cs index ff3086fad..7cab5503a 100644 --- a/src/SIL.Machine/Tokenization/StringDetokenizer.cs +++ b/src/SIL.Machine/Tokenization/StringDetokenizer.cs @@ -9,7 +9,7 @@ public enum DetokenizeOperation NoOperation, MergeLeft, MergeRight, - MergeBoth + MergeBoth, } public abstract class StringDetokenizer : IDetokenizer diff --git a/src/SIL.Machine/Translation/EditDistanceWordAlignmentMethod.cs b/src/SIL.Machine/Translation/EditDistanceWordAlignmentMethod.cs index 7fbb97c57..082bdb1a4 100644 --- a/src/SIL.Machine/Translation/EditDistanceWordAlignmentMethod.cs +++ b/src/SIL.Machine/Translation/EditDistanceWordAlignmentMethod.cs @@ -37,7 +37,7 @@ IReadOnlyList targetSegment { Mode = AlignmentMode.Global, ExpansionCompressionEnabled = true, - TranspositionEnabled = true + TranspositionEnabled = true, }; paa.Compute(); Alignment, int> alignment = paa.GetAlignments().First(); diff --git a/src/SIL.Machine/Translation/EditOperation.cs b/src/SIL.Machine/Translation/EditOperation.cs index 7e7c3514e..6ecb36585 100644 --- a/src/SIL.Machine/Translation/EditOperation.cs +++ b/src/SIL.Machine/Translation/EditOperation.cs @@ -7,6 +7,6 @@ public enum EditOperation Insert, Delete, PrefixDelete, - Substitute + Substitute, } } diff --git a/src/SIL.Machine/Translation/ErrorCorrectionWordGraphProcessor.cs b/src/SIL.Machine/Translation/ErrorCorrectionWordGraphProcessor.cs index 8546dddcf..09080aa0f 100644 --- a/src/SIL.Machine/Translation/ErrorCorrectionWordGraphProcessor.cs +++ b/src/SIL.Machine/Translation/ErrorCorrectionWordGraphProcessor.cs @@ -224,7 +224,7 @@ public IEnumerable GetResults() { var builder = new TranslationResultBuilder(_wordGraph.SourceTokens) { - TargetDetokenizer = _targetDetokenizer + TargetDetokenizer = _targetDetokenizer, }; BuildCorrectionFromHypothesis(builder, _prevPrefix, _prevIsLastWordComplete, hypothesis); yield return builder.ToResult(); diff --git a/src/SIL.Machine/Translation/FuzzyEditDistanceWordAlignmentMethod.cs b/src/SIL.Machine/Translation/FuzzyEditDistanceWordAlignmentMethod.cs index dcb001a62..d33939024 100644 --- a/src/SIL.Machine/Translation/FuzzyEditDistanceWordAlignmentMethod.cs +++ b/src/SIL.Machine/Translation/FuzzyEditDistanceWordAlignmentMethod.cs @@ -44,7 +44,7 @@ IReadOnlyList targetSegment { Mode = AlignmentMode.Global, ExpansionCompressionEnabled = true, - TranspositionEnabled = true + TranspositionEnabled = true, }; paa.Compute(); Alignment, int> alignment = paa.GetAlignments().First(); diff --git a/src/SIL.Machine/Translation/SymmetrizationHeuristic.cs b/src/SIL.Machine/Translation/SymmetrizationHeuristic.cs index e18b96111..03af3c2e4 100644 --- a/src/SIL.Machine/Translation/SymmetrizationHeuristic.cs +++ b/src/SIL.Machine/Translation/SymmetrizationHeuristic.cs @@ -37,6 +37,6 @@ public enum SymmetrizationHeuristic /// /// "diag-and" method in "Statistical Phrase-Based Translation" (Koehn et al., 2003). /// - GrowDiagFinalAnd + GrowDiagFinalAnd, } } diff --git a/src/SIL.Machine/Translation/TranslationSources.cs b/src/SIL.Machine/Translation/TranslationSources.cs index b72974e3c..5e4831700 100644 --- a/src/SIL.Machine/Translation/TranslationSources.cs +++ b/src/SIL.Machine/Translation/TranslationSources.cs @@ -9,6 +9,6 @@ public enum TranslationSources Smt = 0x1, Transfer = 0x2, Prefix = 0x4, - Nmt = 0x8 + Nmt = 0x8, } } diff --git a/src/SIL.Machine/Translation/WordAlignmentDirection.cs b/src/SIL.Machine/Translation/WordAlignmentDirection.cs index 4a5bd01e8..6cb5c9766 100644 --- a/src/SIL.Machine/Translation/WordAlignmentDirection.cs +++ b/src/SIL.Machine/Translation/WordAlignmentDirection.cs @@ -9,6 +9,6 @@ public enum WordAlignmentDirection Inverse, // source <-> target - Symmetric + Symmetric, } } diff --git a/src/SIL.Machine/Translation/WordGraph.cs b/src/SIL.Machine/Translation/WordGraph.cs index e86f13340..bc57d8dd9 100644 --- a/src/SIL.Machine/Translation/WordGraph.cs +++ b/src/SIL.Machine/Translation/WordGraph.cs @@ -147,11 +147,9 @@ public void ToGraphViz(TextWriter writer) " {0} [shape=\"{1}\", color=\"{2}\"", i, i == 0 ? "diamond" : "circle", - i == 0 - ? "green" - : FinalStates.Contains(i) - ? "red" - : "black" + i == 0 ? "green" + : FinalStates.Contains(i) ? "red" + : "black" ); if (FinalStates.Contains(i)) writer.Write(", peripheries=\"2\""); diff --git a/src/SIL.Machine/Utils/StringExtensions.cs b/src/SIL.Machine/Utils/StringExtensions.cs index d9084b4ee..4353f60d1 100644 --- a/src/SIL.Machine/Utils/StringExtensions.cs +++ b/src/SIL.Machine/Utils/StringExtensions.cs @@ -22,7 +22,7 @@ public static class StringExtensions '\uFF01', '\uFF0E', '\uFF1F', - '\uFF61' + '\uFF61', }; private static readonly HashSet QuotationMarks = new HashSet @@ -40,7 +40,7 @@ public static class StringExtensions '«', '»', '‹', - '›' + '›', }; private static readonly HashSet DelayedSentenceStart = new HashSet(QuotationMarks) @@ -48,7 +48,7 @@ public static class StringExtensions '(', '[', '<', - '{' + '{', }; private static readonly HashSet DelayedSentenceEnd = new HashSet(QuotationMarks) @@ -56,7 +56,7 @@ public static class StringExtensions ')', ']', '>', - '}' + '}', }; public static bool IsSentenceTerminal(this char c) diff --git a/src/sentencepiece4c/CMakeLists.txt b/src/sentencepiece4c/CMakeLists.txt index 649b97ac7..a6e8dbdff 100644 --- a/src/sentencepiece4c/CMakeLists.txt +++ b/src/sentencepiece4c/CMakeLists.txt @@ -18,6 +18,8 @@ FetchContent_Declare( GIT_REPOSITORY https://github.com/google/sentencepiece.git GIT_TAG v0.1.96 ) +# Workaround: allow configuring external projects (sentencepiece) that use old cmake_minimum_required +set(CMAKE_POLICY_VERSION_MINIMUM 3.5 CACHE STRING "Allow configuring projects requiring older CMake" FORCE) FetchContent_MakeAvailable(sentencepiece) # Add source to this project's executable. diff --git a/tests/SIL.Machine.Morphology.HermitCrab.Tests/AffixTemplateTests.cs b/tests/SIL.Machine.Morphology.HermitCrab.Tests/AffixTemplateTests.cs index 493d8aae6..54786c82f 100644 --- a/tests/SIL.Machine.Morphology.HermitCrab.Tests/AffixTemplateTests.cs +++ b/tests/SIL.Machine.Morphology.HermitCrab.Tests/AffixTemplateTests.cs @@ -52,7 +52,7 @@ public void RealizationalRule() .Feature(Head) .EqualTo(head => head.Feature("tense").EqualTo("past")) .Value, - Gloss = "PAST" + Gloss = "PAST", }; edSuffix.Allomorphs.Add( @@ -61,23 +61,23 @@ public void RealizationalRule() Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value, - Pattern.New("2").Annotation(alvStop).Value + Pattern.New("2").Annotation(alvStop).Value, }, - Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new InsertSegments(Table3, "ɯd") } + Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new InsertSegments(Table3, "ɯd") }, } ); edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Annotation(voicelessCons).Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "t") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "t") }, } ); edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "d") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "d") }, } ); @@ -89,7 +89,7 @@ public void RealizationalRule() .Feature(Head) .EqualTo(head => head.Feature("pers").EqualTo("3").Feature("tense").EqualTo("pres")) .Value, - Gloss = "3SG" + Gloss = "3SG", }; sSuffix.Allomorphs.Add( @@ -98,16 +98,16 @@ public void RealizationalRule() Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value, - Pattern.New("2").Annotation(labiodental).Value + Pattern.New("2").Annotation(labiodental).Value, }, - Rhs = { new CopyFromInput("1"), new ModifyFromInput("2", voiced), new InsertSegments(Table3, "z") } + Rhs = { new CopyFromInput("1"), new ModifyFromInput("2", voiced), new InsertSegments(Table3, "z") }, } ); sSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Annotation(strident).Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "ɯz") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "ɯz") }, } ); sSuffix.Allomorphs.Add( @@ -116,16 +116,16 @@ public void RealizationalRule() Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value, - Pattern.New("2").Annotation(voicelessCons).Value + Pattern.New("2").Annotation(voicelessCons).Value, }, - Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new InsertSegments(Table3, "s") } + Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new InsertSegments(Table3, "s") }, } ); sSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "z") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "z") }, } ); @@ -137,21 +137,21 @@ public void RealizationalRule() .Feature(Head) .EqualTo(head => head.Feature("evidential").EqualTo("witnessed")) .Value, - Gloss = "WIT" + Gloss = "WIT", }; evidential.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "v") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "v") }, } ); var verbTemplate = new AffixTemplate { Name = "verb", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, }; verbTemplate.Slots.Add(new AffixTemplateSlot(sSuffix, edSuffix) { Optional = true }); verbTemplate.Slots.Add(new AffixTemplateSlot(evidential) { Optional = true }); @@ -239,37 +239,37 @@ public void NonFinalTemplate() .Symbol("vd-") .Value; - var edSuffix = new AffixProcessRule { Name = "ed_suffix", Gloss = "PAST", }; + var edSuffix = new AffixProcessRule { Name = "ed_suffix", Gloss = "PAST" }; edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value, - Pattern.New("2").Annotation(alvStop).Value + Pattern.New("2").Annotation(alvStop).Value, }, - Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new InsertSegments(Table3, "ɯd") } + Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new InsertSegments(Table3, "ɯd") }, } ); edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Annotation(voicelessCons).Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "t") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "t") }, } ); edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "d") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "d") }, } ); var verbTemplate = new AffixTemplate { Name = "verb", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, }; verbTemplate.Slots.Add(new AffixTemplateSlot(edSuffix)); Morphophonemic.AffixTemplates.Add(verbTemplate); @@ -279,13 +279,13 @@ public void NonFinalTemplate() Name = "nominalizer", Gloss = "NOM", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, - OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value + OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value, }; nominalizer.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "v") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "v") }, } ); Morphophonemic.MorphologicalRules.Add(nominalizer); @@ -298,14 +298,14 @@ public void NonFinalTemplate() .New(Language.SyntacticFeatureSystem) .Symbol("N") .Value, - OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value + OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value, }; crule.Subrules.Add( new CompoundingSubrule { HeadLhs = { Pattern.New("head").Annotation(any).OneOrMore.Value }, NonHeadLhs = { Pattern.New("nonHead").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("head"), new InsertSegments(Table3, "+"), new CopyFromInput("nonHead") } + Rhs = { new CopyFromInput("head"), new InsertSegments(Table3, "+"), new CopyFromInput("nonHead") }, } ); Morphophonemic.MorphologicalRules.Add(crule); @@ -320,14 +320,14 @@ public void NonFinalTemplate() new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") }, } ); var nounTemplate = new AffixTemplate { Name = "noun", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value, }; nounTemplate.Slots.Add(new AffixTemplateSlot(sSuffix) { Optional = true }); Morphophonemic.AffixTemplates.Add(nounTemplate); @@ -357,14 +357,14 @@ public void AffixTemplateAppliedAfterMorphologicalRule() Name = "nominalizer", Gloss = "NOM", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, - OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value + OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value, }; nominalizer.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "v") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "v") }, } ); Morphophonemic.MorphologicalRules.Add(nominalizer); @@ -380,14 +380,14 @@ public void AffixTemplateAppliedAfterMorphologicalRule() new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") }, } ); var nounTemplate = new AffixTemplate { Name = "noun", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value, }; nounTemplate.Slots.Add(new AffixTemplateSlot(sSuffix) { Optional = true }); Morphophonemic.AffixTemplates.Add(nounTemplate); @@ -416,14 +416,14 @@ public void SameRuleUsedInMultipleTemplates() new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "d") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "d") }, } ); var transitiveVerbTemplate = new AffixTemplate { Name = "Transitive Verb", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("TV").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("TV").Value, }; transitiveVerbTemplate.Slots.Add(new AffixTemplateSlot(edSuffix)); Morphophonemic.AffixTemplates.Add(transitiveVerbTemplate); @@ -431,7 +431,7 @@ public void SameRuleUsedInMultipleTemplates() var intransitiveVerbTemplate = new AffixTemplate { Name = "Intransitive Verb", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("IV").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("IV").Value, }; intransitiveVerbTemplate.Slots.Add(new AffixTemplateSlot(edSuffix)); Morphophonemic.AffixTemplates.Add(intransitiveVerbTemplate); @@ -441,14 +441,14 @@ public void SameRuleUsedInMultipleTemplates() Name = "intransitive verbalizer", Gloss = "IVERB", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value, - OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("IV").Value + OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("IV").Value, }; nominalizer.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "v") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "v") }, } ); Morphophonemic.MorphologicalRules.Add(nominalizer); diff --git a/tests/SIL.Machine.Morphology.HermitCrab.Tests/HermitCrabTestBase.cs b/tests/SIL.Machine.Morphology.HermitCrab.Tests/HermitCrabTestBase.cs index a7736f41a..2d1afc619 100644 --- a/tests/SIL.Machine.Morphology.HermitCrab.Tests/HermitCrabTestBase.cs +++ b/tests/SIL.Machine.Morphology.HermitCrab.Tests/HermitCrabTestBase.cs @@ -51,7 +51,7 @@ public void FixtureSetUp() new FeatureSymbol("labiodental"), new FeatureSymbol("alveolar"), new FeatureSymbol("velar") - ) + ), }; phonologicalFeatSys.Freeze(); @@ -72,7 +72,7 @@ public void FixtureSetUp() new SymbolicFeature("aspect", new FeatureSymbol("perf"), new FeatureSymbol("impf")), new SymbolicFeature("mood", new FeatureSymbol("active"), new FeatureSymbol("passive")), new SymbolicFeature("fum", new FeatureSymbol("fum+", "+"), new FeatureSymbol("fum-", "-")), - new SymbolicFeature("bar", new FeatureSymbol("bar+", "+"), new FeatureSymbol("bar-", "-")) + new SymbolicFeature("bar", new FeatureSymbol("bar+", "+"), new FeatureSymbol("bar-", "-")), }; syntacticFeatSys.AddPartsOfSpeech( new FeatureSymbol("N", "Noun"), @@ -518,12 +518,12 @@ public void FixtureSetUp() Morphophonemic = new Stratum(Table3) { Name = "Morphophonemic", - MorphologicalRuleOrder = MorphologicalRuleOrder.Unordered + MorphologicalRuleOrder = MorphologicalRuleOrder.Unordered, }; Allophonic = new Stratum(Table1) { Name = "Allophonic", - MorphologicalRuleOrder = MorphologicalRuleOrder.Unordered + MorphologicalRuleOrder = MorphologicalRuleOrder.Unordered, }; Surface = new Stratum(Table1) { Name = "Surface", MorphologicalRuleOrder = MorphologicalRuleOrder.Unordered }; @@ -760,7 +760,7 @@ public void FixtureSetUp() .Value ) { - Name = "sn1" + Name = "sn1", }; entry.Allomorphs[2].StemName = new StemName( FeatureStruct @@ -777,7 +777,7 @@ public void FixtureSetUp() .Value ) { - Name = "sn2" + Name = "sn2", }; AddEntry( @@ -800,7 +800,7 @@ public void FixtureSetUp() Name = "Test", PhonologicalFeatureSystem = phonologicalFeatSys, SyntacticFeatureSystem = syntacticFeatSys, - Strata = { Morphophonemic, Allophonic, Surface } + Strata = { Morphophonemic, Allophonic, Surface }, }; } @@ -831,7 +831,7 @@ public LexEntry AddEntry(string gloss, FeatureStruct syntacticFS, Stratum stratu Id = gloss, SyntacticFeatureStruct = syntacticFS, Gloss = gloss, - IsPartial = syntacticFS.IsEmpty + IsPartial = syntacticFS.IsEmpty, }; foreach (string form in forms) entry.Allomorphs.Add(new RootAllomorph(new Segments(stratum.CharacterDefinitionTable, form, true))); diff --git a/tests/SIL.Machine.Morphology.HermitCrab.Tests/LexEntryTests.cs b/tests/SIL.Machine.Morphology.HermitCrab.Tests/LexEntryTests.cs index 853740885..191a6b5ed 100644 --- a/tests/SIL.Machine.Morphology.HermitCrab.Tests/LexEntryTests.cs +++ b/tests/SIL.Machine.Morphology.HermitCrab.Tests/LexEntryTests.cs @@ -19,13 +19,13 @@ public void DisjunctiveAllomorphs() { Name = "ed_suffix", Gloss = "PAST", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, }; edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+ɯd") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+ɯd") }, } ); Morphophonemic.MorphologicalRules.Add(edSuffix); @@ -57,20 +57,20 @@ public void FreeFluctuation() { Name = "ed_suffix", Gloss = "PAST", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, }; edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+t") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+t") }, } ); edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+"), new InsertSimpleContext(d) } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+"), new InsertSimpleContext(d) }, } ); Morphophonemic.MorphologicalRules.Add(edSuffix); @@ -96,13 +96,13 @@ public void StemNames() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("pers").EqualTo("1")) - .Value + .Value, }; edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+ɯd") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+ɯd") }, } ); Morphophonemic.MorphologicalRules.Add(edSuffix); @@ -116,13 +116,13 @@ public void StemNames() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("pers").EqualTo("2")) - .Value + .Value, }; tSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+t") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+t") }, } ); Morphophonemic.MorphologicalRules.Add(tSuffix); @@ -136,13 +136,13 @@ public void StemNames() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("pers").EqualTo("3")) - .Value + .Value, }; sSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+s") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+s") }, } ); Morphophonemic.MorphologicalRules.Add(sSuffix); @@ -174,14 +174,14 @@ public void BoundRootAllomorph() { Name = "ed_suffix", Gloss = "PAST", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, }; Morphophonemic.MorphologicalRules.Add(edSuffix); edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+ɯd") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+ɯd") }, } ); @@ -271,13 +271,13 @@ public void PartialEntry() Name = "nominalizer", Gloss = "NOM", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, - OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value + OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value, }; nominalizer.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "v") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "v") }, } ); Morphophonemic.MorphologicalRules.Add(nominalizer); @@ -298,14 +298,14 @@ public void PartialEntry() new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") }, } ); var verbTemplate = new AffixTemplate { Name = "verb", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, }; verbTemplate.Slots.Add(new AffixTemplateSlot(sSuffix) { Optional = true }); Morphophonemic.AffixTemplates.Add(verbTemplate); diff --git a/tests/SIL.Machine.Morphology.HermitCrab.Tests/MorpherTests.cs b/tests/SIL.Machine.Morphology.HermitCrab.Tests/MorpherTests.cs index 709b5bb02..eb8944ad0 100644 --- a/tests/SIL.Machine.Morphology.HermitCrab.Tests/MorpherTests.cs +++ b/tests/SIL.Machine.Morphology.HermitCrab.Tests/MorpherTests.cs @@ -20,13 +20,13 @@ public void AnalyzeWord_CanAnalyze_ReturnsCorrectAnalysis() Id = "PAST", Name = "ed_suffix", Gloss = "PAST", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, }; edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+d") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+d") }, } ); Morphophonemic.MorphologicalRules.Add(edSuffix); @@ -49,13 +49,13 @@ public void AnalyzeWord_CanAnalyzeLinear_ReturnsCorrectAnalysis() Id = "PAST", Name = "ed_suffix", Gloss = "PAST", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, }; edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+d") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+d") }, } ); Morphophonemic.MorphologicalRules.Add(edSuffix); @@ -66,13 +66,13 @@ public void AnalyzeWord_CanAnalyzeLinear_ReturnsCorrectAnalysis() Id = "PLURAL", Name = "t_suffix", Gloss = "PLURAL", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value, }; tSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+t") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+t") }, } ); Morphophonemic.MorphologicalRules.Add(tSuffix); @@ -82,7 +82,7 @@ public void AnalyzeWord_CanAnalyzeLinear_ReturnsCorrectAnalysis() var rule1 = new RewriteRule { Name = "rule1", - Lhs = Pattern.New().Annotation(Character(Table1, "t")).Value + Lhs = Pattern.New().Annotation(Character(Table1, "t")).Value, }; rule1.Subrules.Add( new RewriteSubrule { Rhs = Pattern.New().Annotation(Character(Table1, "d")).Value } @@ -108,13 +108,13 @@ public void AnalyzeWord_CannotAnalyze_ReturnsEmptyEnumerable() Id = "PAST", Name = "ed_suffix", Gloss = "PAST", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, }; edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+d") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+d") }, } ); Morphophonemic.MorphologicalRules.Add(edSuffix); @@ -138,13 +138,13 @@ public void AnalyzeWord_CannotAnalyzeDueToAllomorphCooccurenceFailure_ReturnsEmp Id = "PAST", Name = "ed_suffix", Gloss = "PAST", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, }; edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+d") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+d") }, } ); Morphophonemic.MorphologicalRules.Add(edSuffix); @@ -197,13 +197,13 @@ public void AnalyzeWord_CannotAnalyzeDueToMorphemeCooccurenceFailure_ReturnsEmpt Id = "PAST", Name = "ed_suffix", Gloss = "PAST", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, }; edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+d") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+d") }, } ); Morphophonemic.MorphologicalRules.Add(edSuffix); @@ -248,13 +248,13 @@ public void AnalyzeWord_CanGuess_ReturnsCorrectAnalysis() Id = "PAST", Name = "ed_suffix", Gloss = "PAST", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, }; edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+d") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+d") }, } ); Morphophonemic.MorphologicalRules.Add(edSuffix); @@ -283,13 +283,13 @@ public void GenerateWords_CanGenerate_ReturnsCorrectWord() Id = "3SG", Name = "si_prefix", Gloss = "3SG", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, }; siPrefix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new InsertSegments(Table3, "si+"), new CopyFromInput("1") } + Rhs = { new InsertSegments(Table3, "si+"), new CopyFromInput("1") }, } ); Morphophonemic.MorphologicalRules.Add(siPrefix); @@ -299,13 +299,13 @@ public void GenerateWords_CanGenerate_ReturnsCorrectWord() Id = "PAST", Name = "ed_suffix", Gloss = "PAST", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, }; edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+ɯd") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+ɯd") }, } ); Morphophonemic.MorphologicalRules.Add(edSuffix); @@ -328,13 +328,13 @@ public void GenerateWords_CannotGenerate_ReturnsEmptyEnumerable() Id = "PL", Name = "ed_suffix", Gloss = "PL", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value, }; edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+ɯd") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+ɯd") }, } ); Morphophonemic.MorphologicalRules.Add(edSuffix); diff --git a/tests/SIL.Machine.Morphology.HermitCrab.Tests/MorphologicalRules/AffixProcessRuleTests.cs b/tests/SIL.Machine.Morphology.HermitCrab.Tests/MorphologicalRules/AffixProcessRuleTests.cs index d222c9476..329074617 100644 --- a/tests/SIL.Machine.Morphology.HermitCrab.Tests/MorphologicalRules/AffixProcessRuleTests.cs +++ b/tests/SIL.Machine.Morphology.HermitCrab.Tests/MorphologicalRules/AffixProcessRuleTests.cs @@ -19,13 +19,13 @@ public void MorphosyntacticRules() Name = "s_suffix", Gloss = "NMLZ", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, - OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value + OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value, }; sSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") }, } ); Morphophonemic.MorphologicalRules.Add(sSuffix); @@ -90,7 +90,7 @@ public void MorphosyntacticRules() new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "d") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "d") }, } ); @@ -116,13 +116,13 @@ public void PercolationRules() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("pers").EqualTo("2")) - .Value + .Value, }; rule1.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "z") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "z") }, } ); Morphophonemic.MorphologicalRules.Add(rule1); @@ -326,27 +326,27 @@ public void SuffixRules() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("pers").EqualTo("3")) - .Value + .Value, }; sSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Annotation(strident).Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "ɯz") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "ɯz") }, } ); sSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Annotation(voicelessCons).Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") }, } ); sSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "z") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "z") }, } ); Morphophonemic.MorphologicalRules.Add(sSuffix); @@ -360,7 +360,7 @@ public void SuffixRules() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("tense").EqualTo("past")) - .Value + .Value, }; edSuffix.Allomorphs.Add( new AffixProcessAllomorph @@ -368,23 +368,23 @@ public void SuffixRules() Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value, - Pattern.New("2").Annotation(alvStop).Value + Pattern.New("2").Annotation(alvStop).Value, }, - Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new InsertSegments(Table3, "+ɯd") } + Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new InsertSegments(Table3, "+ɯd") }, } ); edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Annotation(voicelessCons).Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+t") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+t") }, } ); edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+"), new InsertSimpleContext(d) } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+"), new InsertSimpleContext(d) }, } ); Morphophonemic.MorphologicalRules.Add(edSuffix); @@ -392,13 +392,13 @@ public void SuffixRules() var prule1 = new RewriteRule { Name = "rule1", - Lhs = Pattern.New().Annotation(Character(Table3, "t")).Value + Lhs = Pattern.New().Annotation(Character(Table3, "t")).Value, }; prule1.Subrules.Add( new RewriteSubrule { Rhs = Pattern.New().Annotation(unasp).Value, - LeftEnvironment = Pattern.New().Annotation(cons).Value + LeftEnvironment = Pattern.New().Annotation(cons).Value, } ); Allophonic.PhonologicalRules.Add(prule1); @@ -455,9 +455,9 @@ public void SuffixRules() .EqualToVariable("a") .Value ) - .Value + .Value, }, - Rhs = { new CopyFromInput("1"), new InsertSimpleContext(alvStop, Variable("vd", "a")) } + Rhs = { new CopyFromInput("1"), new InsertSimpleContext(alvStop, Variable("vd", "a")) }, } ); @@ -531,27 +531,27 @@ public void PrefixRules() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("pers").EqualTo("3")) - .Value + .Value, }; sPrefix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(strident).Annotation(any).OneOrMore.Value }, - Rhs = { new InsertSegments(Table3, "zi"), new CopyFromInput("1") } + Rhs = { new InsertSegments(Table3, "zi"), new CopyFromInput("1") }, } ); sPrefix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(voicelessCons).Annotation(any).OneOrMore.Value }, - Rhs = { new InsertSegments(Table3, "s"), new CopyFromInput("1") } + Rhs = { new InsertSegments(Table3, "s"), new CopyFromInput("1") }, } ); sPrefix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new InsertSegments(Table3, "z"), new CopyFromInput("1") } + Rhs = { new InsertSegments(Table3, "z"), new CopyFromInput("1") }, } ); Morphophonemic.MorphologicalRules.Add(sPrefix); @@ -565,27 +565,27 @@ public void PrefixRules() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("tense").EqualTo("past")) - .Value + .Value, }; edPrefix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(alvStop).Annotation(any).OneOrMore.Value }, - Rhs = { new InsertSegments(Table3, "di+"), new CopyFromInput("1") } + Rhs = { new InsertSegments(Table3, "di+"), new CopyFromInput("1") }, } ); edPrefix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(voicelessCons).Annotation(any).OneOrMore.Value }, - Rhs = { new InsertSegments(Table3, "t+"), new CopyFromInput("1") } + Rhs = { new InsertSegments(Table3, "t+"), new CopyFromInput("1") }, } ); edPrefix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new InsertSegments(Table3, "d+"), new CopyFromInput("1") } + Rhs = { new InsertSegments(Table3, "d+"), new CopyFromInput("1") }, } ); Morphophonemic.MorphologicalRules.Add(edPrefix); @@ -593,9 +593,9 @@ public void PrefixRules() var aspiration = new RewriteRule { Name = "aspiration", - Lhs = Pattern.New().Annotation(voicelessStop).Value + Lhs = Pattern.New().Annotation(voicelessStop).Value, }; - aspiration.Subrules.Add(new RewriteSubrule { Rhs = Pattern.New().Annotation(unasp).Value, }); + aspiration.Subrules.Add(new RewriteSubrule { Rhs = Pattern.New().Annotation(unasp).Value }); Allophonic.PhonologicalRules.Add(aspiration); var morpher = new Morpher(TraceManager, Language); @@ -631,7 +631,7 @@ public void PrefixRules() .Value ) .Annotation(any) - .OneOrMore.Value + .OneOrMore.Value, }, Rhs = { @@ -642,8 +642,8 @@ public void PrefixRules() .EqualToVariable("a") .Value ), - new CopyFromInput("1") - } + new CopyFromInput("1"), + }, } ); @@ -670,7 +670,7 @@ public void PrefixRules() .Value ) .Value, - Pattern.New("3").Annotation(any).OneOrMore.Value + Pattern.New("3").Annotation(any).OneOrMore.Value, }, Rhs = { @@ -683,8 +683,8 @@ public void PrefixRules() .Value ), new CopyFromInput("1"), - new CopyFromInput("3") - } + new CopyFromInput("3"), + }, } ); @@ -721,7 +721,7 @@ public void InfixRules() .Symbol("V") .Feature(Head) .EqualTo(head => head.Feature("aspect").EqualTo("perf").Feature("mood").EqualTo("active")) - .Value + .Value, }; perfAct.Allomorphs.Add( new AffixProcessAllomorph @@ -730,7 +730,7 @@ public void InfixRules() { Pattern.New("1").Annotation(cons).Value, Pattern.New("2").Annotation(cons).Value, - Pattern.New("3").Annotation(cons).Value + Pattern.New("3").Annotation(cons).Value, }, Rhs = { @@ -738,8 +738,8 @@ public void InfixRules() new InsertSegments(Table3, "a"), new CopyFromInput("2"), new InsertSegments(Table3, "a"), - new CopyFromInput("3") - } + new CopyFromInput("3"), + }, } ); Morphophonemic.MorphologicalRules.Add(perfAct); @@ -753,7 +753,7 @@ public void InfixRules() .Symbol("V") .Feature(Head) .EqualTo(head => head.Feature("aspect").EqualTo("perf").Feature("mood").EqualTo("passive")) - .Value + .Value, }; perfPass.Allomorphs.Add( new AffixProcessAllomorph @@ -762,7 +762,7 @@ public void InfixRules() { Pattern.New("1").Annotation(cons).Value, Pattern.New("2").Annotation(cons).Value, - Pattern.New("3").Annotation(cons).Value + Pattern.New("3").Annotation(cons).Value, }, Rhs = { @@ -770,8 +770,8 @@ public void InfixRules() new InsertSegments(Table3, "u"), new CopyFromInput("2"), new InsertSegments(Table3, "i"), - new CopyFromInput("3") - } + new CopyFromInput("3"), + }, } ); Morphophonemic.MorphologicalRules.Add(perfPass); @@ -785,7 +785,7 @@ public void InfixRules() .Symbol("V") .Feature(Head) .EqualTo(head => head.Feature("aspect").EqualTo("impf").Feature("mood").EqualTo("active")) - .Value + .Value, }; imperfAct.Allomorphs.Add( new AffixProcessAllomorph @@ -793,15 +793,15 @@ public void InfixRules() Lhs = { Pattern.New("1").Annotation(cons).Annotation(cons).Value, - Pattern.New("2").Annotation(cons).Value + Pattern.New("2").Annotation(cons).Value, }, Rhs = { new InsertSegments(Table3, "a"), new CopyFromInput("1"), new InsertSegments(Table3, "u"), - new CopyFromInput("2") - } + new CopyFromInput("2"), + }, } ); Morphophonemic.MorphologicalRules.Add(imperfAct); @@ -815,7 +815,7 @@ public void InfixRules() .Symbol("V") .Feature(Head) .EqualTo(head => head.Feature("aspect").EqualTo("impf").Feature("mood").EqualTo("passive")) - .Value + .Value, }; imperfPass.Allomorphs.Add( new AffixProcessAllomorph @@ -824,7 +824,7 @@ public void InfixRules() { Pattern.New("1").Annotation(cons).Value, Pattern.New("2").Annotation(cons).Value, - Pattern.New("3").Annotation(cons).Value + Pattern.New("3").Annotation(cons).Value, }, Rhs = { @@ -832,8 +832,8 @@ public void InfixRules() new CopyFromInput("1"), new CopyFromInput("2"), new InsertSegments(Table3, "a"), - new CopyFromInput("3") - } + new CopyFromInput("3"), + }, } ); Morphophonemic.MorphologicalRules.Add(imperfPass); @@ -841,9 +841,9 @@ public void InfixRules() var aspiration = new RewriteRule { Name = "aspiration", - Lhs = Pattern.New().Annotation(voicelessStop).Value + Lhs = Pattern.New().Annotation(voicelessStop).Value, }; - aspiration.Subrules.Add(new RewriteSubrule { Rhs = Pattern.New().Annotation(unasp).Value, }); + aspiration.Subrules.Add(new RewriteSubrule { Rhs = Pattern.New().Annotation(unasp).Value }); Allophonic.PhonologicalRules.Add(aspiration); var morpher = new Morpher(TraceManager, Language); @@ -895,7 +895,7 @@ public void SimulfixRules() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("pers").EqualTo("3")) - .Value + .Value, }; simulfix.Allomorphs.Add( new AffixProcessAllomorph @@ -903,9 +903,9 @@ public void SimulfixRules() Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value, - Pattern.New("2").Annotation(p).Value + Pattern.New("2").Annotation(p).Value, }, - Rhs = { new CopyFromInput("1"), new ModifyFromInput("2", voiced) } + Rhs = { new CopyFromInput("1"), new ModifyFromInput("2", voiced) }, } ); Allophonic.MorphologicalRules.Add(simulfix); @@ -920,9 +920,9 @@ public void SimulfixRules() Lhs = { Pattern.New("1").Annotation(p).Value, - Pattern.New("2").Annotation(any).OneOrMore.Value + Pattern.New("2").Annotation(any).OneOrMore.Value, }, - Rhs = { new ModifyFromInput("1", voiced), new CopyFromInput("2") } + Rhs = { new ModifyFromInput("1", voiced), new CopyFromInput("2") }, } ); @@ -938,9 +938,9 @@ public void SimulfixRules() { Pattern.New("1").Annotation(cons).Optional.Value, Pattern.New("2").Annotation(vowel).Value, - Pattern.New("3").Annotation(any).OneOrMore.Value + Pattern.New("3").Annotation(any).OneOrMore.Value, }, - Rhs = { new CopyFromInput("1"), new ModifyFromInput("2", nonround), new CopyFromInput("3") } + Rhs = { new CopyFromInput("1"), new ModifyFromInput("2", nonround), new CopyFromInput("3") }, } ); @@ -955,9 +955,9 @@ public void SimulfixRules() { Pattern.New("1").Annotation(cons).Optional.Value, Pattern.New("2").Annotation(vowel).Range(1, 2).Value, - Pattern.New("3").Annotation(any).OneOrMore.Value + Pattern.New("3").Annotation(any).OneOrMore.Value, }, - Rhs = { new CopyFromInput("1"), new ModifyFromInput("2", nonround), new CopyFromInput("3") } + Rhs = { new CopyFromInput("1"), new ModifyFromInput("2", nonround), new CopyFromInput("3") }, } ); @@ -1000,7 +1000,7 @@ public void ReduplicationRules() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("pers").EqualTo("3")) - .Value + .Value, }; redup.Allomorphs.Add( new AffixProcessAllomorph @@ -1008,9 +1008,9 @@ public void ReduplicationRules() Lhs = { Pattern.New("1").Annotation(cons).Annotation(vowel).Value, - Pattern.New("2").Annotation(any).OneOrMore.Value + Pattern.New("2").Annotation(any).OneOrMore.Value, }, - Rhs = { new CopyFromInput("1"), new CopyFromInput("1"), new CopyFromInput("2") } + Rhs = { new CopyFromInput("1"), new CopyFromInput("1"), new CopyFromInput("2") }, } ); Morphophonemic.MorphologicalRules.Add(redup); @@ -1021,14 +1021,14 @@ public void ReduplicationRules() var voicing = new RewriteRule { Name = "voicing", - Lhs = Pattern.New().Annotation(Character(Table1, "s")).Value + Lhs = Pattern.New().Annotation(Character(Table1, "s")).Value, }; voicing.Subrules.Add( new RewriteSubrule { Rhs = Pattern.New().Annotation(voiced).Value, LeftEnvironment = Pattern.New().Annotation(vowel).Value, - RightEnvironment = Pattern.New().Annotation(vowel).Value + RightEnvironment = Pattern.New().Annotation(vowel).Value, } ); Allophonic.PhonologicalRules.Add(voicing); @@ -1039,13 +1039,13 @@ public void ReduplicationRules() var affrication = new RewriteRule { Name = "affrication", - Lhs = Pattern.New().Annotation(Character(Table1, "s")).Value + Lhs = Pattern.New().Annotation(Character(Table1, "s")).Value, }; affrication.Subrules.Add( new RewriteSubrule { Rhs = Pattern.New().Annotation(affricate).Value, - LeftEnvironment = Pattern.New().Annotation(HCFeatureSystem.LeftSideAnchor).Value + LeftEnvironment = Pattern.New().Annotation(HCFeatureSystem.LeftSideAnchor).Value, } ); Allophonic.PhonologicalRules.Add(affrication); @@ -1062,7 +1062,7 @@ public void ReduplicationRules() Pattern.New("1").Annotation(any).OneOrMore.Value, Pattern.New("2").Annotation(vowel).Annotation(cons).Value, }, - Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new CopyFromInput("2") } + Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new CopyFromInput("2") }, } ); @@ -1080,7 +1080,7 @@ public void ReduplicationRules() Pattern.New("1").Annotation(any).ZeroOrMore.Value, Pattern.New("2").Annotation(cons).Annotation(vowel).Annotation(cons).Value, }, - Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new CopyFromInput("2") } + Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new CopyFromInput("2") }, } ); @@ -1097,20 +1097,20 @@ public void ReduplicationRules() Pattern.New("1").Annotation(any).OneOrMore.Value, Pattern.New("2").Annotation(vowel).Annotation(cons).Value, }, - Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new CopyFromInput("2") } + Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new CopyFromInput("2") }, } ); var gDelete = new RewriteRule { Name = "g_delete", - Lhs = Pattern.New().Annotation(Character(Table1, "g")).Value + Lhs = Pattern.New().Annotation(Character(Table1, "g")).Value, }; gDelete.Subrules.Add( new RewriteSubrule { LeftEnvironment = Pattern.New().Annotation(vowel).Value, - RightEnvironment = Pattern.New().Annotation(vowel).Value + RightEnvironment = Pattern.New().Annotation(vowel).Value, } ); Allophonic.PhonologicalRules.Add(gDelete); @@ -1122,7 +1122,7 @@ public void ReduplicationRules() gDelete.Subrules.Add( new RewriteSubrule { - RightEnvironment = Pattern.New().Annotation(HCFeatureSystem.RightSideAnchor).Value + RightEnvironment = Pattern.New().Annotation(HCFeatureSystem.RightSideAnchor).Value, } ); @@ -1140,9 +1140,15 @@ public void ReduplicationRules() { Pattern.New("1").Annotation(cons).Value, Pattern.New("2").Annotation(vowel).Annotation(vowel).Value, - Pattern.New("3").Annotation(cons).Value + Pattern.New("3").Annotation(cons).Value, + }, + Rhs = + { + new CopyFromInput("1"), + new CopyFromInput("2"), + new CopyFromInput("2"), + new CopyFromInput("3"), }, - Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new CopyFromInput("2"), new CopyFromInput("3") } } ); @@ -1176,7 +1182,7 @@ public void TruncateRules() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("pers").EqualTo("3")) - .Value + .Value, }; truncate.Allomorphs.Add( new AffixProcessAllomorph @@ -1184,9 +1190,9 @@ public void TruncateRules() Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value, - Pattern.New("2").Annotation(Character(Table3, "g")).Value + Pattern.New("2").Annotation(Character(Table3, "g")).Value, }, - Rhs = { new CopyFromInput("1") } + Rhs = { new CopyFromInput("1") }, } ); Morphophonemic.MorphologicalRules.Add(truncate); @@ -1201,9 +1207,9 @@ public void TruncateRules() Lhs = { Pattern.New("1").Annotation(Character(Table3, "s")).Value, - Pattern.New("2").Annotation(any).OneOrMore.Value + Pattern.New("2").Annotation(any).OneOrMore.Value, }, - Rhs = { new CopyFromInput("2") } + Rhs = { new CopyFromInput("2") }, } ); @@ -1217,9 +1223,9 @@ public void TruncateRules() Lhs = { Pattern.New("1").Annotation(fricative).Value, - Pattern.New("2").Annotation(any).OneOrMore.Value + Pattern.New("2").Annotation(any).OneOrMore.Value, }, - Rhs = { new CopyFromInput("2") } + Rhs = { new CopyFromInput("2") }, } ); @@ -1233,9 +1239,9 @@ public void TruncateRules() Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value, - Pattern.New("2").Annotation(velarStop).Value + Pattern.New("2").Annotation(velarStop).Value, }, - Rhs = { new CopyFromInput("1") } + Rhs = { new CopyFromInput("1") }, } ); @@ -1249,9 +1255,9 @@ public void TruncateRules() Lhs = { Pattern.New("1").Annotation(Character(Table3, "s")).Optional.Value, - Pattern.New("2").Annotation(any).OneOrMore.Value + Pattern.New("2").Annotation(any).OneOrMore.Value, }, - Rhs = { new InsertSegments(Table3, "g"), new CopyFromInput("2") } + Rhs = { new InsertSegments(Table3, "g"), new CopyFromInput("2") }, } ); @@ -1274,7 +1280,7 @@ public void RequiredEnvironments() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("pers").EqualTo("3")) - .Value + .Value, }; sSuffix.Allomorphs.Add( new AffixProcessAllomorph @@ -1292,15 +1298,15 @@ public void RequiredEnvironments() ConstraintType.Require, null, Pattern.New().Annotation(Character(Table3, "ɯ")).Value - ) - } + ), + }, } ); sSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "z") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "z") }, } ); Morphophonemic.MorphologicalRules.Add(sSuffix); @@ -1314,13 +1320,13 @@ public void RequiredEnvironments() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("tense").EqualTo("past")) - .Value + .Value, }; edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+ɯd") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+ɯd") }, } ); Morphophonemic.MorphologicalRules.Add(edSuffix); @@ -1346,7 +1352,7 @@ public void RequiredSyntacticFeatureStruct() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("pers").EqualTo("3")) - .Value + .Value, }; sSuffix.Allomorphs.Add( new AffixProcessAllomorph @@ -1357,14 +1363,14 @@ public void RequiredSyntacticFeatureStruct() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("tense").EqualTo("past")) - .Value + .Value, } ); sSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "z") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "z") }, } ); Morphophonemic.MorphologicalRules.Add(sSuffix); @@ -1378,13 +1384,13 @@ public void RequiredSyntacticFeatureStruct() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("tense").EqualTo("past")) - .Value + .Value, }; edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+ɯd") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+ɯd") }, } ); Morphophonemic.MorphologicalRules.Add(edSuffix); @@ -1410,20 +1416,20 @@ public void FreeFluctuation() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("pers").EqualTo("3")) - .Value + .Value, }; sSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") }, } ); sSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "z") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "z") }, } ); Morphophonemic.MorphologicalRules.Add(sSuffix); @@ -1447,7 +1453,7 @@ public void CircumfixRules() new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new InsertSegments(Table3, "ta"), new CopyFromInput("1"), new InsertSegments(Table3, "od") } + Rhs = { new InsertSegments(Table3, "ta"), new CopyFromInput("1"), new InsertSegments(Table3, "od") }, } ); Morphophonemic.MorphologicalRules.Add(circumfix); @@ -1457,7 +1463,7 @@ public void CircumfixRules() new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") }, } ); Morphophonemic.MorphologicalRules.Add(sSuffix); @@ -1490,7 +1496,7 @@ public void BoundaryRules() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("pers").EqualTo("3")) - .Value + .Value, }; Morphophonemic.MorphologicalRules.Add(sSuffix); sSuffix.Allomorphs.Add( @@ -1511,9 +1517,9 @@ public void BoundaryRules() ) .Annotation(cons) .Annotation(vowel) - .Value + .Value, }, - Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new InsertSegments(Table3, "s") } + Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new InsertSegments(Table3, "s") }, } ); @@ -1540,7 +1546,7 @@ public void WordSynthesisWithBoundaryAtBeginning() { Name = "ht_suffix", Gloss = "prefix", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, }; Morphophonemic.MorphologicalRules.Add(htSuffix); htSuffix.Allomorphs.Add( @@ -1551,7 +1557,7 @@ public void WordSynthesisWithBoundaryAtBeginning() Pattern.New("1").Annotation(any).ZeroOrMore.Value, Pattern.New("2").Annotation(cons).Value, Pattern.New("3").Annotation(vowel).Value, - Pattern.New("4").Annotation(cons).Value + Pattern.New("4").Annotation(cons).Value, }, Rhs = { @@ -1560,8 +1566,8 @@ public void WordSynthesisWithBoundaryAtBeginning() new CopyFromInput("2"), new InsertSegments(Table3, "t"), new CopyFromInput("3"), - new CopyFromInput("4") - } + new CopyFromInput("4"), + }, } ); @@ -1574,14 +1580,14 @@ public void WordSynthesisWithBoundaryAtBeginning() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("tense").EqualTo("past")) - .Value + .Value, }; Morphophonemic.MorphologicalRules.Add(edSuffix); edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+ɯd") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+ɯd") }, } ); @@ -1610,7 +1616,7 @@ public void PartialRule() .Symbol("vd-") .Value; - var edSuffix = new AffixProcessRule { Name = "ed_suffix", Gloss = "TEMP_VERB", }; + var edSuffix = new AffixProcessRule { Name = "ed_suffix", Gloss = "TEMP_VERB" }; edSuffix.Allomorphs.Add( new AffixProcessAllomorph @@ -1618,30 +1624,30 @@ public void PartialRule() Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value, - Pattern.New("2").Annotation(alvStop).Value + Pattern.New("2").Annotation(alvStop).Value, }, - Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new InsertSegments(Table3, "ɯd") } + Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new InsertSegments(Table3, "ɯd") }, } ); edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Annotation(voicelessCons).Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "t") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "t") }, } ); edSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "d") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "d") }, } ); var verbTemplate = new AffixTemplate { Name = "verb", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, }; verbTemplate.Slots.Add(new AffixTemplateSlot(edSuffix) { Optional = true }); Morphophonemic.AffixTemplates.Add(verbTemplate); @@ -1651,14 +1657,14 @@ public void PartialRule() Name = "s_suffix", Gloss = "PART_VERB", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, - IsPartial = true + IsPartial = true, }; sSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") }, } ); Morphophonemic.MorphologicalRules.Add(sSuffix); @@ -1668,14 +1674,14 @@ public void PartialRule() Name = "nominalizer", Gloss = "DERIV", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, - OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value + OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value, }; nominalizer.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "v") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "v") }, } ); Morphophonemic.MorphologicalRules.Add(nominalizer); @@ -1685,13 +1691,13 @@ public void PartialRule() Name = "u_suffix", Gloss = "PART_NOUN", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value, - IsPartial = true + IsPartial = true, }; uSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "u") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "u") }, } ); Morphophonemic.MorphologicalRules.Add(uSuffix); @@ -1706,14 +1712,14 @@ public void PartialRule() new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "p") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "p") }, } ); var nounTemplate = new AffixTemplate { Name = "noun", - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value, }; nounTemplate.Slots.Add(new AffixTemplateSlot(pSuffix) { Optional = true }); Morphophonemic.AffixTemplates.Add(nounTemplate); @@ -1755,14 +1761,14 @@ public void DisjunctiveAllomorphs() new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Annotation(vowel).Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") }, } ); esSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "ɯs") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "ɯs") }, } ); Morphophonemic.MorphologicalRules.Add(esSuffix); @@ -1784,15 +1790,15 @@ public void DisjunctiveAllomorphs() ConstraintType.Require, null, Pattern.New().Annotation(vowel).Value - ) - } + ), + }, } ); guSuffix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "gu") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "gu") }, } ); Morphophonemic.MorphologicalRules.Add(guSuffix); @@ -1825,7 +1831,7 @@ public void SubsumedAffix() new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "u") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "u") }, } ); Morphophonemic.MorphologicalRules.Add(uSuffix); @@ -1842,9 +1848,9 @@ public void SubsumedAffix() Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value, - Pattern.New("2").Annotation(vowel).Value + Pattern.New("2").Annotation(vowel).Value, }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "s") }, } ); Morphophonemic.MorphologicalRules.Add(sSuffix); @@ -1854,14 +1860,14 @@ public void SubsumedAffix() Name = "nominalizer", Gloss = "NOM", RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value, - OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value + OutSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value, }; nominalizer.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "v") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "v") }, } ); Morphophonemic.MorphologicalRules.Add(nominalizer); @@ -1878,9 +1884,9 @@ public void SubsumedAffix() Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value, - Pattern.New("2").Annotation(vowel).Value + Pattern.New("2").Annotation(vowel).Value, }, - Rhs = { new CopyFromInput("1") } + Rhs = { new CopyFromInput("1") }, } ); Morphophonemic.MorphologicalRules.Add(deleteVowelSuffix); @@ -1922,15 +1928,15 @@ public void ModifyFromInputRules() Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value, - Pattern.New("2").Annotation(vowel).Value + Pattern.New("2").Annotation(vowel).Value, }, Rhs = { new CopyFromInput("1"), new CopyFromInput("2"), new InsertSegments(Table3, "s"), - new ModifyFromInput("2", lowRound) - } + new ModifyFromInput("2", lowRound), + }, } ); Morphophonemic.MorphologicalRules.Add(sSuffix); @@ -1981,7 +1987,7 @@ public void NonContiguousRules() .Symbol("V") .Feature(Head) .EqualTo(head => head.Feature("aspect").EqualTo("perf").Feature("mood").EqualTo("active")) - .Value + .Value, }; perfAct.Allomorphs.Add( new AffixProcessAllomorph @@ -1990,7 +1996,7 @@ public void NonContiguousRules() { Pattern.New("1").Annotation(cons).Value, Pattern.New("2").Annotation(cons).Value, - Pattern.New("3").Annotation(cons).Value + Pattern.New("3").Annotation(cons).Value, }, Rhs = { @@ -1999,8 +2005,8 @@ public void NonContiguousRules() new CopyFromInput("2"), new InsertSegments(Table3, "a"), new CopyFromInput("3"), - new InsertSegments(Table3, "ɯd") - } + new InsertSegments(Table3, "ɯd"), + }, } ); Morphophonemic.MorphologicalRules.Add(perfAct); @@ -2009,13 +2015,13 @@ public void NonContiguousRules() { Name = "rule1", ApplicationMode = RewriteApplicationMode.Iterative, - Lhs = Pattern.New().Annotation(lowVowel).Value + Lhs = Pattern.New().Annotation(lowVowel).Value, }; rule1.Subrules.Add( new RewriteSubrule { Rhs = Pattern.New().Annotation(i).Value, - RightEnvironment = Pattern.New().Annotation(voicedCons).Value + RightEnvironment = Pattern.New().Annotation(voicedCons).Value, } ); Allophonic.PhonologicalRules.Add(rule1); diff --git a/tests/SIL.Machine.Morphology.HermitCrab.Tests/MorphologicalRules/CompoundingRuleTests.cs b/tests/SIL.Machine.Morphology.HermitCrab.Tests/MorphologicalRules/CompoundingRuleTests.cs index 3b993b7bb..93192e758 100644 --- a/tests/SIL.Machine.Morphology.HermitCrab.Tests/MorphologicalRules/CompoundingRuleTests.cs +++ b/tests/SIL.Machine.Morphology.HermitCrab.Tests/MorphologicalRules/CompoundingRuleTests.cs @@ -18,7 +18,7 @@ public void SimpleRules() { HeadLhs = { Pattern.New("head").Annotation(any).OneOrMore.Value }, NonHeadLhs = { Pattern.New("nonHead").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("head"), new InsertSegments(Table3, "+"), new CopyFromInput("nonHead") } + Rhs = { new CopyFromInput("head"), new InsertSegments(Table3, "+"), new CopyFromInput("nonHead") }, } ); @@ -35,7 +35,7 @@ public void SimpleRules() { HeadLhs = { Pattern.New("head").Annotation(any).OneOrMore.Value }, NonHeadLhs = { Pattern.New("nonHead").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("nonHead"), new InsertSegments(Table3, "+"), new CopyFromInput("head") } + Rhs = { new CopyFromInput("nonHead"), new InsertSegments(Table3, "+"), new CopyFromInput("head") }, } ); @@ -55,14 +55,14 @@ public void SimpleRules() .New(Language.SyntacticFeatureSystem) .Feature(Head) .EqualTo(head => head.Feature("tense").EqualTo("past")) - .Value + .Value, }; Allophonic.MorphologicalRules.Insert(0, prefix); prefix.Allomorphs.Add( new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new InsertSegments(Table3, "di+"), new CopyFromInput("1") } + Rhs = { new InsertSegments(Table3, "di+"), new CopyFromInput("1") }, } ); @@ -80,7 +80,7 @@ public void SimpleRules() { HeadLhs = { Pattern.New("head").Annotation(any).OneOrMore.Value }, NonHeadLhs = { Pattern.New("nonHead").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("head"), new InsertSegments(Table3, "+"), new CopyFromInput("nonHead") } + Rhs = { new CopyFromInput("head"), new InsertSegments(Table3, "+"), new CopyFromInput("nonHead") }, } ); @@ -98,7 +98,7 @@ public void SimpleRules() { HeadLhs = { Pattern.New("head").Annotation(any).OneOrMore.Value }, NonHeadLhs = { Pattern.New("nonHead").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("nonHead"), new InsertSegments(Table3, "+"), new CopyFromInput("head") } + Rhs = { new CopyFromInput("nonHead"), new InsertSegments(Table3, "+"), new CopyFromInput("head") }, } ); @@ -115,7 +115,10 @@ public void MorphosyntacticRules() var rule1 = new CompoundingRule { Name = "rule1", - NonHeadRequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("V").Value + NonHeadRequiredSyntacticFeatureStruct = FeatureStruct + .New(Language.SyntacticFeatureSystem) + .Symbol("V") + .Value, }; Allophonic.MorphologicalRules.Add(rule1); rule1.Subrules.Add( @@ -123,7 +126,7 @@ public void MorphosyntacticRules() { HeadLhs = { Pattern.New("head").Annotation(any).OneOrMore.Value }, NonHeadLhs = { Pattern.New("nonHead").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("head"), new InsertSegments(Table3, "+"), new CopyFromInput("nonHead") } + Rhs = { new CopyFromInput("head"), new InsertSegments(Table3, "+"), new CopyFromInput("nonHead") }, } ); @@ -180,7 +183,7 @@ public void ProdRestrictRule() { HeadLhs = { Pattern.New("head").Annotation(any).OneOrMore.Value }, NonHeadLhs = { Pattern.New("nonHead").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("head"), new InsertSegments(Table3, "+"), new CopyFromInput("nonHead") } + Rhs = { new CopyFromInput("head"), new InsertSegments(Table3, "+"), new CopyFromInput("nonHead") }, } ); diff --git a/tests/SIL.Machine.Morphology.HermitCrab.Tests/PhonologicalRules/MetathesisRuleTests.cs b/tests/SIL.Machine.Morphology.HermitCrab.Tests/PhonologicalRules/MetathesisRuleTests.cs index 032e09470..54d0e7451 100644 --- a/tests/SIL.Machine.Morphology.HermitCrab.Tests/PhonologicalRules/MetathesisRuleTests.cs +++ b/tests/SIL.Machine.Morphology.HermitCrab.Tests/PhonologicalRules/MetathesisRuleTests.cs @@ -20,7 +20,7 @@ public void SimpleRule() .Group("2", group => group.Annotation(Character(Table3, "u"))) .Value, LeftSwitchName = "2", - RightSwitchName = "1" + RightSwitchName = "1", }; Morphophonemic.PhonologicalRules.Add(rule1); @@ -44,7 +44,7 @@ public void ComplexRule() .Group("rightEnv", group => group.Annotation(HCFeatureSystem.RightSideAnchor)) .Value, LeftSwitchName = "2", - RightSwitchName = "1" + RightSwitchName = "1", }; Morphophonemic.PhonologicalRules.Add(rule1); @@ -54,7 +54,7 @@ public void ComplexRule() new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+u") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "+u") }, } ); @@ -76,7 +76,7 @@ public void SimpleRuleNotUnapplied() .Group("2", group => group.Annotation(Character(Table3, "u"))) .Value, LeftSwitchName = "2", - RightSwitchName = "1" + RightSwitchName = "1", }; Morphophonemic.PhonologicalRules.Add(prule); @@ -86,7 +86,7 @@ public void SimpleRuleNotUnapplied() new AffixProcessAllomorph { Lhs = { Pattern.New("1").Annotation(any).OneOrMore.Value }, - Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "i") } + Rhs = { new CopyFromInput("1"), new InsertSegments(Table3, "i") }, } ); diff --git a/tests/SIL.Machine.Morphology.HermitCrab.Tests/PhonologicalRules/RewriteRuleTests.cs b/tests/SIL.Machine.Morphology.HermitCrab.Tests/PhonologicalRules/RewriteRuleTests.cs index e79cc0d3a..f7c56ecaa 100644 --- a/tests/SIL.Machine.Morphology.HermitCrab.Tests/PhonologicalRules/RewriteRuleTests.cs +++ b/tests/SIL.Machine.Morphology.HermitCrab.Tests/PhonologicalRules/RewriteRuleTests.cs @@ -25,21 +25,21 @@ public void SimpleRules() var rule1 = new RewriteRule { Name = "rule1", - Lhs = Pattern.New().Annotation(Character(Table1, "t")).Value + Lhs = Pattern.New().Annotation(Character(Table1, "t")).Value, }; Allophonic.PhonologicalRules.Add(rule1); rule1.Subrules.Add( new RewriteSubrule { Rhs = Pattern.New().Annotation(asp).Value, - LeftEnvironment = Pattern.New().Annotation(nonCons).Value + LeftEnvironment = Pattern.New().Annotation(nonCons).Value, } ); var rule2 = new RewriteRule { Name = "rule2", - Lhs = Pattern.New().Annotation(Character(Table3, "p")).Value + Lhs = Pattern.New().Annotation(Character(Table3, "p")).Value, }; Allophonic.PhonologicalRules.Add(rule2); Morphophonemic.PhonologicalRules.Add(rule2); @@ -53,7 +53,7 @@ public void SimpleRules() .Annotation(nonCons) .Optional.Annotation(nonCons) .Optional.Value, - RightEnvironment = Pattern.New().Annotation(nonCons).Value + RightEnvironment = Pattern.New().Annotation(nonCons).Value, } ); @@ -108,7 +108,7 @@ public void LongDistanceRules() var rule3 = new RewriteRule { Name = "rule3", - Lhs = Pattern.New().Annotation(highVowel).Value + Lhs = Pattern.New().Annotation(highVowel).Value, }; Allophonic.PhonologicalRules.Add(rule3); rule3.Subrules.Add( @@ -121,7 +121,7 @@ public void LongDistanceRules() .Annotation(cons) .Annotation(lowVowel) .Annotation(cons) - .Value + .Value, } ); @@ -139,7 +139,7 @@ public void LongDistanceRules() .Annotation(lowVowel) .Annotation(cons) .Annotation(rndVowel) - .Value + .Value, } ); @@ -158,7 +158,7 @@ public void LongDistanceRules() .Optional.Annotation(Character(Table3, "+")) .Annotation(cons) .Optional.Annotation(vowel) - .Optional.Value + .Optional.Value, } ); @@ -193,7 +193,7 @@ public void AnchorRules() new RewriteSubrule { Rhs = Pattern.New().Annotation(vlUnasp).Value, - RightEnvironment = Pattern.New().Annotation(HCFeatureSystem.RightSideAnchor).Value + RightEnvironment = Pattern.New().Annotation(HCFeatureSystem.RightSideAnchor).Value, } ); Allophonic.PhonologicalRules.Add(rule3); @@ -211,7 +211,7 @@ public void AnchorRules() .Annotation(vowel) .Annotation(cons) .Annotation(HCFeatureSystem.RightSideAnchor) - .Value + .Value, } ); @@ -223,7 +223,7 @@ public void AnchorRules() new RewriteSubrule { Rhs = Pattern.New().Annotation(vlUnasp).Value, - LeftEnvironment = Pattern.New().Annotation(HCFeatureSystem.LeftSideAnchor).Value + LeftEnvironment = Pattern.New().Annotation(HCFeatureSystem.LeftSideAnchor).Value, } ); @@ -240,7 +240,7 @@ public void AnchorRules() .Annotation(HCFeatureSystem.LeftSideAnchor) .Annotation(cons) .Annotation(vowel) - .Value + .Value, } ); @@ -295,7 +295,7 @@ public void QuantifierRules() var rule3 = new RewriteRule { Name = "rule3", - Lhs = Pattern.New().Annotation(highVowel).Value + Lhs = Pattern.New().Annotation(highVowel).Value, }; Allophonic.PhonologicalRules.Add(rule3); rule3.Subrules.Add( @@ -308,14 +308,14 @@ public void QuantifierRules() .LazyRange(1, 2) .Annotation(cons) .Annotation(rndVowel) - .Value + .Value, } ); var rule4 = new RewriteRule { Name = "rule4", - Lhs = Pattern.New().Annotation(highVowel).Value + Lhs = Pattern.New().Annotation(highVowel).Value, }; Allophonic.PhonologicalRules.Add(rule4); rule4.Subrules.Add( @@ -328,7 +328,7 @@ public void QuantifierRules() .Group(g => g.Annotation(cons).Annotation(lowVowel)) .LazyRange(1, 2) .Annotation(cons) - .Value + .Value, } ); @@ -343,7 +343,7 @@ public void QuantifierRules() var rule1 = new RewriteRule { Name = "rule1", - Lhs = Pattern.New().Annotation(highVowel).Value + Lhs = Pattern.New().Annotation(highVowel).Value, }; Allophonic.PhonologicalRules.Add(rule1); rule1.Subrules.Add( @@ -355,7 +355,7 @@ public void QuantifierRules() .Annotation(backRndVowel) .Annotation(highVowel) .LazyRange(0, 2) - .Value + .Value, } ); @@ -401,14 +401,14 @@ public void MultipleSegmentRules() var rule1 = new RewriteRule { Name = "rule1", - Lhs = Pattern.New().Annotation(highVowel).Annotation(highVowel).Value + Lhs = Pattern.New().Annotation(highVowel).Annotation(highVowel).Value, }; Allophonic.PhonologicalRules.Add(rule1); rule1.Subrules.Add( new RewriteSubrule { Rhs = Pattern.New().Annotation(backRnd).Annotation(backRnd).Value, - LeftEnvironment = Pattern.New().Annotation(backRndVowel).Value + LeftEnvironment = Pattern.New().Annotation(backRndVowel).Value, } ); @@ -447,7 +447,7 @@ public void MultipleDeletionRules() var rule1 = new RewriteRule { Name = "rule1", - Lhs = Pattern.New().Annotation(highVowel).Annotation(highVowel).Value + Lhs = Pattern.New().Annotation(highVowel).Annotation(highVowel).Value, }; Allophonic.PhonologicalRules.Add(rule1); rule1.Subrules.Add( @@ -490,14 +490,14 @@ public void MergeRules() var rule1 = new RewriteRule { Name = "rule1", - Lhs = Pattern.New().Annotation(highVowel).Annotation(highVowel).Value + Lhs = Pattern.New().Annotation(highVowel).Annotation(highVowel).Value, }; Allophonic.PhonologicalRules.Add(rule1); rule1.Subrules.Add( new RewriteSubrule { Rhs = Pattern.New().Annotation(t).Value, - LeftEnvironment = Pattern.New().Annotation(backRndVowel).Value + LeftEnvironment = Pattern.New().Annotation(backRndVowel).Value, } ); @@ -542,7 +542,7 @@ public void MultipleMergeRules() .Annotation(backRndVowel) .Annotation(highVowel) .Annotation(highVowel) - .Value + .Value, }; Allophonic.PhonologicalRules.Add(rule1); rule1.Subrules.Add( @@ -581,7 +581,7 @@ public void ExpandRules() rule1.Subrules.Add( new RewriteSubrule { - Rhs = Pattern.New().Annotation(highVowel).Annotation(highVowel).Value + Rhs = Pattern.New().Annotation(highVowel).Annotation(highVowel).Value, } ); @@ -682,7 +682,7 @@ public void BoundaryRules() var rule1 = new RewriteRule { Name = "rule1", - Lhs = Pattern.New().Annotation(highVowel).Value + Lhs = Pattern.New().Annotation(highVowel).Value, }; Morphophonemic.PhonologicalRules.Add(rule1); rule1.Subrules.Add( @@ -693,7 +693,7 @@ public void BoundaryRules() .New() .Annotation(backRndVowel) .Annotation(Character(Table3, "+")) - .Value + .Value, } ); @@ -709,7 +709,7 @@ public void BoundaryRules() .New() .Annotation(Character(Table3, "+")) .Annotation(unbackUnrndVowel) - .Value + .Value, } ); @@ -721,7 +721,7 @@ public void BoundaryRules() new RewriteSubrule { Rhs = Pattern.New().Annotation(backRnd).Value, - LeftEnvironment = Pattern.New().Annotation(backRndVowel).Value + LeftEnvironment = Pattern.New().Annotation(backRndVowel).Value, } ); @@ -733,7 +733,7 @@ public void BoundaryRules() new RewriteSubrule { Rhs = Pattern.New().Annotation(unbackUnrnd).Value, - RightEnvironment = Pattern.New().Annotation(unbackUnrndVowel).Value + RightEnvironment = Pattern.New().Annotation(unbackUnrndVowel).Value, } ); @@ -745,14 +745,14 @@ public void BoundaryRules() rule1.Subrules.Add( new RewriteSubrule { - RightEnvironment = Pattern.New().Annotation(Character(Table3, "b")).Value + RightEnvironment = Pattern.New().Annotation(Character(Table3, "b")).Value, } ); var rule2 = new RewriteRule { Name = "rule2", - Lhs = Pattern.New().Annotation(backVowel).Value + Lhs = Pattern.New().Annotation(backVowel).Value, }; rule2.Subrules.Add( new RewriteSubrule @@ -761,7 +761,7 @@ public void BoundaryRules() RightEnvironment = Pattern .New() .Group(group => group.Annotation(Character(Table3, "+")).Annotation(Character(Table3, "b"))) - .Value + .Value, } ); Morphophonemic.PhonologicalRules.Add(rule2); @@ -774,7 +774,7 @@ public void BoundaryRules() rule1.Subrules.Add( new RewriteSubrule { - LeftEnvironment = Pattern.New().Annotation(Character(Table3, "b")).Value + LeftEnvironment = Pattern.New().Annotation(Character(Table3, "b")).Value, } ); @@ -788,7 +788,7 @@ public void BoundaryRules() .New() .Annotation(Character(Table3, "b")) .Annotation(Character(Table3, "+")) - .Value + .Value, } ); @@ -813,7 +813,7 @@ public void BoundaryRules() .Annotation(unvdUnasp) .Value, LeftEnvironment = Pattern.New().Annotation(vowel).Value, - RightEnvironment = Pattern.New().Annotation(vowel).Value + RightEnvironment = Pattern.New().Annotation(vowel).Value, } ); @@ -827,7 +827,7 @@ public void BoundaryRules() { Rhs = Pattern.New().Annotation(unvdUnasp).Annotation(unvdUnasp).Value, LeftEnvironment = Pattern.New().Annotation(vowel).Value, - RightEnvironment = Pattern.New().Annotation(vowel).Value + RightEnvironment = Pattern.New().Annotation(vowel).Value, } ); @@ -840,7 +840,7 @@ public void BoundaryRules() new RewriteSubrule { Rhs = Pattern.New().Annotation(asp).Value, - LeftEnvironment = Pattern.New().Annotation(Character(Table3, "+")).Value + LeftEnvironment = Pattern.New().Annotation(Character(Table3, "+")).Value, } ); @@ -866,7 +866,7 @@ public void BoundaryRules() .Annotation(vowel) .Annotation(HCFeatureSystem.RightSideAnchor) .Value, - RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value + RequiredSyntacticFeatureStruct = FeatureStruct.New(Language.SyntacticFeatureSystem).Symbol("N").Value, } ); @@ -909,7 +909,7 @@ public void CommonFeatureRules() var rule1 = new RewriteRule { Name = "rule1", - Lhs = Pattern.New().Annotation(Character(Table1, "p")).Value + Lhs = Pattern.New().Annotation(Character(Table1, "p")).Value, }; Allophonic.PhonologicalRules.Add(rule1); rule1.Subrules.Add( @@ -917,7 +917,7 @@ public void CommonFeatureRules() { Rhs = Pattern.New().Annotation(vdLabFric).Value, LeftEnvironment = Pattern.New().Annotation(vowel).Value, - RightEnvironment = Pattern.New().Annotation(vowel).Value + RightEnvironment = Pattern.New().Annotation(vowel).Value, } ); @@ -930,7 +930,7 @@ public void CommonFeatureRules() { Rhs = Pattern.New().Annotation(Character(Table1, "v")).Value, LeftEnvironment = Pattern.New().Annotation(vowel).Value, - RightEnvironment = Pattern.New().Annotation(vowel).Value + RightEnvironment = Pattern.New().Annotation(vowel).Value, } ); @@ -1008,7 +1008,7 @@ public void AlphaVariableRules() var rule1 = new RewriteRule { Name = "rule1", - Lhs = Pattern.New().Annotation(highVowel).Value + Lhs = Pattern.New().Annotation(highVowel).Value, }; Morphophonemic.PhonologicalRules.Add(rule1); rule1.Subrules.Add( @@ -1039,7 +1039,7 @@ public void AlphaVariableRules() .Value ) .Annotation(cons) - .Value + .Value, } ); @@ -1071,7 +1071,7 @@ public void AlphaVariableRules() .EqualToVariable("a") .Value ) - .Value + .Value, } ); @@ -1106,10 +1106,10 @@ public void AlphaVariableRules() .Value ) .Annotation(vowel) - .Value + .Value, } ); - rule1.Subrules.Add(new RewriteSubrule { Rhs = Pattern.New().Annotation(unasp).Value, }); + rule1.Subrules.Add(new RewriteSubrule { Rhs = Pattern.New().Annotation(unasp).Value }); morpher = new Morpher(TraceManager, Language); AssertMorphsEqual(morpher.ParseWord("pipʰ"), "41"); @@ -1147,7 +1147,7 @@ public void AlphaVariableRules() .EqualToVariable("c") .Value ) - .Value + .Value, } ); @@ -1181,7 +1181,7 @@ public void AlphaVariableRules() .Value ) .Value, - RightEnvironment = Pattern.New().Annotation(HCFeatureSystem.RightSideAnchor).Value + RightEnvironment = Pattern.New().Annotation(HCFeatureSystem.RightSideAnchor).Value, } ); @@ -1243,7 +1243,7 @@ public void EpenthesisRules() new RewriteSubrule { Rhs = Pattern.New().Annotation(highFrontUnrndVowel).Value, - LeftEnvironment = Pattern.New().Annotation(highVowel).Value + LeftEnvironment = Pattern.New().Annotation(highVowel).Value, } ); @@ -1255,7 +1255,7 @@ public void EpenthesisRules() new RewriteSubrule { Rhs = Pattern.New().Annotation(Character(Table1, "i")).Value, - RightEnvironment = Pattern.New().Annotation(highVowel).Value + RightEnvironment = Pattern.New().Annotation(highVowel).Value, } ); @@ -1269,7 +1269,7 @@ public void EpenthesisRules() { Rhs = Pattern.New().Annotation(highFrontUnrndVowel).Value, LeftEnvironment = Pattern.New().Annotation(HCFeatureSystem.LeftSideAnchor).Value, - RightEnvironment = Pattern.New().Annotation(cons).Value + RightEnvironment = Pattern.New().Annotation(cons).Value, } ); @@ -1282,7 +1282,7 @@ public void EpenthesisRules() { Rhs = Pattern.New().Annotation(highFrontUnrndVowel).Value, LeftEnvironment = Pattern.New().Annotation(cons).Value, - RightEnvironment = Pattern.New().Annotation(HCFeatureSystem.RightSideAnchor).Value + RightEnvironment = Pattern.New().Annotation(HCFeatureSystem.RightSideAnchor).Value, } ); @@ -1295,7 +1295,7 @@ public void EpenthesisRules() { Rhs = Pattern.New().Annotation(highFrontUnrndVowel).Value, LeftEnvironment = Pattern.New().Annotation(cons).Value, - RightEnvironment = Pattern.New().Annotation(highBackRndVowel).Value + RightEnvironment = Pattern.New().Annotation(highBackRndVowel).Value, } ); @@ -1330,7 +1330,7 @@ public void EpenthesisRules() .EqualToVariable("b") .Value ) - .Value + .Value, } ); @@ -1346,7 +1346,7 @@ public void EpenthesisRules() .Annotation(highFrontUnrndVowel) .Annotation(highFrontUnrndVowel) .Value, - LeftEnvironment = Pattern.New().Annotation(highVowel).Value + LeftEnvironment = Pattern.New().Annotation(highVowel).Value, } ); @@ -1360,7 +1360,7 @@ public void EpenthesisRules() new RewriteSubrule { Rhs = Pattern.New().Annotation(highFrontUnrndVowel).Value, - LeftEnvironment = Pattern.New().Annotation(HCFeatureSystem.LeftSideAnchor).Value + LeftEnvironment = Pattern.New().Annotation(HCFeatureSystem.LeftSideAnchor).Value, } ); @@ -1375,7 +1375,7 @@ public void EpenthesisRules() new RewriteSubrule { Rhs = Pattern.New().Annotation(highBackRnd).Value, - LeftEnvironment = Pattern.New().Annotation(highBackRndVowel).Value + LeftEnvironment = Pattern.New().Annotation(highBackRndVowel).Value, } ); @@ -1386,7 +1386,7 @@ public void EpenthesisRules() { Rhs = Pattern.New().Annotation(Character(Table1, "t")).Value, LeftEnvironment = Pattern.New().Annotation(vowel).Value, - RightEnvironment = Pattern.New().Annotation(vowel).Value + RightEnvironment = Pattern.New().Annotation(vowel).Value, } ); @@ -1454,7 +1454,7 @@ public void DeletionRules() var rule4 = new RewriteRule { Name = "rule4", - Lhs = Pattern.New().Annotation(highFrontUnrndVowel).Value + Lhs = Pattern.New().Annotation(highFrontUnrndVowel).Value, }; Allophonic.PhonologicalRules.Add(rule4); rule4.Subrules.Add( @@ -1501,7 +1501,7 @@ public void DeletionRules() new RewriteSubrule { LeftEnvironment = Pattern.New().Annotation(HCFeatureSystem.LeftSideAnchor).Value, - RightEnvironment = Pattern.New().Annotation(Character(Table3, "+")).Value + RightEnvironment = Pattern.New().Annotation(Character(Table3, "+")).Value, } ); @@ -1513,28 +1513,28 @@ public void DeletionRules() .Annotation(Character(Table3, "u")) .Annotation(Character(Table3, "b")) .Annotation(Character(Table3, "u")) - .Value + .Value, }; Morphophonemic.PhonologicalRules.Add(rule5); rule5.Subrules.Add( new RewriteSubrule { LeftEnvironment = Pattern.New().Annotation(Character(Table3, "+")).Value, - RightEnvironment = Pattern.New().Annotation(HCFeatureSystem.RightSideAnchor).Value + RightEnvironment = Pattern.New().Annotation(HCFeatureSystem.RightSideAnchor).Value, } ); var rule1 = new RewriteRule { Name = "rule1", - Lhs = Pattern.New().Annotation(Character(Table3, "t")).Value + Lhs = Pattern.New().Annotation(Character(Table3, "t")).Value, }; Morphophonemic.PhonologicalRules.Add(rule1); rule1.Subrules.Add( new RewriteSubrule { Rhs = Pattern.New().Annotation(asp).Value, - LeftEnvironment = Pattern.New().Annotation(nonCons).Value + LeftEnvironment = Pattern.New().Annotation(nonCons).Value, } ); @@ -1598,7 +1598,7 @@ public void DeletionRules() .EqualToVariable("d") .Value ) - .Value + .Value, } ); @@ -1609,7 +1609,7 @@ public void DeletionRules() { Rhs = Pattern.New().Annotation(voiced).Value, LeftEnvironment = Pattern.New().Annotation(vowel).Value, - RightEnvironment = Pattern.New().Annotation(vowel).Value + RightEnvironment = Pattern.New().Annotation(vowel).Value, } ); @@ -1744,14 +1744,14 @@ public void DisjunctiveRules() var disrule1 = new RewriteRule { Name = "disrule1", - Lhs = Pattern.New().Annotation(stop).Value + Lhs = Pattern.New().Annotation(stop).Value, }; Allophonic.PhonologicalRules.Add(disrule1); disrule1.Subrules.Add( new RewriteSubrule { Rhs = Pattern.New().Annotation(asp).Value, - LeftEnvironment = Pattern.New().Annotation(HCFeatureSystem.LeftSideAnchor).Value + LeftEnvironment = Pattern.New().Annotation(HCFeatureSystem.LeftSideAnchor).Value, } ); disrule1.Subrules.Add(new RewriteSubrule { Rhs = Pattern.New().Annotation(unasp).Value }); @@ -1770,7 +1770,7 @@ public void DisjunctiveRules() .Annotation(backRndVowel) .Group(g => g.Annotation(cons).Annotation(highFrontVowel)) .LazyZeroOrMore.Annotation(cons) - .Value + .Value, } ); disrule1.Subrules.Add( @@ -1782,7 +1782,7 @@ public void DisjunctiveRules() .Annotation(frontRndVowel) .Group(g => g.Annotation(cons).Annotation(highFrontVowel)) .LazyZeroOrMore.Annotation(cons) - .Value + .Value, } ); disrule1.Subrules.Add( @@ -1794,7 +1794,7 @@ public void DisjunctiveRules() .Annotation(backUnrndVowel) .Group(g => g.Annotation(cons).Annotation(highFrontVowel)) .LazyZeroOrMore.Annotation(cons) - .Value + .Value, } ); disrule1.Subrules.Add( @@ -1806,7 +1806,7 @@ public void DisjunctiveRules() .Annotation(frontUnrndVowel) .Group(g => g.Annotation(cons).Annotation(highFrontVowel)) .LazyZeroOrMore.Annotation(cons) - .Value + .Value, } ); @@ -1819,14 +1819,14 @@ public void DisjunctiveRules() new RewriteSubrule { Rhs = Pattern.New().Annotation(asp).Value, - LeftEnvironment = Pattern.New().Annotation(HCFeatureSystem.LeftSideAnchor).Value + LeftEnvironment = Pattern.New().Annotation(HCFeatureSystem.LeftSideAnchor).Value, } ); disrule1.Subrules.Add( new RewriteSubrule { Rhs = Pattern.New().Annotation(unasp).Value, - RightEnvironment = Pattern.New().Annotation(HCFeatureSystem.RightSideAnchor).Value + RightEnvironment = Pattern.New().Annotation(HCFeatureSystem.RightSideAnchor).Value, } ); @@ -1839,14 +1839,14 @@ public void DisjunctiveRules() new RewriteSubrule { Rhs = Pattern.New().Annotation(vd).Value, - LeftEnvironment = Pattern.New().Annotation(vowel).Value + LeftEnvironment = Pattern.New().Annotation(vowel).Value, } ); disrule1.Subrules.Add( new RewriteSubrule { Rhs = Pattern.New().Annotation(asp).Value, - RightEnvironment = Pattern.New().Annotation(HCFeatureSystem.RightSideAnchor).Value + RightEnvironment = Pattern.New().Annotation(HCFeatureSystem.RightSideAnchor).Value, } ); @@ -1859,7 +1859,7 @@ public void DisjunctiveRules() new RewriteSubrule { Rhs = Pattern.New().Annotation(asp).Value, - LeftEnvironment = Pattern.New().Annotation(voicelessStop).Value + LeftEnvironment = Pattern.New().Annotation(voicelessStop).Value, } ); disrule1.Subrules.Add(new RewriteSubrule { Rhs = Pattern.New().Annotation(unasp).Value }); @@ -1904,13 +1904,13 @@ public void MultipleApplicationRules() { Name = "rule1", ApplicationMode = RewriteApplicationMode.Simultaneous, - Lhs = Pattern.New().Annotation(highVowel).Value + Lhs = Pattern.New().Annotation(highVowel).Value, }; rule1.Subrules.Add( new RewriteSubrule { Rhs = Pattern.New().Annotation(backRnd).Value, - LeftEnvironment = Pattern.New().Annotation(i).Annotation(cons).Value + LeftEnvironment = Pattern.New().Annotation(i).Annotation(cons).Value, } ); Allophonic.PhonologicalRules.Add(rule1); diff --git a/tests/SIL.Machine.Morphology.HermitCrab.Tests/SIL.Machine.Morphology.HermitCrab.Tests.csproj b/tests/SIL.Machine.Morphology.HermitCrab.Tests/SIL.Machine.Morphology.HermitCrab.Tests.csproj index 3763ddfd1..c131a8b81 100644 --- a/tests/SIL.Machine.Morphology.HermitCrab.Tests/SIL.Machine.Morphology.HermitCrab.Tests.csproj +++ b/tests/SIL.Machine.Morphology.HermitCrab.Tests/SIL.Machine.Morphology.HermitCrab.Tests.csproj @@ -1,7 +1,7 @@  - net8.0 + net10.0 SIL.Machine.Morphology.HermitCrab enable enable @@ -13,21 +13,21 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/SIL.Machine.Tests/Annotations/AnnotationTests.cs b/tests/SIL.Machine.Tests/Annotations/AnnotationTests.cs index 9647b76ef..db74eee40 100644 --- a/tests/SIL.Machine.Tests/Annotations/AnnotationTests.cs +++ b/tests/SIL.Machine.Tests/Annotations/AnnotationTests.cs @@ -152,40 +152,40 @@ public void Find() annList.Add(new Annotation(Range.Create(20, 70), FeatureStruct.New().Value), false); Annotation result; - Assert.IsFalse(annList.Find(0, out result)); + Assert.That(annList.Find(0, out result), Is.False); Assert.That(result, Is.SameAs(annList.Begin)); - Assert.IsTrue(annList.Find(1, out result)); + Assert.That(annList.Find(1, out result), Is.True); Assert.That(result, Is.SameAs(annList.First)); - Assert.IsFalse(annList.Find(100, out result)); + Assert.That(annList.Find(100, out result), Is.False); Assert.That(result, Is.SameAs(annList.Last)); - Assert.IsFalse(annList.Find(101, out result)); + Assert.That(annList.Find(101, out result), Is.False); Assert.That(result, Is.SameAs(annList.Last)); - Assert.IsFalse(annList.Find(30, out result)); + Assert.That(annList.Find(30, out result), Is.False); Assert.That(result, Is.SameAs(annList.ElementAt(3))); - Assert.IsTrue(annList.Find(9, out result)); + Assert.That(annList.Find(9, out result), Is.True); Assert.That(result, Is.SameAs(annList.First.Next)); - Assert.IsFalse(annList.Find(101, Direction.RightToLeft, out result)); + Assert.That(annList.Find(101, Direction.RightToLeft, out result), Is.False); Assert.That(result, Is.SameAs(annList.End)); - Assert.IsTrue(annList.Find(100, Direction.RightToLeft, out result)); + Assert.That(annList.Find(100, Direction.RightToLeft, out result), Is.True); Assert.That(result, Is.SameAs(annList.Last)); - Assert.IsFalse(annList.Find(1, Direction.RightToLeft, out result)); + Assert.That(annList.Find(1, Direction.RightToLeft, out result), Is.False); Assert.That(result, Is.SameAs(annList.First)); - Assert.IsFalse(annList.Find(0, Direction.RightToLeft, out result)); + Assert.That(annList.Find(0, Direction.RightToLeft, out result), Is.False); Assert.That(result, Is.SameAs(annList.First)); - Assert.IsFalse(annList.Find(15, Direction.RightToLeft, out result)); + Assert.That(annList.Find(15, Direction.RightToLeft, out result), Is.False); Assert.That(result, Is.SameAs(annList.ElementAt(2))); - Assert.IsTrue(annList.Find(10, Direction.RightToLeft, out result)); + Assert.That(annList.Find(10, Direction.RightToLeft, out result), Is.True); Assert.That(result, Is.SameAs(annList.First.Next)); } @@ -200,9 +200,9 @@ public void GetNodes() annList.Add(99, 100, FeatureStruct.New().Value); annList.Add(new Annotation(Range.Create(20, 70), FeatureStruct.New().Value), false); - Assert.IsFalse(annList.GetNodes(0, 1).Any()); + Assert.That(annList.GetNodes(0, 1).Any(), Is.False); - Assert.IsFalse(annList.GetNodes(100, 101).Any()); + Assert.That(annList.GetNodes(100, 101).Any(), Is.False); Annotation[] anns = annList.GetNodes(8, 52).ToArray(); Assert.That(anns.Length, Is.EqualTo(3)); @@ -230,40 +230,40 @@ public void FindDepthFirst() annList.Add(51, 100, FeatureStruct.New().Value); Annotation result; - Assert.IsFalse(annList.FindDepthFirst(0, out result)); + Assert.That(annList.FindDepthFirst(0, out result), Is.False); Assert.That(result, Is.EqualTo(annList.Begin)); - Assert.IsFalse(annList.FindDepthFirst(100, out result)); + Assert.That(annList.FindDepthFirst(100, out result), Is.False); Assert.That(result, Is.EqualTo(annList.Last)); - Assert.IsTrue(annList.FindDepthFirst(1, out result)); + Assert.That(annList.FindDepthFirst(1, out result), Is.True); Assert.That(result, Is.EqualTo(annList.First)); - Assert.IsFalse(annList.FindDepthFirst(8, out result)); + Assert.That(annList.FindDepthFirst(8, out result), Is.False); Assert.That(result, Is.EqualTo(annList.First.Children.First)); - Assert.IsTrue(annList.FindDepthFirst(99, out result)); + Assert.That(annList.FindDepthFirst(99, out result), Is.True); Assert.That(result, Is.EqualTo(annList.Last.Children.Last)); - Assert.IsTrue(annList.FindDepthFirst(49, out result)); + Assert.That(annList.FindDepthFirst(49, out result), Is.True); Assert.That(result, Is.EqualTo(annList.First.Next)); - Assert.IsFalse(annList.FindDepthFirst(101, Direction.RightToLeft, out result)); + Assert.That(annList.FindDepthFirst(101, Direction.RightToLeft, out result), Is.False); Assert.That(result, Is.EqualTo(annList.End)); - Assert.IsFalse(annList.FindDepthFirst(1, Direction.RightToLeft, out result)); + Assert.That(annList.FindDepthFirst(1, Direction.RightToLeft, out result), Is.False); Assert.That(result, Is.EqualTo(annList.First)); - Assert.IsTrue(annList.FindDepthFirst(100, Direction.RightToLeft, out result)); + Assert.That(annList.FindDepthFirst(100, Direction.RightToLeft, out result), Is.True); Assert.That(result, Is.EqualTo(annList.Last)); - Assert.IsFalse(annList.FindDepthFirst(71, Direction.RightToLeft, out result)); + Assert.That(annList.FindDepthFirst(71, Direction.RightToLeft, out result), Is.False); Assert.That(result, Is.EqualTo(annList.Last.Children.Last)); - Assert.IsTrue(annList.FindDepthFirst(2, Direction.RightToLeft, out result)); + Assert.That(annList.FindDepthFirst(2, Direction.RightToLeft, out result), Is.True); Assert.That(result, Is.EqualTo(annList.First.Children.First)); - Assert.IsTrue(annList.FindDepthFirst(50, Direction.RightToLeft, out result)); + Assert.That(annList.FindDepthFirst(50, Direction.RightToLeft, out result), Is.True); Assert.That(result, Is.EqualTo(annList.Last.Prev)); } } diff --git a/tests/SIL.Machine.Tests/Clusterers/DbscanClustererTests.cs b/tests/SIL.Machine.Tests/Clusterers/DbscanClustererTests.cs index 7da7630ca..aa334213f 100644 --- a/tests/SIL.Machine.Tests/Clusterers/DbscanClustererTests.cs +++ b/tests/SIL.Machine.Tests/Clusterers/DbscanClustererTests.cs @@ -12,7 +12,7 @@ public void Cluster_AllObjectsInSameCluster() { { 0.00, 0.09, 0.12 }, { 0.09, 0.00, 0.21 }, - { 0.12, 0.21, 0.00 } + { 0.12, 0.21, 0.00 }, }; char[] objects = { 'A', 'B', 'C' }; var clusterer = new DbscanClusterer(o1 => objects.Where(o2 => matrix[o1 - 'A', o2 - 'A'] <= 0.2), 2); @@ -33,7 +33,7 @@ public void Cluster_NoiseNotEmpty() { { 0.00, 0.09, 0.22 }, { 0.09, 0.00, 0.30 }, - { 0.22, 0.30, 0.00 } + { 0.22, 0.30, 0.00 }, }; char[] objects = { 'A', 'B', 'C' }; var clusterer = new DbscanClusterer(o1 => objects.Where(o2 => matrix[o1 - 'A', o2 - 'A'] <= 0.2), 2); diff --git a/tests/SIL.Machine.Tests/Clusterers/FlatUpgmaClustererTests.cs b/tests/SIL.Machine.Tests/Clusterers/FlatUpgmaClustererTests.cs index f6b803c09..fc7112775 100644 --- a/tests/SIL.Machine.Tests/Clusterers/FlatUpgmaClustererTests.cs +++ b/tests/SIL.Machine.Tests/Clusterers/FlatUpgmaClustererTests.cs @@ -13,7 +13,7 @@ public void Cluster() { 0.50, 0.00, 0.40, 0.70, 0.60 }, { 0.67, 0.40, 0.00, 0.80, 0.80 }, { 0.80, 0.70, 0.80, 0.00, 0.30 }, - { 0.20, 0.60, 0.80, 0.30, 0.00 } + { 0.20, 0.60, 0.80, 0.30, 0.00 }, }; var fupgma = new FlatUpgmaClusterer((o1, o2) => matrix[o1 - 'A', o2 - 'A'], 0.5); Cluster[] clusters = fupgma.GenerateClusters(new[] { 'A', 'B', 'C', 'D', 'E' }).ToArray(); diff --git a/tests/SIL.Machine.Tests/Clusterers/NeighborJoiningClustererTests.cs b/tests/SIL.Machine.Tests/Clusterers/NeighborJoiningClustererTests.cs index fcf73ce6f..ee04d0880 100644 --- a/tests/SIL.Machine.Tests/Clusterers/NeighborJoiningClustererTests.cs +++ b/tests/SIL.Machine.Tests/Clusterers/NeighborJoiningClustererTests.cs @@ -14,7 +14,7 @@ public void Cluster() { 1, 0, 2, 3, 3 }, { 2, 2, 0, 3, 3 }, { 3, 3, 3, 0, 1 }, - { 3, 3, 3, 1, 0 } + { 3, 3, 3, 1, 0 }, }; var nj = new NeighborJoiningClusterer((o1, o2) => matrix[o1 - 'A', o2 - 'A']); IUndirectedGraph, ClusterEdge> tree = nj.GenerateClusters( @@ -54,7 +54,7 @@ public void Cluster() { "AB", new Cluster { Description = "AB" } - } + }, }; var edges = new[] @@ -65,7 +65,7 @@ public void Cluster() new ClusterEdge(vertices["DE"], vertices["D"], 0.5), new ClusterEdge(vertices["DE"], vertices["E"], 0.5), new ClusterEdge(vertices["AB"], vertices["A"], 0.5), - new ClusterEdge(vertices["AB"], vertices["B"], 0.5) + new ClusterEdge(vertices["AB"], vertices["B"], 0.5), }; AssertTreeEqual(tree, edges.ToUndirectedGraph, ClusterEdge>(false)); diff --git a/tests/SIL.Machine.Tests/Clusterers/UpgmaClustererTests.cs b/tests/SIL.Machine.Tests/Clusterers/UpgmaClustererTests.cs index e0f422086..19d85e5e1 100644 --- a/tests/SIL.Machine.Tests/Clusterers/UpgmaClustererTests.cs +++ b/tests/SIL.Machine.Tests/Clusterers/UpgmaClustererTests.cs @@ -15,7 +15,7 @@ public void Cluster() { 4, 4, 0, 6, 6, 8 }, { 6, 6, 6, 0, 4, 8 }, { 6, 6, 6, 4, 0, 8 }, - { 8, 8, 8, 8, 8, 0 } + { 8, 8, 8, 8, 8, 0 }, }; var upgma = new UpgmaClusterer((o1, o2) => matrix[o1 - 'A', o2 - 'A']); IBidirectionalGraph, ClusterEdge> tree = upgma.GenerateClusters( @@ -67,7 +67,7 @@ public void Cluster() { "DE", new Cluster { Description = "DE" } - } + }, }; var edges = new[] @@ -81,7 +81,7 @@ public void Cluster() new ClusterEdge(vertices["AB"], vertices["A"], 1), new ClusterEdge(vertices["AB"], vertices["B"], 1), new ClusterEdge(vertices["DE"], vertices["D"], 2), - new ClusterEdge(vertices["DE"], vertices["E"], 2) + new ClusterEdge(vertices["DE"], vertices["E"], 2), }; AssertTreeEqual(tree, edges.ToBidirectionalGraph, ClusterEdge>()); } @@ -122,13 +122,13 @@ public void ClusterTwoDataObjects() { "B", new Cluster('B') { Description = "B" } - } + }, }; var edges = new[] { new ClusterEdge(vertices["root"], vertices["A"], 0.5), - new ClusterEdge(vertices["root"], vertices["B"], 0.5) + new ClusterEdge(vertices["root"], vertices["B"], 0.5), }; AssertTreeEqual(tree, edges.ToBidirectionalGraph, ClusterEdge>()); diff --git a/tests/SIL.Machine.Tests/Corpora/AlignedWordPairTests.cs b/tests/SIL.Machine.Tests/Corpora/AlignedWordPairTests.cs index 2925db342..fc1b0ecf7 100644 --- a/tests/SIL.Machine.Tests/Corpora/AlignedWordPairTests.cs +++ b/tests/SIL.Machine.Tests/Corpora/AlignedWordPairTests.cs @@ -44,7 +44,7 @@ public void ParseToString() IEnumerable alignedWordPairs = new List() { new AlignedWordPair(0, 1) { TranslationScore = 0.1, AlignmentScore = 0.1 }, - new AlignedWordPair(1, 0) { TranslationScore = 0.1, AlignmentScore = 0.1 } + new AlignedWordPair(1, 0) { TranslationScore = 0.1, AlignmentScore = 0.1 }, }; string alignmentString = string.Join(' ', alignedWordPairs.Select(wp => wp.ToString())); IEnumerable parsedAlignedWordPairs = AlignedWordPair.Parse(alignmentString); diff --git a/tests/SIL.Machine.Tests/Corpora/CorporaExtensionsTests.cs b/tests/SIL.Machine.Tests/Corpora/CorporaExtensionsTests.cs index 836f3bdaf..baaa80eba 100644 --- a/tests/SIL.Machine.Tests/Corpora/CorporaExtensionsTests.cs +++ b/tests/SIL.Machine.Tests/Corpora/CorporaExtensionsTests.cs @@ -79,7 +79,7 @@ public void MergedCorpus_SelectFirst() { TextRow("text1", 1, "source 2 segment 1 ."), TextRow("text1", 2, "source 2 segment 2 ."), - TextRow("text1", 3) + TextRow("text1", 3), } ) ); @@ -90,7 +90,7 @@ public void MergedCorpus_SelectFirst() { TextRow("text1", 1, "source 3 segment 1 ."), TextRow("text1", 2, "source 3 segment 2 ."), - TextRow("text1", 3, "source 3 segment 3 .") + TextRow("text1", 3, "source 3 segment 3 ."), } ) ); @@ -112,7 +112,7 @@ public void MergedCorpus_SelectRandom_Seed123456() { TextRow("text1", 1, "source 1 segment 1 ."), TextRow("text1", 2, "source 1 segment 2 ."), - TextRow("text1", 3, "source 1 segment 3 .") + TextRow("text1", 3, "source 1 segment 3 ."), } ) ); @@ -123,7 +123,7 @@ public void MergedCorpus_SelectRandom_Seed123456() { TextRow("text1", 1, "source 2 segment 1 ."), TextRow("text1", 2, "source 2 segment 2 ."), - TextRow("text1", 3, "source 2 segment 3 .") + TextRow("text1", 3, "source 2 segment 3 ."), } ) ); @@ -134,7 +134,7 @@ public void MergedCorpus_SelectRandom_Seed123456() { TextRow("text1", 1, "source 3 segment 1 ."), TextRow("text1", 2, "source 3 segment 2 ."), - TextRow("text1", 3, "source 3 segment 3 .") + TextRow("text1", 3, "source 3 segment 3 ."), } ) ); @@ -159,7 +159,7 @@ public void MergedCorpus_SelectRandom_Seed4501() { TextRow("text1", 1, "source 1 segment 1 ."), TextRow("text1", 2, "source 1 segment 2 ."), - TextRow("text1", 3, "source 1 segment 3 .") + TextRow("text1", 3, "source 1 segment 3 ."), } ) ); @@ -170,7 +170,7 @@ public void MergedCorpus_SelectRandom_Seed4501() { TextRow("text1", 1, "source 2 segment 1 ."), TextRow("text1", 2, "source 2 segment 2 ."), - TextRow("text1", 3, "source 2 segment 3 .") + TextRow("text1", 3, "source 2 segment 3 ."), } ) ); @@ -181,7 +181,7 @@ public void MergedCorpus_SelectRandom_Seed4501() { TextRow("text1", 1, "source 3 segment 1 ."), TextRow("text1", 2, "source 3 segment 2 ."), - TextRow("text1", 3, "source 3 segment 3 .") + TextRow("text1", 3, "source 3 segment 3 ."), } ) ); @@ -206,7 +206,7 @@ public void AlignMergedCorpora() { TextRow("text1", 1, "source 1 segment 1 ."), TextRow("text1", 2, "source 1 segment 2 ."), - TextRow("text1", 3, "source 1 segment 3 .") + TextRow("text1", 3, "source 1 segment 3 ."), } ) ); @@ -217,7 +217,7 @@ public void AlignMergedCorpora() { TextRow("text1", 1, "source 2 segment 1 ."), TextRow("text1", 2, "source 2 segment 2 ."), - TextRow("text1", 3, "source 2 segment 3 .") + TextRow("text1", 3, "source 2 segment 3 ."), } ) ); @@ -228,7 +228,7 @@ public void AlignMergedCorpora() { TextRow("text1", 1, "source 3 segment 1 ."), TextRow("text1", 2, "source 3 segment 2 ."), - TextRow("text1", 3, "source 3 segment 3 .") + TextRow("text1", 3, "source 3 segment 3 ."), } ) ); @@ -242,7 +242,7 @@ public void AlignMergedCorpora() { TextRow("text1", 1, "target 1 segment 1 ."), TextRow("text1", 2, "target 1 segment 2 ."), - TextRow("text1", 3, "target 1 segment 3 .") + TextRow("text1", 3, "target 1 segment 3 ."), } ) ); @@ -253,7 +253,7 @@ public void AlignMergedCorpora() { TextRow("text1", 1, "target 2 segment 1 ."), TextRow("text1", 2, "target 2 segment 2 ."), - TextRow("text1", 3, "target 2 segment 3 .") + TextRow("text1", 3, "target 2 segment 3 ."), } ) ); @@ -264,7 +264,7 @@ public void AlignMergedCorpora() { TextRow("text1", 1, "target 3 segment 1 ."), TextRow("text1", 2, "target 3 segment 2 ."), - TextRow("text1", 3, "target 3 segment 3 .") + TextRow("text1", 3, "target 3 segment 3 ."), } ) ); @@ -288,7 +288,7 @@ private static TextRow TextRow( return new TextRow(textId, rowRef) { Segment = text.Length == 0 ? Array.Empty() : text.Split(), - Flags = flags + Flags = flags, }; } } diff --git a/tests/SIL.Machine.Tests/Corpora/CorporaTestHelpers.cs b/tests/SIL.Machine.Tests/Corpora/CorporaTestHelpers.cs index eb4e37af6..5f51b8c86 100644 --- a/tests/SIL.Machine.Tests/Corpora/CorporaTestHelpers.cs +++ b/tests/SIL.Machine.Tests/Corpora/CorporaTestHelpers.cs @@ -50,11 +50,9 @@ public static string CreateTestParatextBackup() return path; } - public static EqualConstraint IgnoreLineEndings(this EqualConstraint constraint) + public static EqualUsingConstraint IgnoreLineEndings(this EqualStringConstraint constraint) { - return constraint.Using( - (actual, expected) => actual.ReplaceLineEndings() == expected.ReplaceLineEndings() - ); + return constraint.Using(new IgnoreLineEndingsStringComparer()); } /// @@ -168,4 +166,17 @@ public static string CleanString(string input, string[] unwanted) } return input; } + + private sealed class IgnoreLineEndingsStringComparer : StringComparer + { + public override int Compare(string? x, string? y) + { + return string.Compare(x?.ReplaceLineEndings(), y?.ReplaceLineEndings(), StringComparison.InvariantCulture); + } + + public override bool Equals(string? x, string? y) => + string.Equals(x?.ReplaceLineEndings(), y?.ReplaceLineEndings(), StringComparison.InvariantCulture); + + public override int GetHashCode(string obj) => obj.ReplaceLineEndings().GetHashCode(); + } } diff --git a/tests/SIL.Machine.Tests/Corpora/NParallelTextCorpusTests.cs b/tests/SIL.Machine.Tests/Corpora/NParallelTextCorpusTests.cs index 0df207c7a..d7a3660f7 100644 --- a/tests/SIL.Machine.Tests/Corpora/NParallelTextCorpusTests.cs +++ b/tests/SIL.Machine.Tests/Corpora/NParallelTextCorpusTests.cs @@ -24,7 +24,7 @@ public void GetRows_ThreeCorpora() { TextRow("text1", 1, "source segment 1 .", TextRowFlags.None), TextRow("text1", 2, "source segment 2 ."), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -35,7 +35,7 @@ public void GetRows_ThreeCorpora() { TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2 ."), - TextRow("text1", 3, "source segment 3 .", TextRowFlags.None) + TextRow("text1", 3, "source segment 3 .", TextRowFlags.None), } ) ); @@ -46,7 +46,7 @@ public void GetRows_ThreeCorpora() { TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2 .", TextRowFlags.None), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -72,7 +72,7 @@ public void GetRows_ThreeCorpora_MissingRows() new[] { TextRow("text1", 1, "source segment 1 .", TextRowFlags.None), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -82,7 +82,7 @@ public void GetRows_ThreeCorpora_MissingRows() new[] { TextRow("text1", 2, "source segment 2 ."), - TextRow("text1", 3, "source segment 3 .", TextRowFlags.None) + TextRow("text1", 3, "source segment 3 .", TextRowFlags.None), } ) ); @@ -107,7 +107,7 @@ public void GetRows_ThreeCorpora_MissingRows_AllAllRows() new[] { TextRow("text1", 1, "source segment 1 .", TextRowFlags.None), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -117,7 +117,7 @@ public void GetRows_ThreeCorpora_MissingRows_AllAllRows() new[] { TextRow("text1", 2, "source segment 2 ."), - TextRow("text1", 3, "source segment 3 .", TextRowFlags.None) + TextRow("text1", 3, "source segment 3 .", TextRowFlags.None), } ) ); @@ -142,7 +142,7 @@ public void GetRows_ThreeCorpora_MissingRows_SomeAllRows() new[] { TextRow("text1", 1, "source segment 1 .", TextRowFlags.None), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -152,7 +152,7 @@ public void GetRows_ThreeCorpora_MissingRows_SomeAllRows() new[] { TextRow("text1", 2, "source segment 2 ."), - TextRow("text1", 3, "source segment 3 .", TextRowFlags.None) + TextRow("text1", 3, "source segment 3 .", TextRowFlags.None), } ) ); @@ -177,7 +177,7 @@ public void GetRows_ThreeCorpora_MissingRows_AllAllRows_MissingMiddle() new[] { TextRow("text1", 1, "source segment 1 .", TextRowFlags.None), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -188,7 +188,7 @@ public void GetRows_ThreeCorpora_MissingRows_AllAllRows_MissingMiddle() { TextRow("text1", 1, "source segment 1 .", TextRowFlags.None), TextRow("text1", 2, "source segment 2 ."), - TextRow("text1", 3, "source segment 3 .", TextRowFlags.None) + TextRow("text1", 3, "source segment 3 .", TextRowFlags.None), } ) ); @@ -199,7 +199,7 @@ public void GetRows_ThreeCorpora_MissingRows_AllAllRows_MissingMiddle() { TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2 ."), - TextRow("text1", 3, "source segment 3 .", TextRowFlags.None) + TextRow("text1", 3, "source segment 3 .", TextRowFlags.None), } ) ); @@ -221,12 +221,12 @@ public void GetRows_ThreeCorpora_MissingRows_MissingLastRows() { TextRow("text1", 1, "source segment 1 .", TextRowFlags.None), TextRow("text1", 2, "source segment 2 ."), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); var corpus2 = new DictionaryTextCorpus( - new MemoryText("text1", new[] { TextRow("text1", 1, "source segment 1 ."), }) + new MemoryText("text1", new[] { TextRow("text1", 1, "source segment 1 .") }) ); var corpus3 = new DictionaryTextCorpus( new MemoryText("text1", new[] { TextRow("text1", 1, "source segment 1 .") }) @@ -248,7 +248,7 @@ public void GetRows_OneCorpus() new[] { TextRow("text1", 1, "source segment 1 .", TextRowFlags.None), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -276,7 +276,7 @@ public void GetRows_ThreeCorpora_Range() TextRowFlags.InRange | TextRowFlags.RangeStart ), TextRow("text1", 3, flags: TextRowFlags.InRange), - TextRow("text1", 4, "source segment 4 .") + TextRow("text1", 4, "source segment 4 ."), } ) ); @@ -288,7 +288,7 @@ public void GetRows_ThreeCorpora_Range() TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2 ."), TextRow("text1", 3, "source segment 3 ."), - TextRow("text1", 4, "source segment 4 .") + TextRow("text1", 4, "source segment 4 ."), } ) ); @@ -300,7 +300,7 @@ public void GetRows_ThreeCorpora_Range() TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2 ."), TextRow("text1", 3, "source segment 3 ."), - TextRow("text1", 4, "source segment 4 .") + TextRow("text1", 4, "source segment 4 ."), } ) ); @@ -326,7 +326,7 @@ public void GetRows_ThreeCorpora_OverlappingRanges() "source segment 2 . source segment 3 .", TextRowFlags.SentenceStart | TextRowFlags.InRange | TextRowFlags.RangeStart ), - TextRow("text1", 3, flags: TextRowFlags.InRange) + TextRow("text1", 3, flags: TextRowFlags.InRange), } ) ); @@ -342,7 +342,7 @@ public void GetRows_ThreeCorpora_OverlappingRanges() TextRowFlags.SentenceStart | TextRowFlags.InRange | TextRowFlags.RangeStart ), TextRow("text1", 2, flags: TextRowFlags.InRange), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -353,7 +353,7 @@ public void GetRows_ThreeCorpora_OverlappingRanges() { TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2 ."), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -377,7 +377,7 @@ public void GetRows_ThreeCorpora_OverlappingRanges_AllIndividualRows() "source segment 2 . source segment 3 .", TextRowFlags.SentenceStart | TextRowFlags.InRange | TextRowFlags.RangeStart ), - TextRow("text1", 3, flags: TextRowFlags.InRange) + TextRow("text1", 3, flags: TextRowFlags.InRange), } ) ); @@ -393,7 +393,7 @@ public void GetRows_ThreeCorpora_OverlappingRanges_AllIndividualRows() TextRowFlags.SentenceStart | TextRowFlags.InRange | TextRowFlags.RangeStart ), TextRow("text1", 2, flags: TextRowFlags.InRange), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -404,7 +404,7 @@ public void GetRows_ThreeCorpora_OverlappingRanges_AllIndividualRows() { TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2 ."), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -429,7 +429,7 @@ public void GetRows_ThreeCorpora_OverlappingRanges_AllRangeOneThroughTwoRows() "source segment 2 . source segment 3 .", TextRowFlags.SentenceStart | TextRowFlags.InRange | TextRowFlags.RangeStart ), - TextRow("text1", 3, flags: TextRowFlags.InRange) + TextRow("text1", 3, flags: TextRowFlags.InRange), } ) ); @@ -445,7 +445,7 @@ public void GetRows_ThreeCorpora_OverlappingRanges_AllRangeOneThroughTwoRows() TextRowFlags.SentenceStart | TextRowFlags.InRange | TextRowFlags.RangeStart ), TextRow("text1", 2, flags: TextRowFlags.InRange), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -456,7 +456,7 @@ public void GetRows_ThreeCorpora_OverlappingRanges_AllRangeOneThroughTwoRows() { TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2 ."), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -481,7 +481,7 @@ public void GetRows_ThreeCorpora_OverlappingRanges_AllRangeTwoThroughThreeRows() "source segment 2 . source segment 3 .", TextRowFlags.SentenceStart | TextRowFlags.InRange | TextRowFlags.RangeStart ), - TextRow("text1", 3, flags: TextRowFlags.InRange) + TextRow("text1", 3, flags: TextRowFlags.InRange), } ) ); @@ -497,7 +497,7 @@ public void GetRows_ThreeCorpora_OverlappingRanges_AllRangeTwoThroughThreeRows() TextRowFlags.SentenceStart | TextRowFlags.InRange | TextRowFlags.RangeStart ), TextRow("text1", 2, flags: TextRowFlags.InRange), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -508,7 +508,7 @@ public void GetRows_ThreeCorpora_OverlappingRanges_AllRangeTwoThroughThreeRows() { TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2 ."), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -529,7 +529,7 @@ public void GetRows_ThreeCorpora_SameRefManyToMany() TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2-1 ."), TextRow("text1", 2, "source segment 2-2 ."), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -541,7 +541,7 @@ public void GetRows_ThreeCorpora_SameRefManyToMany() TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2-1 ."), TextRow("text1", 2, "source segment 2-2 ."), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -553,7 +553,7 @@ public void GetRows_ThreeCorpora_SameRefManyToMany() TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2-1 ."), TextRow("text1", 2, "source segment 2-2 ."), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -576,7 +576,7 @@ public void GetRows_ThreeCorpora_SameRefCorporaOfDifferentSizes() TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2-1 ."), TextRow("text1", 2, "source segment 2-2 ."), - TextRow("text1", 3, "source segment 3 . ") + TextRow("text1", 3, "source segment 3 . "), } ) ); @@ -599,7 +599,7 @@ private static TextRow TextRow( return new TextRow(textId, rowRef) { Segment = text.Length == 0 ? Array.Empty() : text.Split(), - Flags = flags + Flags = flags, }; } } diff --git a/tests/SIL.Machine.Tests/Corpora/ParallelTextCorpusTests.cs b/tests/SIL.Machine.Tests/Corpora/ParallelTextCorpusTests.cs index 4d60ffaf4..47227b7dc 100644 --- a/tests/SIL.Machine.Tests/Corpora/ParallelTextCorpusTests.cs +++ b/tests/SIL.Machine.Tests/Corpora/ParallelTextCorpusTests.cs @@ -26,7 +26,7 @@ public void GetRows_NoMissingRows() { TextRow("text1", 1, "source segment 1 .", TextRowFlags.None), TextRow("text1", 2, "source segment 2 ."), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -37,7 +37,7 @@ public void GetRows_NoMissingRows() { TextRow("text1", 1, "target segment 1 ."), TextRow("text1", 2, "target segment 2 ."), - TextRow("text1", 3, "target segment 3 .", TextRowFlags.None) + TextRow("text1", 3, "target segment 3 .", TextRowFlags.None), } ) ); @@ -48,7 +48,7 @@ public void GetRows_NoMissingRows() { AlignmentRow("text1", 1, new AlignedWordPair(0, 0)), AlignmentRow("text1", 2, new AlignedWordPair(1, 1)), - AlignmentRow("text1", 3, new AlignedWordPair(2, 2)) + AlignmentRow("text1", 3, new AlignedWordPair(2, 2)), } ) ); @@ -82,7 +82,7 @@ public void GetRows_MissingMiddleTargetRow() { TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2 ."), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -98,7 +98,7 @@ public void GetRows_MissingMiddleTargetRow() new[] { AlignmentRow("text1", 1, new AlignedWordPair(0, 0)), - AlignmentRow("text1", 3, new AlignedWordPair(2, 2)) + AlignmentRow("text1", 3, new AlignedWordPair(2, 2)), } ) ); @@ -134,7 +134,7 @@ public void GetRows_MissingMiddleSourceRow() { TextRow("text1", 1, "target segment 1 ."), TextRow("text1", 2, "target segment 2 ."), - TextRow("text1", 3, "target segment 3 .") + TextRow("text1", 3, "target segment 3 ."), } ) ); @@ -144,7 +144,7 @@ public void GetRows_MissingMiddleSourceRow() new[] { AlignmentRow("text1", 1, new AlignedWordPair(0, 0)), - AlignmentRow("text1", 3, new AlignedWordPair(2, 2)) + AlignmentRow("text1", 3, new AlignedWordPair(2, 2)), } ) ); @@ -174,7 +174,7 @@ public void GetRows_MissingLastTargetRow() { TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2 ."), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -190,7 +190,7 @@ public void GetRows_MissingLastTargetRow() new[] { AlignmentRow("text1", 1, new AlignedWordPair(0, 0)), - AlignmentRow("text1", 2, new AlignedWordPair(1, 1)) + AlignmentRow("text1", 2, new AlignedWordPair(1, 1)), } ) ); @@ -226,7 +226,7 @@ public void GetRows_MissingLastSourceRow() { TextRow("text1", 1, "target segment 1 ."), TextRow("text1", 2, "target segment 2 ."), - TextRow("text1", 3, "target segment 3 .") + TextRow("text1", 3, "target segment 3 ."), } ) ); @@ -236,7 +236,7 @@ public void GetRows_MissingLastSourceRow() new[] { AlignmentRow("text1", 1, new AlignedWordPair(0, 0)), - AlignmentRow("text1", 2, new AlignedWordPair(1, 1)) + AlignmentRow("text1", 2, new AlignedWordPair(1, 1)), } ) ); @@ -266,7 +266,7 @@ public void GetRows_MissingFirstTargetRow() { TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2 ."), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -282,7 +282,7 @@ public void GetRows_MissingFirstTargetRow() new[] { AlignmentRow("text1", 2, new AlignedWordPair(1, 1)), - AlignmentRow("text1", 3, new AlignedWordPair(2, 2)) + AlignmentRow("text1", 3, new AlignedWordPair(2, 2)), } ) ); @@ -318,7 +318,7 @@ public void GetRows_MissingFirstSourceRow() { TextRow("text1", 1, "target segment 1 ."), TextRow("text1", 2, "target segment 2 ."), - TextRow("text1", 3, "target segment 3 .") + TextRow("text1", 3, "target segment 3 ."), } ) ); @@ -328,7 +328,7 @@ public void GetRows_MissingFirstSourceRow() new[] { AlignmentRow("text1", 2, new AlignedWordPair(1, 1)), - AlignmentRow("text1", 3, new AlignedWordPair(2, 2)) + AlignmentRow("text1", 3, new AlignedWordPair(2, 2)), } ) ); @@ -364,7 +364,7 @@ public void GetRows_Range() TextRowFlags.InRange | TextRowFlags.RangeStart ), TextRow("text1", 3, flags: TextRowFlags.InRange), - TextRow("text1", 4, "source segment 4 .") + TextRow("text1", 4, "source segment 4 ."), } ) ); @@ -376,7 +376,7 @@ public void GetRows_Range() TextRow("text1", 1, "target segment 1 ."), TextRow("text1", 2, "target segment 2 ."), TextRow("text1", 3, "target segment 3 ."), - TextRow("text1", 4, "target segment 4 .") + TextRow("text1", 4, "target segment 4 ."), } ) ); @@ -407,7 +407,7 @@ public void GetRows_OverlappingRanges() "source segment 2 . source segment 3 .", TextRowFlags.SentenceStart | TextRowFlags.InRange | TextRowFlags.RangeStart ), - TextRow("text1", 3, flags: TextRowFlags.InRange) + TextRow("text1", 3, flags: TextRowFlags.InRange), } ) ); @@ -423,7 +423,7 @@ public void GetRows_OverlappingRanges() TextRowFlags.SentenceStart | TextRowFlags.InRange | TextRowFlags.RangeStart ), TextRow("text1", 2, flags: TextRowFlags.InRange), - TextRow("text1", 3, "target segment 3 .") + TextRow("text1", 3, "target segment 3 ."), } ) ); @@ -460,7 +460,7 @@ public void GetRows_OverlappingRangesAndMissingRows() TextRowFlags.SentenceStart | TextRowFlags.InRange | TextRowFlags.RangeStart ), TextRow("text1", 2, flags: TextRowFlags.InRange), - TextRow("text1", 3, flags: TextRowFlags.InRange) + TextRow("text1", 3, flags: TextRowFlags.InRange), } ) ); @@ -475,7 +475,7 @@ public void GetRows_OverlappingRangesAndMissingRows() "target segment 3 . target segment 4 .", TextRowFlags.SentenceStart | TextRowFlags.InRange | TextRowFlags.RangeStart ), - TextRow("text1", 4, flags: TextRowFlags.InRange) + TextRow("text1", 4, flags: TextRowFlags.InRange), } ) ); @@ -515,7 +515,7 @@ public void GetRows_AdjacentRangesSameText() "source segment 3 . source segment 4 .", TextRowFlags.SentenceStart | TextRowFlags.InRange | TextRowFlags.RangeStart ), - TextRow("text1", 4, flags: TextRowFlags.InRange) + TextRow("text1", 4, flags: TextRowFlags.InRange), } ) ); @@ -527,7 +527,7 @@ public void GetRows_AdjacentRangesSameText() TextRow("text1", 1, "target segment 1 .", TextRowFlags.None), TextRow("text1", 2, "target segment 2 ."), TextRow("text1", 3, "target segment 3 ."), - TextRow("text1", 4, "target segment 4 .") + TextRow("text1", 4, "target segment 4 ."), } ) ); @@ -565,7 +565,7 @@ public void GetRows_AdjacentRangesDifferentTexts() ), TextRow("text1", 2, flags: TextRowFlags.InRange), TextRow("text1", 3, "source segment 3 ."), - TextRow("text1", 4, "source segment 4 .") + TextRow("text1", 4, "source segment 4 ."), } ) ); @@ -582,7 +582,7 @@ public void GetRows_AdjacentRangesDifferentTexts() "target segment 3 . target segment 4 .", TextRowFlags.SentenceStart | TextRowFlags.InRange | TextRowFlags.RangeStart ), - TextRow("text1", 4, flags: TextRowFlags.InRange) + TextRow("text1", 4, flags: TextRowFlags.InRange), } ) ); @@ -621,7 +621,7 @@ public void GetRows_AdjacentRangesBothTexts_EmptyTargetSegments() "source segment 3 . source segment 4 .", TextRowFlags.InRange | TextRowFlags.RangeStart ), - TextRow("text1", 4, flags: TextRowFlags.InRange) + TextRow("text1", 4, flags: TextRowFlags.InRange), } ) ); @@ -633,7 +633,7 @@ public void GetRows_AdjacentRangesBothTexts_EmptyTargetSegments() TextRow("text1", 1, flags: TextRowFlags.InRange | TextRowFlags.RangeStart), TextRow("text1", 2, flags: TextRowFlags.InRange), TextRow("text1", 3, flags: TextRowFlags.InRange | TextRowFlags.RangeStart), - TextRow("text1", 4, flags: TextRowFlags.InRange) + TextRow("text1", 4, flags: TextRowFlags.InRange), } ) ); @@ -641,7 +641,7 @@ public void GetRows_AdjacentRangesBothTexts_EmptyTargetSegments() var parallelCorpus = new ParallelTextCorpus(sourceCorpus, targetCorpus) { AllSourceRows = true, - AllTargetRows = false + AllTargetRows = false, }; ParallelTextRow[] rows = parallelCorpus.ToArray(); Assert.That(rows.Length, Is.EqualTo(2)); @@ -666,13 +666,13 @@ public void GetRows_AllSourceRows() TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2 ."), TextRow("text1", 3, "source segment 3 ."), - TextRow("text1", 4, "source segment 4 .") + TextRow("text1", 4, "source segment 4 ."), } ), new MemoryText("text2", new[] { TextRow("text2", 5, "source segment 5 .") }), new MemoryText( "text3", - new[] { TextRow("text3", 6, "source segment 6 ."), TextRow("text3", 7, "source segment 7 ."), } + new[] { TextRow("text3", 6, "source segment 6 ."), TextRow("text3", 7, "source segment 7 .") } ) ); var targetCorpus = new DictionaryTextCorpus( @@ -682,12 +682,12 @@ public void GetRows_AllSourceRows() { TextRow("text1", 1, "target segment 1 ."), TextRow("text1", 3, "target segment 3 ."), - TextRow("text1", 4, "target segment 4 .") + TextRow("text1", 4, "target segment 4 ."), } ), new MemoryText( "text3", - new[] { TextRow("text3", 6, "target segment 6 ."), TextRow("text3", 7, "target segment 7 ."), } + new[] { TextRow("text3", 6, "target segment 6 ."), TextRow("text3", 7, "target segment 7 .") } ) ); @@ -748,7 +748,7 @@ public void GetRows_RangeAllTargetRows() TextRowFlags.SentenceStart | TextRowFlags.InRange | TextRowFlags.RangeStart ), TextRow("text1", 3, flags: TextRowFlags.InRange), - TextRow("text1", 4, "source segment 4 .") + TextRow("text1", 4, "source segment 4 ."), } ) ); @@ -760,7 +760,7 @@ public void GetRows_RangeAllTargetRows() TextRow("text1", 1, "target segment 1 ."), TextRow("text1", 2, "target segment 2 ."), TextRow("text1", 3, "target segment 3 ."), - TextRow("text1", 4, "target segment 4 .") + TextRow("text1", 4, "target segment 4 ."), } ) ); @@ -793,7 +793,7 @@ public void GetRows_SameRefMiddleManyToMany() TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2-1 ."), TextRow("text1", 2, "source segment 2-2 ."), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -805,7 +805,7 @@ public void GetRows_SameRefMiddleManyToMany() TextRow("text1", 1, "target segment 1 ."), TextRow("text1", 2, "target segment 2-1 ."), TextRow("text1", 2, "target segment 2-2 ."), - TextRow("text1", 3, "target segment 3 .") + TextRow("text1", 3, "target segment 3 ."), } ) ); @@ -841,7 +841,7 @@ public void GetGetRows_SameRefMiddleOneToMany() { TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2 ."), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -853,7 +853,7 @@ public void GetGetRows_SameRefMiddleOneToMany() TextRow("text1", 1, "target segment 1 ."), TextRow("text1", 2, "target segment 2-1 ."), TextRow("text1", 2, "target segment 2-2 ."), - TextRow("text1", 3, "target segment 3 .") + TextRow("text1", 3, "target segment 3 ."), } ) ); @@ -882,7 +882,7 @@ public void GetGetRows_SameRefMiddleManyToOne() TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2-1 ."), TextRow("text1", 2, "source segment 2-2 ."), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -893,7 +893,7 @@ public void GetGetRows_SameRefMiddleManyToOne() { TextRow("text1", 1, "target segment 1 ."), TextRow("text1", 2, "target segment 2 ."), - TextRow("text1", 3, "target segment 3 .") + TextRow("text1", 3, "target segment 3 ."), } ) ); @@ -917,7 +917,7 @@ public void GetGetRows_SameRefLastOneToMany() var sourceCorpus = new DictionaryTextCorpus( new MemoryText( "text1", - new[] { TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2 ."), } + new[] { TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2 .") } ) ); var targetCorpus = new DictionaryTextCorpus( @@ -928,7 +928,7 @@ public void GetGetRows_SameRefLastOneToMany() TextRow("text1", 1, "target segment 1 ."), TextRow("text1", 2, "target segment 2-1 ."), TextRow("text1", 2, "target segment 2-2 ."), - TextRow("text1", 3, "target segment 3 .") + TextRow("text1", 3, "target segment 3 ."), } ) ); @@ -957,14 +957,14 @@ public void GetGetRows_SameRefLastManyToOne() TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2-1 ."), TextRow("text1", 2, "source segment 2-2 ."), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); var targetCorpus = new DictionaryTextCorpus( new MemoryText( "text1", - new[] { TextRow("text1", 1, "target segment 1 ."), TextRow("text1", 2, "target segment 2 ."), } + new[] { TextRow("text1", 1, "target segment 1 ."), TextRow("text1", 2, "target segment 2 .") } ) ); @@ -999,12 +999,16 @@ public void GetGetRows_SameVerseRefOneToMany() { TextRow("MAT", ScriptureRef.Parse("MAT 1:1", ScrVers.Original), "source chapter one, verse one ."), TextRow("MAT", ScriptureRef.Parse("MAT 1:2", ScrVers.Original), "source chapter one, verse two ."), - TextRow("MAT", ScriptureRef.Parse("MAT 1:3", ScrVers.Original), "source chapter one, verse three .") + TextRow( + "MAT", + ScriptureRef.Parse("MAT 1:3", ScrVers.Original), + "source chapter one, verse three ." + ), } ) ) { - Versification = ScrVers.Original + Versification = ScrVers.Original, }; var targetCorpus = new DictionaryTextCorpus( new MemoryText( @@ -1019,12 +1023,12 @@ public void GetGetRows_SameVerseRefOneToMany() TextRowFlags.SentenceStart | TextRowFlags.InRange | TextRowFlags.RangeStart ), TextRow("MAT", ScriptureRef.Parse("MAT 1:3", versification), flags: TextRowFlags.InRange), - TextRow("MAT", ScriptureRef.Parse("MAT 1:4", versification), "target chapter one, verse four .") + TextRow("MAT", ScriptureRef.Parse("MAT 1:4", versification), "target chapter one, verse four ."), } ) ) { - Versification = versification + Versification = versification, }; var parallelCorpus = new ParallelTextCorpus(sourceCorpus, targetCorpus); @@ -1067,12 +1071,12 @@ public void GetGetRows_VerseRefOutOfOrder() ScriptureRef.Parse("MAT 1:3", ScrVers.Original), "source chapter one, verse three ." ), - TextRow("MAT", ScriptureRef.Parse("MAT 1:4", ScrVers.Original), "source chapter one, verse four .") + TextRow("MAT", ScriptureRef.Parse("MAT 1:4", ScrVers.Original), "source chapter one, verse four ."), } ) ) { - Versification = ScrVers.Original + Versification = ScrVers.Original, }; var targetCorpus = new DictionaryTextCorpus( new MemoryText( @@ -1083,12 +1087,12 @@ public void GetGetRows_VerseRefOutOfOrder() TextRow("MAT", ScriptureRef.Parse("MAT 1:2", versification), "target chapter one, verse two ."), TextRow("MAT", ScriptureRef.Parse("MAT 1:3", versification), "target chapter one, verse three ."), TextRow("MAT", ScriptureRef.Parse("MAT 1:4", versification), "target chapter one, verse four ."), - TextRow("MAT", ScriptureRef.Parse("MAT 1:5", versification), "target chapter one, verse five .") + TextRow("MAT", ScriptureRef.Parse("MAT 1:5", versification), "target chapter one, verse five ."), } ) ) { - Versification = versification + Versification = versification, }; var parallelCorpus = new ParallelTextCorpus(sourceCorpus, targetCorpus); @@ -1146,7 +1150,7 @@ public void Count_MissingRow() { TextRow("text1", 1, "target segment 1 ."), TextRow("text1", 2, "target segment 2 ."), - TextRow("text1", 3, "target segment 3 .") + TextRow("text1", 3, "target segment 3 ."), } ) ); @@ -1172,7 +1176,7 @@ public void Count_EmptyRow() { TextRow("text1", 1, "source segment 1 ."), TextRow("text1", 2, "source segment 2 ."), - TextRow("text1", 3, "source segment 3 .") + TextRow("text1", 3, "source segment 3 ."), } ) ); @@ -1183,7 +1187,7 @@ public void Count_EmptyRow() { TextRow("text1", 1, "target segment 1 ."), TextRow("text1", 2), - TextRow("text1", 3, "target segment 3 .") + TextRow("text1", 3, "target segment 3 ."), } ) ); @@ -1204,7 +1208,7 @@ private static TextRow TextRow( return new TextRow(textId, rowRef) { Segment = text.Length == 0 ? Array.Empty() : text.Split(), - Flags = flags + Flags = flags, }; } @@ -1223,7 +1227,7 @@ public void GetRows_AllDeuterocanonicalBooks_WithAlignments() "LJE", "S3Y", "SUS", - "BEL" + "BEL", }; MemoryText CreateMemoryText(string bookId, string segmentType) @@ -1286,7 +1290,7 @@ public void GetRows_MultipleRowsPerBookWithMismatches() "LJE", "S3Y", "SUS", - "BEL" + "BEL", }; DictionaryTextCorpus sourceCorpus = new DictionaryTextCorpus( @@ -1302,7 +1306,7 @@ public void GetRows_MultipleRowsPerBookWithMismatches() .ToArray() ) { - Versification = ScrVers.Original + Versification = ScrVers.Original, }; DictionaryTextCorpus targetCorpus = new DictionaryTextCorpus( @@ -1314,7 +1318,7 @@ public void GetRows_MultipleRowsPerBookWithMismatches() .ToArray() ) { - Versification = ScrVers.Original + Versification = ScrVers.Original, }; DictionaryAlignmentCorpus alignments = new DictionaryAlignmentCorpus( @@ -1328,28 +1332,28 @@ public void GetRows_MultipleRowsPerBookWithMismatches() ParallelTextCorpus parallelCorpus = new ParallelTextCorpus(sourceCorpus, targetCorpus, alignments) { - AllSourceRows = true + AllSourceRows = true, }; var rows = parallelCorpus.ToList(); Assert.That(rows.Count, Is.EqualTo(22), "Total rows processed should be 22."); - TestContext.WriteLine("=== Debugging Output ==="); - TestContext.WriteLine($"Total Rows: {rows.Count}"); + TestContext.Out.WriteLine("=== Debugging Output ==="); + TestContext.Out.WriteLine($"Total Rows: {rows.Count}"); foreach (var row in rows.Take(2)) { string bookId = row.TextId; - TestContext.WriteLine($"Book: {bookId}"); - TestContext.WriteLine( + TestContext.Out.WriteLine($"Book: {bookId}"); + TestContext.Out.WriteLine( $"SourceRefs: {string.Join(", ", row.SourceRefs?.Select(sr => sr.ToString()) ?? new[] { "null" })}" ); - TestContext.WriteLine( + TestContext.Out.WriteLine( $"TargetRefs: {string.Join(", ", row.TargetRefs?.Select(tr => tr.ToString()) ?? new[] { "null" })}" ); - TestContext.WriteLine($"SourceSegment: {string.Join(" ", row.SourceSegment)}"); - TestContext.WriteLine($"TargetSegment: {string.Join(" ", row.TargetSegment)}"); - TestContext.WriteLine("--------------"); + TestContext.Out.WriteLine($"SourceSegment: {string.Join(" ", row.SourceSegment)}"); + TestContext.Out.WriteLine($"TargetSegment: {string.Join(" ", row.TargetSegment)}"); + TestContext.Out.WriteLine("--------------"); } for (int i = 0; i < rows.Count; i++) @@ -1484,14 +1488,14 @@ public void GetVersesInVersification_ButNotInSourceOrTarget(string bookId, ScrVe if (issues.Any()) { - TestContext.WriteLine("The following issues were encountered:"); + TestContext.Out.WriteLine("The following issues were encountered:"); foreach (var issue in issues) { - TestContext.WriteLine(issue); + TestContext.Out.WriteLine(issue); } } - TestContext.WriteLine(issues.Count); + TestContext.Out.WriteLine(issues.Count); Assert.That( issues.Count, @@ -1573,10 +1577,10 @@ public void GetVersesInSourceOrTarget_ButNotInVersification(string bookId, ScrVe if (issues.Any()) { - TestContext.WriteLine("The following issues were encountered:"); + TestContext.Out.WriteLine("The following issues were encountered:"); foreach (var issue in issues) { - TestContext.WriteLine(issue); + TestContext.Out.WriteLine(issue); } } @@ -1593,7 +1597,7 @@ public void ValidateCrossBookMappingsAcrossVersifications() Dictionary expectedMappings = new Dictionary { { "SUS 1:1", "DAG 13:1" }, - { "SUS 1:2", "DAG 13:2" } + { "SUS 1:2", "DAG 13:2" }, }; string source1Text = "Et erat vir habitans in Babylone, et nomen ejus Joakim:"; @@ -1602,7 +1606,7 @@ public void ValidateCrossBookMappingsAcrossVersifications() Dictionary versifications = new Dictionary { { ScrVersType.Original, ScrVers.Original }, - { ScrVersType.English, ScrVers.English } + { ScrVersType.English, ScrVers.English }, }; ParatextTextCorpus corpus = CorporaTestHelpers.GetDeuterocanonicalSourceCorpus(); @@ -1612,7 +1616,7 @@ public void ValidateCrossBookMappingsAcrossVersifications() ScrVers versification = versifications[versificationType]; corpus.Versification = versification; - TestContext.WriteLine($"Validating for versification: {versificationType}"); + TestContext.Out.WriteLine($"Validating for versification: {versificationType}"); foreach (var mapping in expectedMappings) { @@ -1625,7 +1629,7 @@ public void ValidateCrossBookMappingsAcrossVersifications() if (sourceText == null || mappedText == null) { - TestContext.WriteLine( + TestContext.Out.WriteLine( $"Missing text for book {sourceVerse.Book} in versification {versificationType}." ); continue; @@ -1640,7 +1644,7 @@ public void ValidateCrossBookMappingsAcrossVersifications() if (sourceRow == null || targetRow == null) { - TestContext.WriteLine( + TestContext.Out.WriteLine( $"Missing verse: {sourceVerse} or {targetVerse} in versification {versificationType}." ); continue; @@ -1676,13 +1680,13 @@ public void GetDoubleMappingsAcrossVersifications() { "DAG 1:1-3", "DAG 1:1-3" }, { "DAG 1:4-6", "DAG 1:1-3" }, { "DAG 1:7", "SUS 1:7" }, - { "DAG 1:8", "SUS 1:8" } + { "DAG 1:8", "SUS 1:8" }, }; Dictionary versifications = new Dictionary { { ScrVersType.Original, ScrVers.Original }, - { ScrVersType.English, ScrVers.English } + { ScrVersType.English, ScrVers.English }, }; Dictionary> targetToSourceMap = new Dictionary>(); @@ -1690,7 +1694,7 @@ public void GetDoubleMappingsAcrossVersifications() foreach (ScrVersType versificationType in versifications.Keys) { ScrVers versification = versifications[versificationType]; - TestContext.WriteLine($"Validating for versification: {versificationType}"); + TestContext.Out.WriteLine($"Validating for versification: {versificationType}"); Dictionary expandedMappings = CorporaTestHelpers.ExpandVerseMappings(expectedMappings); @@ -1734,12 +1738,12 @@ public void GetDoubleMappingsAcrossVersifications() mergedContent += $"Content for {sourceVerse} "; } - TestContext.WriteLine($"Merged content for Target {targetVerse}: {mergedContent}"); + TestContext.Out.WriteLine($"Merged content for Target {targetVerse}: {mergedContent}"); if (sourceVerses.Count > 1) { doubleMappedVerses.Add(targetVerse, sourceVerses.ToArray()); - TestContext.WriteLine( + TestContext.Out.WriteLine( $"Double mapping detected for Target {targetVerse}: " + $"Mapped from Source(s) {string.Join(", ", sourceVerses)}" ); @@ -1786,7 +1790,7 @@ private static ScrVers GetVersification(ScrVersType versificationType) ScrVersType.English => ScrVers.English, ScrVersType.RussianProtestant => ScrVers.RussianProtestant, ScrVersType.RussianOrthodox => ScrVers.RussianOrthodox, - _ => throw new ArgumentException("Invalid versification type", nameof(versificationType)) + _ => throw new ArgumentException("Invalid versification type", nameof(versificationType)), }; } diff --git a/tests/SIL.Machine.Tests/Corpora/ParatextProjectTermsParserTests.cs b/tests/SIL.Machine.Tests/Corpora/ParatextProjectTermsParserTests.cs index 8de0cad95..95ec0675c 100644 --- a/tests/SIL.Machine.Tests/Corpora/ParatextProjectTermsParserTests.cs +++ b/tests/SIL.Machine.Tests/Corpora/ParatextProjectTermsParserTests.cs @@ -33,7 +33,7 @@ public void TestGetKeyTermsFromTermsRenderings() " - } + }, } ); IEnumerable terms = env.GetGlosses(); @@ -101,7 +101,7 @@ public void TestGetKeyTermsFromTermsLocalizations_FilterByChapters() { "HAB", new() { 1 } - } + }, } ); IEnumerable terms = env.GetGlosses(); @@ -131,7 +131,7 @@ public void TestGetKeyTermsFromTermsLocalizations_TermRenderingsExists_PreferLoc " - } + }, }, useTermGlosses: true ); diff --git a/tests/SIL.Machine.Tests/Corpora/ParatextProjectVersificationErrorTests.cs b/tests/SIL.Machine.Tests/Corpora/ParatextProjectVersificationErrorTests.cs index f3c618060..af462680f 100644 --- a/tests/SIL.Machine.Tests/Corpora/ParatextProjectVersificationErrorTests.cs +++ b/tests/SIL.Machine.Tests/Corpora/ParatextProjectVersificationErrorTests.cs @@ -34,7 +34,7 @@ public void GetUsfmVersificationErrors_NoErrors() \v 14 \v 15 " - } + }, } ); Assert.That( @@ -69,7 +69,7 @@ public void GetUsfmVersificationErrors_MissingVerse() \v 13 \v 14 " - } + }, } ); IReadOnlyList errors = env.GetUsfmVersificationErrors(); @@ -89,7 +89,7 @@ public void GetUsfmVersificationErrors_MissingChapter() "653JNTest.SFM", @"\id 3JN " - } + }, } ); IReadOnlyList errors = env.GetUsfmVersificationErrors(); @@ -126,7 +126,7 @@ public void GetUsfmVersificationErrors_ExtraVerse() \v 15 \v 16 " - } + }, } ); IReadOnlyList errors = env.GetUsfmVersificationErrors(); @@ -161,7 +161,7 @@ public void GetUsfmVersificationErrors_InvalidVerse() \v 14 \v 15 " - } + }, } ); IReadOnlyList errors = env.GetUsfmVersificationErrors(); @@ -198,7 +198,7 @@ public void GetUsfmVersificationErrors_ExtraVerseSegment() \v 14b \v 15 " - } + }, } ); IReadOnlyList errors = env.GetUsfmVersificationErrors(); @@ -237,7 +237,7 @@ public void GetUsfmVersificationErrors_MissingVerseSegment() \v 14 \v 15 " - } + }, } ); IReadOnlyList errors = env.GetUsfmVersificationErrors(); @@ -259,7 +259,7 @@ public void GetUsfmVersificationErrors_IgnoreNonCanonicals() \c 1 \v 3-2 " - } + }, } ); IReadOnlyList errors = env.GetUsfmVersificationErrors(); @@ -295,7 +295,7 @@ public void GetUsfmVersificationErrors_ExtraVerse_ExcludedInCustomVrs() \v 14 \v 15 " - } + }, } ); IReadOnlyList errors = env.GetUsfmVersificationErrors(); @@ -349,7 +349,7 @@ public void GetUsfmVersificationErrors_MultipleBooks() \v 14 \v 15 " - } + }, } ); IReadOnlyList errors = env.GetUsfmVersificationErrors(); @@ -384,7 +384,7 @@ public void GetUsfmVersificationErrors_MultipleChapters() \c 2 \v 1 " - } + }, } ); IReadOnlyList errors = env.GetUsfmVersificationErrors(); @@ -408,7 +408,7 @@ public void GetUsfmVersificationErrors_InvalidChapterNumber() @"\id 3JN \c 1. " - } + }, } ); IReadOnlyList errors = env.GetUsfmVersificationErrors(); @@ -433,7 +433,7 @@ public void GetUsfmVersificationErrors_InvalidVerseNumber() \c 1 \v v1 " - } + }, } ); IReadOnlyList errors = env.GetUsfmVersificationErrors(); diff --git a/tests/SIL.Machine.Tests/Corpora/PlaceMarkersUsfmUpdateBlockHandlerTests.cs b/tests/SIL.Machine.Tests/Corpora/PlaceMarkersUsfmUpdateBlockHandlerTests.cs index c9130a8f2..dab667458 100644 --- a/tests/SIL.Machine.Tests/Corpora/PlaceMarkersUsfmUpdateBlockHandlerTests.cs +++ b/tests/SIL.Machine.Tests/Corpora/PlaceMarkersUsfmUpdateBlockHandlerTests.cs @@ -30,7 +30,7 @@ public void UpdateUsfm_ParagraphMarkers() ScrRef("MAT 1:1"), updateRows, new Dictionary { { "alignment_info", alignInfo } } - ) + ), ]; string usfm = @"\id MAT @@ -79,7 +79,7 @@ public void UpdateUsfm_StyleMarkers() ScrRef("MAT 1:1"), updateRows, new Dictionary { { "alignment_info", alignInfo } } - ) + ), ]; string usfm = @"\id MAT @@ -117,7 +117,7 @@ public void UpdateUsfm_StyleMarkers() ScrRef("MAT 1:1"), updateRows, new Dictionary { { "alignment_info", alignInfo } } - ) + ), ]; target = UpdateUsfm( @@ -149,7 +149,7 @@ public void UpdateUsfm_EmbedMarkers() new UpdateUsfmRow(ScrRef("MAT 1:4/1:f"), "New embed text"), new UpdateUsfmRow(ScrRef("MAT 1:5"), "New verse 5"), new UpdateUsfmRow(ScrRef("MAT 1:6"), "New verse 6"), - new UpdateUsfmRow(ScrRef("MAT 1:6/1:f"), "New verse 6 embed text") + new UpdateUsfmRow(ScrRef("MAT 1:6/1:f"), "New verse 6 embed text"), ]; string usfm = @"\id MAT @@ -219,7 +219,7 @@ public void UpdateUsfm_TrailingEmptyParagraphs() ScrRef("MAT 1:1"), "New verse 1", new Dictionary { { "alignment_info", alignInfo } } - ) + ), ]; string usfm = @"\id MAT @@ -267,7 +267,7 @@ public void UpdateUsfm_Headers() paragraphBehavior: UpdateUsfmMarkerBehavior.Preserve, styleBehavior: UpdateUsfmMarkerBehavior.Strip ) - } + }, } ), new UpdateUsfmRow( @@ -284,11 +284,11 @@ public void UpdateUsfm_Headers() paragraphBehavior: UpdateUsfmMarkerBehavior.Preserve, styleBehavior: UpdateUsfmMarkerBehavior.Strip ) - } + }, } ), new UpdateUsfmRow(ScrRef("MAT 1:3"), "Y"), - new UpdateUsfmRow(ScrRef("MAT 1:3/1:s1"), "Updated header") + new UpdateUsfmRow(ScrRef("MAT 1:3/1:s1"), "Updated header"), ]; string usfm = @"\id MAT @@ -365,7 +365,7 @@ public void UpdateUsfm_ConsecutiveMarkers() paragraphBehavior: UpdateUsfmMarkerBehavior.Preserve, styleBehavior: UpdateUsfmMarkerBehavior.Preserve ) - } + }, } ), ]; @@ -413,7 +413,7 @@ public void UpdateUsfm_VerseRanges() paragraphBehavior: UpdateUsfmMarkerBehavior.Preserve, styleBehavior: UpdateUsfmMarkerBehavior.Strip ) - } + }, } )) .ToList(); @@ -461,7 +461,7 @@ public void UpdateUsfm_NoUpdate() paragraphBehavior: UpdateUsfmMarkerBehavior.Strip, styleBehavior: UpdateUsfmMarkerBehavior.Strip ) - } + }, } ), ]; @@ -504,7 +504,7 @@ public void UpdateUsfm_NoUpdate() paragraphBehavior: UpdateUsfmMarkerBehavior.Preserve, styleBehavior: UpdateUsfmMarkerBehavior.Strip ) - } + }, } ), ]; @@ -562,7 +562,7 @@ public void UpdateUsfm_SplitTokens() paragraphBehavior: UpdateUsfmMarkerBehavior.Preserve, styleBehavior: UpdateUsfmMarkerBehavior.Strip ) - } + }, } ), ]; @@ -611,7 +611,7 @@ public void UpdateUsfm_NoText() paragraphBehavior: UpdateUsfmMarkerBehavior.Preserve, styleBehavior: UpdateUsfmMarkerBehavior.Preserve ) - } + }, } ), ]; @@ -657,7 +657,7 @@ public void UpdateUsfm_ConsecutiveSubstring() paragraphBehavior: UpdateUsfmMarkerBehavior.Preserve, styleBehavior: UpdateUsfmMarkerBehavior.Strip ) - } + }, } ), ]; @@ -704,7 +704,7 @@ public void UpdateUsfm_VersesOutOfOrder() paragraphBehavior: UpdateUsfmMarkerBehavior.Preserve, styleBehavior: UpdateUsfmMarkerBehavior.Strip ) - } + }, } ), new UpdateUsfmRow( @@ -721,9 +721,9 @@ public void UpdateUsfm_VersesOutOfOrder() paragraphBehavior: UpdateUsfmMarkerBehavior.Preserve, styleBehavior: UpdateUsfmMarkerBehavior.Strip ) - } + }, } - ) + ), ]; string usfm = @"\id MAT @@ -772,7 +772,7 @@ public void UpdateUsfm_StripParagraphsWithHeaders() paragraphBehavior: UpdateUsfmMarkerBehavior.Strip, styleBehavior: UpdateUsfmMarkerBehavior.Preserve ) - } + }, } ), ]; diff --git a/tests/SIL.Machine.Tests/Corpora/UpdateUsfmParserHandlerTests.cs b/tests/SIL.Machine.Tests/Corpora/UpdateUsfmParserHandlerTests.cs index cc6142036..9b5219c36 100644 --- a/tests/SIL.Machine.Tests/Corpora/UpdateUsfmParserHandlerTests.cs +++ b/tests/SIL.Machine.Tests/Corpora/UpdateUsfmParserHandlerTests.cs @@ -11,7 +11,7 @@ public void GetUsfm_Verse_CharStyle() { var rows = new List { - new UpdateUsfmRow(ScrRef("MAT 1:1"), "First verse of the first chapter.") + new UpdateUsfmRow(ScrRef("MAT 1:1"), "First verse of the first chapter."), }; string target = UpdateUsfm(rows); @@ -37,7 +37,7 @@ public void GetUsfm_StripAllText() var rows = new List { new UpdateUsfmRow(ScrRef("MAT 1:1"), "Update 1"), - new UpdateUsfmRow(ScrRef("MAT 1:3"), "Update 3") + new UpdateUsfmRow(ScrRef("MAT 1:3"), "Update 3"), }; string usfm = @"\id MAT - Test @@ -204,7 +204,7 @@ public void GetUsfm_PreserveParagraphs() [Test] public void GetUsfm_ParagraphInVerse() { - var rows = new List { new UpdateUsfmRow(ScrRef("MAT 1:1"), "Update 1"), }; + var rows = new List { new UpdateUsfmRow(ScrRef("MAT 1:1"), "Update 1") }; string usfm = @"\id MAT - Test \c 1 @@ -290,7 +290,7 @@ public void GetUsfm_Verse_StripNote() { var rows = new List { - new UpdateUsfmRow(ScrRef("MAT 2:1"), "First verse of the second chapter.") + new UpdateUsfmRow(ScrRef("MAT 2:1"), "First verse of the second chapter."), }; string target = UpdateUsfm(rows, embedBehavior: UpdateUsfmMarkerBehavior.Strip); @@ -320,7 +320,7 @@ public void GetUsfm_Verse_RowVerseSegment() { var rows = new List { - new UpdateUsfmRow(ScrRef("MAT 2:1a"), "First verse of the second chapter.") + new UpdateUsfmRow(ScrRef("MAT 2:1a"), "First verse of the second chapter."), }; string target = UpdateUsfm(rows); @@ -337,7 +337,7 @@ public void GetUsfm_Verse_UsfmVerseSegment() { var rows = new List { - new UpdateUsfmRow(ScrRef("MAT 2:7"), "Seventh verse of the second chapter.") + new UpdateUsfmRow(ScrRef("MAT 2:7"), "Seventh verse of the second chapter."), }; string target = UpdateUsfm(rows); @@ -349,7 +349,7 @@ public void GetUsfm_Verse_MultipleParas() { var rows = new List { - new UpdateUsfmRow(ScrRef("MAT 1:2"), "Second verse of the first chapter.") + new UpdateUsfmRow(ScrRef("MAT 1:2"), "Second verse of the first chapter."), }; string target = UpdateUsfm(rows); @@ -366,7 +366,7 @@ public void GetUsfm_Verse_Table() { var rows = new List { - new UpdateUsfmRow(ScrRef("MAT 2:9"), "Ninth verse of the second chapter.") + new UpdateUsfmRow(ScrRef("MAT 2:9"), "Ninth verse of the second chapter."), }; string target = UpdateUsfm(rows); @@ -381,7 +381,7 @@ public void GetUsfm_Verse_RangeSingleRowMultipleVerses() new UpdateUsfmRow( ScrRef("MAT 2:11", "MAT 2:12"), "Eleventh verse of the second chapter. Twelfth verse of the second chapter." - ) + ), }; string target = UpdateUsfm(rows); @@ -398,7 +398,7 @@ public void GetUsfm_Verse_RangeSingleRowSingleVerse() { var rows = new List { - new UpdateUsfmRow(ScrRef("MAT 2:11"), "Eleventh verse of the second chapter.") + new UpdateUsfmRow(ScrRef("MAT 2:11"), "Eleventh verse of the second chapter."), }; string target = UpdateUsfm(rows); @@ -411,7 +411,7 @@ public void GetUsfm_Verse_RangeMultipleRowsSingleVerse() var rows = new List { new UpdateUsfmRow(ScrRef("MAT 2:11"), "Eleventh verse of the second chapter."), - new UpdateUsfmRow(ScrRef("MAT 2:12"), "Twelfth verse of the second chapter.") + new UpdateUsfmRow(ScrRef("MAT 2:12"), "Twelfth verse of the second chapter."), }; string target = UpdateUsfm(rows); @@ -430,7 +430,7 @@ public void GetUsfm_MergeVerseSegments() { new UpdateUsfmRow(ScrRef("MAT 2:2"), "Verse 2."), new UpdateUsfmRow(ScrRef("MAT 2:2a"), "Verse 2a."), - new UpdateUsfmRow(ScrRef("MAT 2:2b"), "Verse 2b.") + new UpdateUsfmRow(ScrRef("MAT 2:2b"), "Verse 2b."), }; string target = UpdateUsfm(rows); @@ -443,7 +443,7 @@ public void GetUsfm_Verse_OptBreak() var rows = new List { new UpdateUsfmRow(ScrRef("MAT 2:2"), "Second verse of the second chapter."), - new UpdateUsfmRow(ScrRef("MAT 2:3"), "Third verse of the second chapter.") + new UpdateUsfmRow(ScrRef("MAT 2:3"), "Third verse of the second chapter."), }; string target = UpdateUsfm(rows, embedBehavior: UpdateUsfmMarkerBehavior.Strip); @@ -458,7 +458,7 @@ public void GetUsfm_Verse_Milestone() { var rows = new List { - new UpdateUsfmRow(ScrRef("MAT 2:10"), "Tenth verse of the second chapter.") + new UpdateUsfmRow(ScrRef("MAT 2:10"), "Tenth verse of the second chapter."), }; string target = UpdateUsfm(rows); @@ -473,7 +473,7 @@ public void GetUsfm_Verse_Unmatched() { var rows = new List { - new UpdateUsfmRow(ScrRef("MAT 1:3"), "Third verse of the first chapter.") + new UpdateUsfmRow(ScrRef("MAT 1:3"), "Third verse of the first chapter."), }; string target = UpdateUsfm(rows); @@ -507,7 +507,7 @@ public void GetUsfm_NonVerse_Relaxed() new UpdateUsfmRow(ScrRef("MAT 1:1"), "First verse of the first chapter."), new UpdateUsfmRow(ScrRef("MAT 2:0/tr/tc1"), "The first cell of the table."), new UpdateUsfmRow(ScrRef("MAT 2:0/tr/tc2"), "The second cell of the table."), - new UpdateUsfmRow(ScrRef("MAT 2:0/tr/tc1"), "The third cell of the table.") + new UpdateUsfmRow(ScrRef("MAT 2:0/tr/tc1"), "The third cell of the table."), }; string target = UpdateUsfm(rows); @@ -533,7 +533,7 @@ public void GetUsfm_NonVerse_Sidebar() { var rows = new List { - new UpdateUsfmRow(ScrRef("MAT 2:3/1:esb/1:ms"), "The first paragraph of the sidebar.") + new UpdateUsfmRow(ScrRef("MAT 2:3/1:esb/1:ms"), "The first paragraph of the sidebar."), }; string target = UpdateUsfm(rows); @@ -546,7 +546,7 @@ public void GetUsfm_NonVerse_Table() var rows = new List { new UpdateUsfmRow(ScrRef("MAT 2:0/1:tr/1:tc1"), "The first cell of the table."), - new UpdateUsfmRow(ScrRef("MAT 2:0/2:tr/1:tc1"), "The third cell of the table.") + new UpdateUsfmRow(ScrRef("MAT 2:0/2:tr/1:tc1"), "The third cell of the table."), }; string target = UpdateUsfm(rows); @@ -565,7 +565,7 @@ public void GetUsfm_NonVerse_OptBreak() { var rows = new List { - new UpdateUsfmRow(ScrRef("MAT 2:3/1:esb/2:p"), "The second paragraph of the sidebar.") + new UpdateUsfmRow(ScrRef("MAT 2:3/1:esb/2:p"), "The second paragraph of the sidebar."), }; string target = UpdateUsfm(rows); @@ -607,7 +607,7 @@ public void GetUsfm_Verse_DoubleVaVp() { var rows = new List { - new UpdateUsfmRow(ScrRef("MAT 3:1"), "Updating later in the book to start.") + new UpdateUsfmRow(ScrRef("MAT 3:1"), "Updating later in the book to start."), }; string target = UpdateUsfm(rows); @@ -651,7 +651,7 @@ public void GetUsfm_Verse_UpdateRowsBeforeText() new UpdateUsfmRow(ScrRef("GEN 1:3"), "Update rows before the start"), new UpdateUsfmRow(ScrRef("GEN 1:4"), "Update rows before the start"), new UpdateUsfmRow(ScrRef("GEN 1:5"), "Update rows before the start"), - new UpdateUsfmRow(ScrRef("MAT 1:0/3:ip"), "The introductory paragraph.") + new UpdateUsfmRow(ScrRef("MAT 1:0/3:ip"), "The introductory paragraph."), }; string target = UpdateUsfm(rows); @@ -667,7 +667,7 @@ public void GetUsfm_StripParagraphs() var rows = new List { new UpdateUsfmRow(ScrRef("MAT 1:0/2:p"), "Update Paragraph"), - new UpdateUsfmRow(ScrRef("MAT 1:1"), "Update Verse 1") + new UpdateUsfmRow(ScrRef("MAT 1:1"), "Update Verse 1"), }; string usfm = @@ -714,7 +714,7 @@ public void GetUsfm_PreservationRawStrings() { var rows = new List { - new UpdateUsfmRow(ScrRef("MAT 1:1"), @"Update all in one row \f \fr 1.1 \ft Some note \f*") + new UpdateUsfmRow(ScrRef("MAT 1:1"), @"Update all in one row \f \fr 1.1 \ft Some note \f*"), }; string usfm = @@ -755,7 +755,7 @@ public void GetUsfm_BeginningOfVerseEmbed() [Test] public void CrossReferenceDontUpdate() { - var rows = new List { new UpdateUsfmRow(ScrRef("MAT 1:1/1:x"), "Update the cross reference"), }; + var rows = new List { new UpdateUsfmRow(ScrRef("MAT 1:1/1:x"), "Update the cross reference") }; string usfm = @"\id MAT - Test \c 1 @@ -773,7 +773,7 @@ public void CrossReferenceDontUpdate() [Test] public void PreserveFig() { - var rows = new List { new UpdateUsfmRow(ScrRef("MAT 1:1"), "Update"), }; + var rows = new List { new UpdateUsfmRow(ScrRef("MAT 1:1"), "Update") }; string usfm = @"\id MAT - Test \c 1 @@ -1191,7 +1191,7 @@ public void GetUsfm_HeaderReferenceParagraphs() new UpdateUsfmRow(ScrRef("MAT 1:2"), "new verse 2"), new UpdateUsfmRow(ScrRef("MAT 1:3"), "new verse 3"), new UpdateUsfmRow(ScrRef("MAT 2:1"), "new verse 1"), - new UpdateUsfmRow(ScrRef("MAT 2:2"), "new verse 2") + new UpdateUsfmRow(ScrRef("MAT 2:2"), "new verse 2"), }; string usfm = diff --git a/tests/SIL.Machine.Tests/Corpora/UsfmManualTests.cs b/tests/SIL.Machine.Tests/Corpora/UsfmManualTests.cs index 762acdf67..4692fbfd8 100644 --- a/tests/SIL.Machine.Tests/Corpora/UsfmManualTests.cs +++ b/tests/SIL.Machine.Tests/Corpora/UsfmManualTests.cs @@ -12,18 +12,23 @@ public class UsfmManualTests [Ignore("This is for manual testing only. Remove this tag to run the test.")] public void ParseParallelCorpusAsync() { - ParatextTextCorpus tCorpus = - new(projectDir: CorporaTestHelpers.UsfmTargetProjectPath, includeAllText: true, includeMarkers: true); + ParatextTextCorpus tCorpus = new( + projectDir: CorporaTestHelpers.UsfmTargetProjectPath, + includeAllText: true, + includeMarkers: true + ); - ParatextTextCorpus sCorpus = - new(projectDir: CorporaTestHelpers.UsfmSourceProjectPath, includeAllText: true, includeMarkers: true); + ParatextTextCorpus sCorpus = new( + projectDir: CorporaTestHelpers.UsfmSourceProjectPath, + includeAllText: true, + includeMarkers: true + ); - ParallelTextCorpus pCorpus = - new(sCorpus, tCorpus, alignmentCorpus: null, rowRefComparer: null) - { - AllSourceRows = true, - AllTargetRows = false - }; + ParallelTextCorpus pCorpus = new(sCorpus, tCorpus, alignmentCorpus: null, rowRefComparer: null) + { + AllSourceRows = true, + AllTargetRows = false, + }; List rows = pCorpus.GetRows().ToList(); Assert.That(rows, Has.Count.GreaterThan(0)); @@ -70,8 +75,8 @@ public void AnalyzeCorporaQuoteConventions() Assert.Multiple(() => { - Assert.NotNull(sourceAnalysis.BestQuoteConvention); - Assert.NotNull(targetAnalysis.BestQuoteConvention); + Assert.That(sourceAnalysis.BestQuoteConvention, Is.Not.Null); + Assert.That(targetAnalysis.BestQuoteConvention, Is.Not.Null); }); } diff --git a/tests/SIL.Machine.Tests/Corpora/UsfmMemoryTextTests.cs b/tests/SIL.Machine.Tests/Corpora/UsfmMemoryTextTests.cs index d2dd5dbdf..b9699dd71 100644 --- a/tests/SIL.Machine.Tests/Corpora/UsfmMemoryTextTests.cs +++ b/tests/SIL.Machine.Tests/Corpora/UsfmMemoryTextTests.cs @@ -760,15 +760,14 @@ public void GetRows_IncompleteVerseRange() private static TextRow[] GetRows(string usfm, bool includeMarkers = false, bool includeAllText = false) { - UsfmMemoryText text = - new( - new UsfmStylesheet("usfm.sty"), - Encoding.UTF8, - "MAT", - usfm.Trim().ReplaceLineEndings("\r\n") + "\r\n", - includeMarkers: includeMarkers, - includeAllText: includeAllText - ); + UsfmMemoryText text = new( + new UsfmStylesheet("usfm.sty"), + Encoding.UTF8, + "MAT", + usfm.Trim().ReplaceLineEndings("\r\n") + "\r\n", + includeMarkers: includeMarkers, + includeAllText: includeAllText + ); return text.GetRows().ToArray(); } } diff --git a/tests/SIL.Machine.Tests/FeatureModel/FeatureStructTests.cs b/tests/SIL.Machine.Tests/FeatureModel/FeatureStructTests.cs index 3d6ce691b..c733110ee 100644 --- a/tests/SIL.Machine.Tests/FeatureModel/FeatureStructTests.cs +++ b/tests/SIL.Machine.Tests/FeatureModel/FeatureStructTests.cs @@ -117,7 +117,7 @@ public void Unify() new ComplexFeature("d"), new SymbolicFeature("e", new FeatureSymbol("f")), new ComplexFeature("g"), - new SymbolicFeature("h", new FeatureSymbol("j")) + new SymbolicFeature("h", new FeatureSymbol("j")), }; FeatureStruct featStruct1 = FeatureStruct @@ -141,7 +141,7 @@ public void Unify() .Value; FeatureStruct result; - Assert.IsTrue(featStruct1.Unify(featStruct2, out result)); + Assert.That(featStruct1.Unify(featStruct2, out result), Is.True); featureSystem = new FeatureSystem { @@ -151,7 +151,7 @@ public void Unify() new SymbolicFeature("e", new FeatureSymbol("f")), new ComplexFeature("g"), new SymbolicFeature("h", new FeatureSymbol("j")), - new ComplexFeature("i") + new ComplexFeature("i"), }; featStruct1 = FeatureStruct @@ -616,7 +616,7 @@ params Func[] expectedSelectors { new SymbolicFeature("a", new FeatureSymbol("a1"), new FeatureSymbol("a2"), new FeatureSymbol("a3")), new SymbolicFeature("b", new FeatureSymbol("b1"), new FeatureSymbol("b2"), new FeatureSymbol("b3")), - new SymbolicFeature("c", new FeatureSymbol("c1"), new FeatureSymbol("c2"), new FeatureSymbol("c3")) + new SymbolicFeature("c", new FeatureSymbol("c1"), new FeatureSymbol("c2"), new FeatureSymbol("c3")), }; featSys.Freeze(); @@ -638,7 +638,7 @@ params Func[] expectedSelectors new ComplexFeature("cx3"), new SymbolicFeature("c", new FeatureSymbol("c1"), new FeatureSymbol("c2"), new FeatureSymbol("c3")), new ComplexFeature("cx4"), - new SymbolicFeature("d", new FeatureSymbol("d1"), new FeatureSymbol("d2"), new FeatureSymbol("d3")) + new SymbolicFeature("d", new FeatureSymbol("d1"), new FeatureSymbol("d2"), new FeatureSymbol("d3")), }; featSys.Freeze(); @@ -693,7 +693,7 @@ params Func[] expectedSelectors new FeatureSymbol("a3"), new FeatureSymbol("a4") ), - new ComplexFeature("cx2") + new ComplexFeature("cx2"), }; featSys.Freeze(); @@ -808,7 +808,7 @@ params Func[] expectedSelectors new SymbolicFeature("a", new FeatureSymbol("a1"), new FeatureSymbol("a2"), new FeatureSymbol("a3")), new SymbolicFeature("b", new FeatureSymbol("b1"), new FeatureSymbol("b2"), new FeatureSymbol("b3")), new SymbolicFeature("c", new FeatureSymbol("c1"), new FeatureSymbol("c2"), new FeatureSymbol("c3")), - new ComplexFeature("cx2") + new ComplexFeature("cx2"), }; featSys.Freeze(); @@ -868,7 +868,7 @@ params Func[] expectedSelectors featSys = new FeatureSystem { new SymbolicFeature("a", new FeatureSymbol("a+", "+"), new FeatureSymbol("a-", "-")), - new SymbolicFeature("b", new FeatureSymbol("b+", "+"), new FeatureSymbol("b-", "-")) + new SymbolicFeature("b", new FeatureSymbol("b+", "+"), new FeatureSymbol("b-", "-")), }; featSys.Freeze(); @@ -1002,7 +1002,7 @@ public void BitArray() new FeatureSymbol("interj"), new FeatureSymbol("num"), new FeatureSymbol("ncp") - ) + ), }; featSys.Freeze(); // 80 values diff --git a/tests/SIL.Machine.Tests/FiniteState/FstTests.cs b/tests/SIL.Machine.Tests/FiniteState/FstTests.cs index 7838b5583..f3fc213b1 100644 --- a/tests/SIL.Machine.Tests/FiniteState/FstTests.cs +++ b/tests/SIL.Machine.Tests/FiniteState/FstTests.cs @@ -25,7 +25,7 @@ public void IsDeterminizable() new StringFeature("C"), new StringFeature("D"), new StringFeature("E"), - new StringFeature("F") + new StringFeature("F"), }; var fst = new Fst(_operations); @@ -76,7 +76,7 @@ public void Determinize() new StringFeature("C"), new StringFeature("D"), new StringFeature("E"), - new StringFeature("F") + new StringFeature("F"), }; var nfst = new Fst(_operations); @@ -220,10 +220,10 @@ public void Transduce() ); s3.Arcs.Add(null, FeatureStruct.New(PhoneticFeatSys).Symbol(Bdry).Feature("strRep").EqualTo(".").Value, s2); s3.Arcs.Add( - null, - FeatureStruct.New(PhoneticFeatSys).Symbol(Bdry).Feature("strRep").EqualTo("+").Value, - fst.CreateState() - ) + null, + FeatureStruct.New(PhoneticFeatSys).Symbol(Bdry).Feature("strRep").EqualTo("+").Value, + fst.CreateState() + ) .Arcs.Add(null, FeatureStruct.New(PhoneticFeatSys).Symbol(Bdry).Feature("strRep").EqualTo(".").Value, s2); s2.Arcs.Add(FeatureStruct.New(PhoneticFeatSys).Symbol("cons+").Value, fst.CreateAcceptingState()); diff --git a/tests/SIL.Machine.Tests/Matching/MatcherTests.cs b/tests/SIL.Machine.Tests/Matching/MatcherTests.cs index 917f2d40b..685006fd9 100644 --- a/tests/SIL.Machine.Tests/Matching/MatcherTests.cs +++ b/tests/SIL.Machine.Tests/Matching/MatcherTests.cs @@ -18,18 +18,18 @@ public void SimplePattern() .Value; var matcher = new Matcher(pattern); - Assert.IsTrue(matcher.IsMatch(sentence)); - Assert.IsTrue(matcher.IsMatch(sentence, 7)); - Assert.IsFalse(matcher.IsMatch(sentence, 29)); + Assert.That(matcher.IsMatch(sentence), Is.True); + Assert.That(matcher.IsMatch(sentence, 7), Is.True); + Assert.That(matcher.IsMatch(sentence, 29), Is.False); Match match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(0, 1))); match = matcher.Match(sentence, 7); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(10, 11))); match = matcher.Match(sentence, 29); - Assert.IsFalse(match.Success); + Assert.That(match.Success, Is.False); Match[] matches = matcher.Matches(sentence).ToArray(); Assert.That(matches.Length, Is.EqualTo(17)); @@ -73,18 +73,18 @@ public void SimplePattern() .Value; matcher = new Matcher(pattern); - Assert.IsTrue(matcher.IsMatch(sentence)); - Assert.IsTrue(matcher.IsMatch(sentence, 7)); - Assert.IsFalse(matcher.IsMatch(sentence, 29)); + Assert.That(matcher.IsMatch(sentence), Is.True); + Assert.That(matcher.IsMatch(sentence, 7), Is.True); + Assert.That(matcher.IsMatch(sentence, 29), Is.False); match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(1, 3))); match = matcher.Match(sentence, 7); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(15, 17))); match = matcher.Match(sentence, 29); - Assert.IsFalse(match.Success); + Assert.That(match.Success, Is.False); matches = matcher.Matches(sentence).ToArray(); Assert.That(matches.Length, Is.EqualTo(4)); @@ -127,18 +127,18 @@ public void AlternationPattern() .Value; var matcher = new Matcher(pattern); - Assert.IsTrue(matcher.IsMatch(sentence)); - Assert.IsTrue(matcher.IsMatch(sentence, 7)); - Assert.IsFalse(matcher.IsMatch(sentence, 29)); + Assert.That(matcher.IsMatch(sentence), Is.True); + Assert.That(matcher.IsMatch(sentence, 7), Is.True); + Assert.That(matcher.IsMatch(sentence, 29), Is.False); Match match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(1, 2))); match = matcher.Match(sentence, 7); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(8, 9))); match = matcher.Match(sentence, 29); - Assert.IsFalse(match.Success); + Assert.That(match.Success, Is.False); Match[] matches = matcher.Matches(sentence).ToArray(); Assert.That(matches.Length, Is.EqualTo(16)); @@ -187,18 +187,18 @@ public void AlternationPattern() .Value; matcher = new Matcher(pattern); - Assert.IsTrue(matcher.IsMatch(sentence)); - Assert.IsTrue(matcher.IsMatch(sentence, 7)); - Assert.IsFalse(matcher.IsMatch(sentence, 10)); + Assert.That(matcher.IsMatch(sentence), Is.True); + Assert.That(matcher.IsMatch(sentence, 7), Is.True); + Assert.That(matcher.IsMatch(sentence, 10), Is.False); match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(0, 7))); match = matcher.Match(sentence, 7); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(9, 18))); match = matcher.Match(sentence, 10); - Assert.IsFalse(match.Success); + Assert.That(match.Success, Is.False); matches = matcher.Matches(sentence).ToArray(); Assert.That(matches.Length, Is.EqualTo(2)); @@ -234,18 +234,18 @@ public void OptionalPattern() .Value; var matcher = new Matcher(pattern); - Assert.IsTrue(matcher.IsMatch(sentence)); - Assert.IsTrue(matcher.IsMatch(sentence, 7)); - Assert.IsFalse(matcher.IsMatch(sentence, 29)); + Assert.That(matcher.IsMatch(sentence), Is.True); + Assert.That(matcher.IsMatch(sentence, 7), Is.True); + Assert.That(matcher.IsMatch(sentence, 29), Is.False); Match match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(0, 3))); match = matcher.Match(sentence, 7); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(15, 17))); match = matcher.Match(sentence, 29); - Assert.IsFalse(match.Success); + Assert.That(match.Success, Is.False); Match[] matches = matcher.Matches(sentence).ToArray(); Assert.That(matches.Length, Is.EqualTo(4)); @@ -297,14 +297,14 @@ public void OptionalPattern() .Value; matcher = new Matcher(pattern); - Assert.IsTrue(matcher.IsMatch(sentence)); - Assert.IsFalse(matcher.IsMatch(sentence, 7)); + Assert.That(matcher.IsMatch(sentence), Is.True); + Assert.That(matcher.IsMatch(sentence, 7), Is.False); match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(0, 14))); match = matcher.Match(sentence, 7); - Assert.IsFalse(match.Success); + Assert.That(match.Success, Is.False); matches = matcher.Matches(sentence).ToArray(); Assert.That(matches.Length, Is.EqualTo(1)); @@ -334,14 +334,14 @@ public void OptionalPattern() .Value; matcher = new Matcher(pattern); - Assert.IsTrue(matcher.IsMatch(sentence)); - Assert.IsFalse(matcher.IsMatch(sentence, 7)); + Assert.That(matcher.IsMatch(sentence), Is.True); + Assert.That(matcher.IsMatch(sentence, 7), Is.False); match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(0, 7))); match = matcher.Match(sentence, 7); - Assert.IsFalse(match.Success); + Assert.That(match.Success, Is.False); matches = matcher.Matches(sentence).ToArray(); Assert.That(matches.Length, Is.EqualTo(1)); @@ -370,18 +370,18 @@ public void ZeroOrMorePattern() .ZeroOrMore.Value; var matcher = new Matcher(pattern); - Assert.IsTrue(matcher.IsMatch(sentence)); - Assert.IsTrue(matcher.IsMatch(sentence, 7)); - Assert.IsFalse(matcher.IsMatch(sentence, 29)); + Assert.That(matcher.IsMatch(sentence), Is.True); + Assert.That(matcher.IsMatch(sentence, 7), Is.True); + Assert.That(matcher.IsMatch(sentence, 29), Is.False); Match match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(0, 3))); match = matcher.Match(sentence, 7); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(9, 14))); match = matcher.Match(sentence, 29); - Assert.IsFalse(match.Success); + Assert.That(match.Success, Is.False); Match[] matches = matcher.Matches(sentence).ToArray(); Assert.That(matches.Length, Is.EqualTo(6)); @@ -433,18 +433,18 @@ public void ZeroOrMorePattern() .LazyZeroOrMore.Value; matcher = new Matcher(pattern); - Assert.IsTrue(matcher.IsMatch(sentence)); - Assert.IsTrue(matcher.IsMatch(sentence, 7)); - Assert.IsFalse(matcher.IsMatch(sentence, 29)); + Assert.That(matcher.IsMatch(sentence), Is.True); + Assert.That(matcher.IsMatch(sentence, 7), Is.True); + Assert.That(matcher.IsMatch(sentence, 29), Is.False); match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(0, 3))); match = matcher.Match(sentence, 7); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(9, 10))); match = matcher.Match(sentence, 29); - Assert.IsFalse(match.Success); + Assert.That(match.Success, Is.False); matches = matcher.Matches(sentence).ToArray(); Assert.That(matches.Length, Is.EqualTo(6)); @@ -492,18 +492,18 @@ public void OneOrMorePattern() .OneOrMore.Value; var matcher = new Matcher(pattern); - Assert.IsTrue(matcher.IsMatch(sentence)); - Assert.IsTrue(matcher.IsMatch(sentence, 7)); - Assert.IsFalse(matcher.IsMatch(sentence, 29)); + Assert.That(matcher.IsMatch(sentence), Is.True); + Assert.That(matcher.IsMatch(sentence, 7), Is.True); + Assert.That(matcher.IsMatch(sentence, 29), Is.False); Match match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(15, 18))); match = matcher.Match(sentence, 16); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(19, 24))); match = matcher.Match(sentence, 29); - Assert.IsFalse(match.Success); + Assert.That(match.Success, Is.False); Match[] matches = matcher.Matches(sentence).ToArray(); Assert.That(matches.Length, Is.EqualTo(3)); @@ -554,18 +554,18 @@ public void OneOrMorePattern() .LazyOneOrMore.Value; matcher = new Matcher(pattern); - Assert.IsTrue(matcher.IsMatch(sentence)); - Assert.IsTrue(matcher.IsMatch(sentence, 7)); - Assert.IsFalse(matcher.IsMatch(sentence, 29)); + Assert.That(matcher.IsMatch(sentence), Is.True); + Assert.That(matcher.IsMatch(sentence, 7), Is.True); + Assert.That(matcher.IsMatch(sentence, 29), Is.False); match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(15, 18))); match = matcher.Match(sentence, 16); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(19, 23))); match = matcher.Match(sentence, 29); - Assert.IsFalse(match.Success); + Assert.That(match.Success, Is.False); matches = matcher.Matches(sentence).ToArray(); Assert.That(matches.Length, Is.EqualTo(3)); @@ -613,18 +613,18 @@ public void RangePattern() .Value; var matcher = new Matcher(pattern); - Assert.IsTrue(matcher.IsMatch(sentence)); - Assert.IsTrue(matcher.IsMatch(sentence, 7)); - Assert.IsFalse(matcher.IsMatch(sentence, 29)); + Assert.That(matcher.IsMatch(sentence), Is.True); + Assert.That(matcher.IsMatch(sentence, 7), Is.True); + Assert.That(matcher.IsMatch(sentence, 29), Is.False); Match match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(0, 3))); match = matcher.Match(sentence, 7); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(9, 12))); match = matcher.Match(sentence, 29); - Assert.IsFalse(match.Success); + Assert.That(match.Success, Is.False); Match[] matches = matcher.Matches(sentence).ToArray(); Assert.That(matches.Length, Is.EqualTo(9)); @@ -676,18 +676,18 @@ public void RangePattern() .Value; matcher = new Matcher(pattern); - Assert.IsTrue(matcher.IsMatch(sentence)); - Assert.IsTrue(matcher.IsMatch(sentence, 7)); - Assert.IsFalse(matcher.IsMatch(sentence, 29)); + Assert.That(matcher.IsMatch(sentence), Is.True); + Assert.That(matcher.IsMatch(sentence, 7), Is.True); + Assert.That(matcher.IsMatch(sentence, 29), Is.False); match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(0, 3))); match = matcher.Match(sentence, 7); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(9, 13))); match = matcher.Match(sentence, 29); - Assert.IsFalse(match.Success); + Assert.That(match.Success, Is.False); matches = matcher.Matches(sentence).ToArray(); Assert.That(matches.Length, Is.EqualTo(6)); @@ -729,18 +729,18 @@ public void RangePattern() .Value; matcher = new Matcher(pattern); - Assert.IsTrue(matcher.IsMatch(sentence)); - Assert.IsTrue(matcher.IsMatch(sentence, 7)); - Assert.IsFalse(matcher.IsMatch(sentence, 29)); + Assert.That(matcher.IsMatch(sentence), Is.True); + Assert.That(matcher.IsMatch(sentence, 7), Is.True); + Assert.That(matcher.IsMatch(sentence, 29), Is.False); match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(0, 2))); match = matcher.Match(sentence, 7); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(9, 11))); match = matcher.Match(sentence, 29); - Assert.IsFalse(match.Success); + Assert.That(match.Success, Is.False); matches = matcher.Matches(sentence).ToArray(); Assert.That(matches.Length, Is.EqualTo(9)); @@ -795,47 +795,47 @@ public void CapturingGroupPattern() .Value; var matcher = new Matcher(pattern); - Assert.IsTrue(matcher.IsMatch(sentence)); - Assert.IsTrue(matcher.IsMatch(sentence, 7)); - Assert.IsFalse(matcher.IsMatch(sentence, 29)); + Assert.That(matcher.IsMatch(sentence), Is.True); + Assert.That(matcher.IsMatch(sentence, 7), Is.True); + Assert.That(matcher.IsMatch(sentence, 29), Is.False); Match match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(0, 3))); - Assert.IsTrue(match.GroupCaptures["onset"].Success); + Assert.That(match.GroupCaptures["onset"].Success, Is.True); Assert.That(match.GroupCaptures["onset"].Range, Is.EqualTo(Range.Create(0, 2))); - Assert.IsFalse(match.GroupCaptures["coda"].Success); + Assert.That(match.GroupCaptures["coda"].Success, Is.False); match = matcher.Match(sentence, 7); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(9, 14))); - Assert.IsFalse(match.GroupCaptures["onset"].Success); - Assert.IsTrue(match.GroupCaptures["coda"].Success); + Assert.That(match.GroupCaptures["onset"].Success, Is.False); + Assert.That(match.GroupCaptures["coda"].Success, Is.True); Assert.That(match.GroupCaptures["coda"].Range, Is.EqualTo(Range.Create(10, 14))); match = matcher.Match(sentence, 29); - Assert.IsFalse(match.Success); + Assert.That(match.Success, Is.False); Match[] matches = matcher.Matches(sentence).ToArray(); Assert.That(matches.Length, Is.EqualTo(6)); Assert.That(matches[0].Range, Is.EqualTo(Range.Create(0, 3))); Assert.That(matches[1].Range, Is.EqualTo(Range.Create(4, 7))); - Assert.IsFalse(matches[1].GroupCaptures["onset"].Success); - Assert.IsTrue(matches[1].GroupCaptures["coda"].Success); + Assert.That(matches[1].GroupCaptures["onset"].Success, Is.False); + Assert.That(matches[1].GroupCaptures["coda"].Success, Is.True); Assert.That(matches[1].GroupCaptures["coda"].Range, Is.EqualTo(Range.Create(5, 7))); Assert.That(matches[5].Range, Is.EqualTo(Range.Create(25, 29))); - Assert.IsTrue(matches[5].GroupCaptures["onset"].Success); + Assert.That(matches[5].GroupCaptures["onset"].Success, Is.True); Assert.That(matches[5].GroupCaptures["onset"].Range, Is.EqualTo(Range.Create(25, 26))); - Assert.IsTrue(matches[5].GroupCaptures["coda"].Success); + Assert.That(matches[5].GroupCaptures["coda"].Success, Is.True); Assert.That(matches[5].GroupCaptures["coda"].Range, Is.EqualTo(Range.Create(27, 29))); matches = matcher.Matches(sentence, 7).ToArray(); Assert.That(matches.Length, Is.EqualTo(4)); Assert.That(matches[0].Range, Is.EqualTo(Range.Create(9, 14))); - Assert.IsFalse(matches[0].GroupCaptures["onset"].Success); - Assert.IsTrue(matches[0].GroupCaptures["coda"].Success); + Assert.That(matches[0].GroupCaptures["onset"].Success, Is.False); + Assert.That(matches[0].GroupCaptures["coda"].Success, Is.True); Assert.That(matches[0].GroupCaptures["coda"].Range, Is.EqualTo(Range.Create(10, 14))); Assert.That(matches[1].Range, Is.EqualTo(Range.Create(15, 18))); - Assert.IsTrue(matches[1].GroupCaptures["onset"].Success); + Assert.That(matches[1].GroupCaptures["onset"].Success, Is.True); Assert.That(matches[1].GroupCaptures["onset"].Range, Is.EqualTo(Range.Create(15, 16))); - Assert.IsTrue(matches[1].GroupCaptures["coda"].Success); + Assert.That(matches[1].GroupCaptures["coda"].Success, Is.True); Assert.That(matches[1].GroupCaptures["coda"].Range, Is.EqualTo(Range.Create(17, 18))); Assert.That(matches[3].Range, Is.EqualTo(Range.Create(25, 29))); matches = matcher.Matches(sentence, 29).ToArray(); @@ -844,13 +844,13 @@ public void CapturingGroupPattern() matches = matcher.AllMatches(sentence).ToArray(); Assert.That(matches.Length, Is.EqualTo(30)); Assert.That(matches[0].Range, Is.EqualTo(Range.Create(0, 3))); - Assert.IsTrue(matches[0].GroupCaptures["onset"].Success); + Assert.That(matches[0].GroupCaptures["onset"].Success, Is.True); Assert.That(matches[0].GroupCaptures["onset"].Range, Is.EqualTo(Range.Create(0, 2))); - Assert.IsFalse(matches[0].GroupCaptures["coda"].Success); + Assert.That(matches[0].GroupCaptures["coda"].Success, Is.False); Assert.That(matches[1].Range, Is.EqualTo(Range.Create(1, 3))); - Assert.IsTrue(matches[1].GroupCaptures["onset"].Success); + Assert.That(matches[1].GroupCaptures["onset"].Success, Is.True); Assert.That(matches[1].GroupCaptures["onset"].Range, Is.EqualTo(Range.Create(1, 2))); - Assert.IsFalse(matches[1].GroupCaptures["coda"].Success); + Assert.That(matches[1].GroupCaptures["coda"].Success, Is.False); Assert.That(matches[2].Range, Is.EqualTo(Range.Create(2, 3))); Assert.That(matches[3].Range, Is.EqualTo(Range.Create(4, 7))); Assert.That(matches[4].Range, Is.EqualTo(Range.Create(4, 6))); @@ -860,12 +860,12 @@ public void CapturingGroupPattern() matches = matcher.AllMatches(sentence, 7).ToArray(); Assert.That(matches.Length, Is.EqualTo(24)); Assert.That(matches[0].Range, Is.EqualTo(Range.Create(9, 14))); - Assert.IsFalse(matches[0].GroupCaptures["onset"].Success); - Assert.IsTrue(matches[0].GroupCaptures["coda"].Success); + Assert.That(matches[0].GroupCaptures["onset"].Success, Is.False); + Assert.That(matches[0].GroupCaptures["coda"].Success, Is.True); Assert.That(matches[0].GroupCaptures["coda"].Range, Is.EqualTo(Range.Create(10, 14))); Assert.That(matches[1].Range, Is.EqualTo(Range.Create(9, 13))); - Assert.IsFalse(matches[1].GroupCaptures["onset"].Success); - Assert.IsTrue(matches[1].GroupCaptures["coda"].Success); + Assert.That(matches[1].GroupCaptures["onset"].Success, Is.False); + Assert.That(matches[1].GroupCaptures["coda"].Success, Is.True); Assert.That(matches[1].GroupCaptures["coda"].Range, Is.EqualTo(Range.Create(10, 13))); Assert.That(matches[2].Range, Is.EqualTo(Range.Create(9, 12))); Assert.That(matches[11].Range, Is.EqualTo(Range.Create(19, 22))); @@ -886,10 +886,10 @@ public void CapturingGroupPattern() "NP", np => np.Group(det => - det.Annotation(FeatureStruct.New(WordFeatSys).Symbol(Word).Symbol("det").Value) - .Annotation(FeatureStruct.New(PhoneticFeatSys).Symbol(Bdry).Value) - .OneOrMore - ) + det.Annotation(FeatureStruct.New(WordFeatSys).Symbol(Word).Symbol("det").Value) + .Annotation(FeatureStruct.New(PhoneticFeatSys).Symbol(Bdry).Value) + .OneOrMore + ) .Optional.Group(adj => adj.Annotation(FeatureStruct.New(WordFeatSys).Symbol(Word).Symbol("adj").Value) .Annotation(FeatureStruct.New(PhoneticFeatSys).Symbol(Bdry).Value) @@ -919,34 +919,34 @@ public void CapturingGroupPattern() .Value; matcher = new Matcher(pattern); - Assert.IsTrue(matcher.IsMatch(sentence)); - Assert.IsTrue(matcher.IsMatch(sentence, 7)); - Assert.IsFalse(matcher.IsMatch(sentence, 16)); + Assert.That(matcher.IsMatch(sentence), Is.True); + Assert.That(matcher.IsMatch(sentence, 7), Is.True); + Assert.That(matcher.IsMatch(sentence, 16), Is.False); match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(0, 29))); - Assert.IsTrue(match.GroupCaptures["NP"].Success); + Assert.That(match.GroupCaptures["NP"].Success, Is.True); Assert.That(match.GroupCaptures["NP"].Range, Is.EqualTo(Range.Create(0, 18))); - Assert.IsTrue(match.GroupCaptures["headNoun"].Success); + Assert.That(match.GroupCaptures["headNoun"].Success, Is.True); Assert.That(match.GroupCaptures["headNoun"].Range, Is.EqualTo(Range.Create(15, 18))); - Assert.IsTrue(match.GroupCaptures["VP"].Success); + Assert.That(match.GroupCaptures["VP"].Success, Is.True); Assert.That(match.GroupCaptures["VP"].Range, Is.EqualTo(Range.Create(19, 29))); - Assert.IsTrue(match.GroupCaptures["headVerb"].Success); + Assert.That(match.GroupCaptures["headVerb"].Success, Is.True); Assert.That(match.GroupCaptures["headVerb"].Range, Is.EqualTo(Range.Create(19, 24))); match = matcher.Match(sentence, 7); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(9, 29))); - Assert.IsTrue(match.GroupCaptures["NP"].Success); + Assert.That(match.GroupCaptures["NP"].Success, Is.True); Assert.That(match.GroupCaptures["NP"].Range, Is.EqualTo(Range.Create(9, 18))); - Assert.IsTrue(match.GroupCaptures["headNoun"].Success); + Assert.That(match.GroupCaptures["headNoun"].Success, Is.True); Assert.That(match.GroupCaptures["headNoun"].Range, Is.EqualTo(Range.Create(15, 18))); - Assert.IsTrue(match.GroupCaptures["VP"].Success); + Assert.That(match.GroupCaptures["VP"].Success, Is.True); Assert.That(match.GroupCaptures["VP"].Range, Is.EqualTo(Range.Create(19, 29))); - Assert.IsTrue(match.GroupCaptures["headVerb"].Success); + Assert.That(match.GroupCaptures["headVerb"].Success, Is.True); Assert.That(match.GroupCaptures["headVerb"].Range, Is.EqualTo(Range.Create(19, 24))); match = matcher.Match(sentence, 16); - Assert.IsFalse(match.Success); + Assert.That(match.Success, Is.False); matches = matcher.Matches(sentence).ToArray(); Assert.That(matches.Length, Is.EqualTo(1)); @@ -958,22 +958,22 @@ public void CapturingGroupPattern() matches = matcher.AllMatches(sentence).ToArray(); Assert.That(matches.Length, Is.EqualTo(8)); Assert.That(matches[1].Range, Is.EqualTo(Range.Create(0, 24))); - Assert.IsTrue(matches[1].GroupCaptures["NP"].Success); + Assert.That(matches[1].GroupCaptures["NP"].Success, Is.True); Assert.That(matches[1].GroupCaptures["NP"].Range, Is.EqualTo(Range.Create(0, 18))); - Assert.IsTrue(matches[1].GroupCaptures["headNoun"].Success); + Assert.That(matches[1].GroupCaptures["headNoun"].Success, Is.True); Assert.That(matches[1].GroupCaptures["headNoun"].Range, Is.EqualTo(Range.Create(15, 18))); - Assert.IsTrue(matches[1].GroupCaptures["VP"].Success); + Assert.That(matches[1].GroupCaptures["VP"].Success, Is.True); Assert.That(matches[1].GroupCaptures["VP"].Range, Is.EqualTo(Range.Create(19, 24))); - Assert.IsTrue(matches[1].GroupCaptures["headVerb"].Success); + Assert.That(matches[1].GroupCaptures["headVerb"].Success, Is.True); Assert.That(matches[1].GroupCaptures["headVerb"].Range, Is.EqualTo(Range.Create(19, 24))); Assert.That(matches[7].Range, Is.EqualTo(Range.Create(15, 24))); - Assert.IsTrue(matches[7].GroupCaptures["NP"].Success); + Assert.That(matches[7].GroupCaptures["NP"].Success, Is.True); Assert.That(matches[7].GroupCaptures["NP"].Range, Is.EqualTo(Range.Create(15, 18))); - Assert.IsTrue(matches[7].GroupCaptures["headNoun"].Success); + Assert.That(matches[7].GroupCaptures["headNoun"].Success, Is.True); Assert.That(matches[7].GroupCaptures["headNoun"].Range, Is.EqualTo(Range.Create(15, 18))); - Assert.IsTrue(matches[7].GroupCaptures["VP"].Success); + Assert.That(matches[7].GroupCaptures["VP"].Success, Is.True); Assert.That(matches[7].GroupCaptures["VP"].Range, Is.EqualTo(Range.Create(19, 24))); - Assert.IsTrue(matches[7].GroupCaptures["headVerb"].Success); + Assert.That(matches[7].GroupCaptures["headVerb"].Success, Is.True); Assert.That(matches[7].GroupCaptures["headVerb"].Range, Is.EqualTo(Range.Create(19, 24))); matches = matcher.AllMatches(sentence, 7).ToArray(); Assert.That(matches.Length, Is.EqualTo(4)); @@ -1009,20 +1009,20 @@ public void Subpattern() .Value; var matcher = new Matcher(pattern); - Assert.IsTrue(matcher.IsMatch(sentence)); - Assert.IsTrue(matcher.IsMatch(sentence, 19)); - Assert.IsFalse(matcher.IsMatch(sentence, 29)); + Assert.That(matcher.IsMatch(sentence), Is.True); + Assert.That(matcher.IsMatch(sentence, 19), Is.True); + Assert.That(matcher.IsMatch(sentence, 29), Is.False); Match match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(0, 3))); Assert.That(match.PatternPath[0], Is.EqualTo("unvoiceInitial")); match = matcher.Match(sentence, 19); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(19, 22))); Assert.That(match.PatternPath[0], Is.EqualTo("unvoiceInitial")); match = matcher.Match(sentence, 29); - Assert.IsFalse(match.Success); + Assert.That(match.Success, Is.False); Match[] matches = matcher.Matches(sentence).ToArray(); Assert.That(matches.Length, Is.EqualTo(6)); @@ -1107,22 +1107,22 @@ public void MatcherSettings() .Value; var matcher = new Matcher(pattern); - Assert.IsFalse(matcher.IsMatch(sentence)); + Assert.That(matcher.IsMatch(sentence), Is.False); matcher = new Matcher( pattern, new MatcherSettings { Filter = ann => ((FeatureSymbol)ann.FeatureStruct.GetValue(Type)) == Word } ); Match match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(0, 29))); - Assert.IsTrue(match.GroupCaptures["NP"].Success); + Assert.That(match.GroupCaptures["NP"].Success, Is.True); Assert.That(match.GroupCaptures["NP"].Range, Is.EqualTo(Range.Create(0, 18))); - Assert.IsTrue(match.GroupCaptures["headNoun"].Success); + Assert.That(match.GroupCaptures["headNoun"].Success, Is.True); Assert.That(match.GroupCaptures["headNoun"].Range, Is.EqualTo(Range.Create(15, 18))); - Assert.IsTrue(match.GroupCaptures["VP"].Success); + Assert.That(match.GroupCaptures["VP"].Success, Is.True); Assert.That(match.GroupCaptures["VP"].Range, Is.EqualTo(Range.Create(19, 29))); - Assert.IsTrue(match.GroupCaptures["headVerb"].Success); + Assert.That(match.GroupCaptures["headVerb"].Success, Is.True); Assert.That(match.GroupCaptures["headVerb"].Range, Is.EqualTo(Range.Create(19, 24))); pattern = Pattern @@ -1131,10 +1131,10 @@ public void MatcherSettings() "NP", np => np.Group(det => - det.Annotation(FeatureStruct.New(WordFeatSys).Symbol(Word).Symbol("det").Value) - .Annotation(FeatureStruct.New(PhoneticFeatSys).Symbol(Bdry).Value) - .OneOrMore - ) + det.Annotation(FeatureStruct.New(WordFeatSys).Symbol(Word).Symbol("det").Value) + .Annotation(FeatureStruct.New(PhoneticFeatSys).Symbol(Bdry).Value) + .OneOrMore + ) .Optional.Group(adj => adj.Annotation(FeatureStruct.New(WordFeatSys).Symbol(Word).Symbol("adj").Value) .Annotation(FeatureStruct.New(PhoneticFeatSys).Symbol(Bdry).Value) @@ -1165,15 +1165,15 @@ public void MatcherSettings() matcher = new Matcher(pattern, new MatcherSettings { Nondeterministic = true }); match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(0, 29))); - Assert.IsTrue(match.GroupCaptures["NP"].Success); + Assert.That(match.GroupCaptures["NP"].Success, Is.True); Assert.That(match.GroupCaptures["NP"].Range, Is.EqualTo(Range.Create(0, 18))); - Assert.IsTrue(match.GroupCaptures["headNoun"].Success); + Assert.That(match.GroupCaptures["headNoun"].Success, Is.True); Assert.That(match.GroupCaptures["headNoun"].Range, Is.EqualTo(Range.Create(15, 18))); - Assert.IsTrue(match.GroupCaptures["VP"].Success); + Assert.That(match.GroupCaptures["VP"].Success, Is.True); Assert.That(match.GroupCaptures["VP"].Range, Is.EqualTo(Range.Create(19, 29))); - Assert.IsTrue(match.GroupCaptures["headVerb"].Success); + Assert.That(match.GroupCaptures["headVerb"].Success, Is.True); Assert.That(match.GroupCaptures["headVerb"].Range, Is.EqualTo(Range.Create(19, 24))); pattern = Pattern @@ -1192,7 +1192,7 @@ public void MatcherSettings() new MatcherSettings { Filter = ann => ((FeatureSymbol)ann.FeatureStruct.GetValue(Type)) == Word } ); match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(0, 3))); matcher = new Matcher( @@ -1200,11 +1200,11 @@ public void MatcherSettings() new MatcherSettings { Filter = ann => ((FeatureSymbol)ann.FeatureStruct.GetValue(Type)) == Word, - Direction = Direction.RightToLeft + Direction = Direction.RightToLeft, } ); match = matcher.Match(sentence); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(match.Range, Is.EqualTo(Range.Create(9, 29))); pattern = Pattern @@ -1218,7 +1218,7 @@ public void MatcherSettings() new MatcherSettings { Filter = ann => ((FeatureSymbol)ann.FeatureStruct.GetValue(Type)) != Word, - MatchingMethod = MatchingMethod.Unification + MatchingMethod = MatchingMethod.Unification, } ); Match[] matches = matcher.Matches(sentence).ToArray(); @@ -1230,7 +1230,7 @@ public void MatcherSettings() { Filter = ann => ((FeatureSymbol)ann.FeatureStruct.GetValue(Type)) != Word, UseDefaults = true, - MatchingMethod = MatchingMethod.Unification + MatchingMethod = MatchingMethod.Unification, } ); matches = matcher.Matches(sentence).ToArray(); @@ -1295,12 +1295,12 @@ public void VariablePattern() AnnotatedStringData word = CreateStringData("fazk"); var matcher = new Matcher(pattern); Match match = matcher.Match(word); - Assert.IsTrue(match.Success); + Assert.That(match.Success, Is.True); Assert.That(((FeatureSymbol)match.VariableBindings["a"]).ID, Is.EqualTo("voice-")); word = CreateStringData("dazk"); match = matcher.Match(word); - Assert.IsFalse(match.Success); + Assert.That(match.Success, Is.False); } [Test] @@ -1320,7 +1320,7 @@ public void NondeterministicPattern() { AnchoredToStart = true, AnchoredToEnd = true, - AllSubmatches = true + AllSubmatches = true, } ); var word = new AnnotatedStringData("test"); @@ -1358,7 +1358,7 @@ public void NondeterministicPattern() { AnchoredToStart = true, AnchoredToEnd = true, - AllSubmatches = true + AllSubmatches = true, } ); @@ -1392,7 +1392,7 @@ public void NondeterministicPattern() { AnchoredToStart = true, AnchoredToEnd = true, - AllSubmatches = true + AllSubmatches = true, } ); diff --git a/tests/SIL.Machine.Tests/Morphology/PoorMansAffixIdentifierTests.cs b/tests/SIL.Machine.Tests/Morphology/PoorMansAffixIdentifierTests.cs index 5ec6a0231..278d6326d 100644 --- a/tests/SIL.Machine.Tests/Morphology/PoorMansAffixIdentifierTests.cs +++ b/tests/SIL.Machine.Tests/Morphology/PoorMansAffixIdentifierTests.cs @@ -129,7 +129,7 @@ public void IdentifyPrefixes() "remote", "asleep", "crazy", - "stupid" + "stupid", }; var affixIdentifier = new PoorMansAffixIdentifier(w => w); diff --git a/tests/SIL.Machine.Tests/Morphology/PoorMansStemmerTests.cs b/tests/SIL.Machine.Tests/Morphology/PoorMansStemmerTests.cs index e4e9fb654..e53a17ef7 100644 --- a/tests/SIL.Machine.Tests/Morphology/PoorMansStemmerTests.cs +++ b/tests/SIL.Machine.Tests/Morphology/PoorMansStemmerTests.cs @@ -99,7 +99,7 @@ public void HaveSameStem() "allow", "joke", "murder", - "suck" + "suck", }; var stemmer = new PoorMansStemmer(s => s) { NormalizeScores = true, Threshold = 0.05 }; @@ -138,7 +138,7 @@ public void LargeEnglishWordList() { NormalizeScores = true, Threshold = 0.03, - MaxAffixLength = 5 + MaxAffixLength = 5, }; stemmer.Train(words); diff --git a/tests/SIL.Machine.Tests/PhoneticTestsBase.cs b/tests/SIL.Machine.Tests/PhoneticTestsBase.cs index 790a32c1f..ee7d9d806 100644 --- a/tests/SIL.Machine.Tests/PhoneticTestsBase.cs +++ b/tests/SIL.Machine.Tests/PhoneticTestsBase.cs @@ -32,7 +32,7 @@ public virtual void FixtureSetUp() new FeatureSymbol("son?", "?") ) { - DefaultSymbolID = "son?" + DefaultSymbolID = "son?", }, new SymbolicFeature( "syl", @@ -41,7 +41,7 @@ public virtual void FixtureSetUp() new FeatureSymbol("syl?", "?") ) { - DefaultSymbolID = "syl?" + DefaultSymbolID = "syl?", }, new SymbolicFeature( "cons", @@ -50,7 +50,7 @@ public virtual void FixtureSetUp() new FeatureSymbol("cons?", "?") ) { - DefaultSymbolID = "cons?" + DefaultSymbolID = "cons?", }, new SymbolicFeature( "high", @@ -59,7 +59,7 @@ public virtual void FixtureSetUp() new FeatureSymbol("high?", "?") ) { - DefaultSymbolID = "high?" + DefaultSymbolID = "high?", }, new SymbolicFeature( "back", @@ -68,7 +68,7 @@ public virtual void FixtureSetUp() new FeatureSymbol("back?", "?") ) { - DefaultSymbolID = "back?" + DefaultSymbolID = "back?", }, new SymbolicFeature( "front", @@ -77,7 +77,7 @@ public virtual void FixtureSetUp() new FeatureSymbol("front?", "?") ) { - DefaultSymbolID = "front?" + DefaultSymbolID = "front?", }, new SymbolicFeature( "low", @@ -86,7 +86,7 @@ public virtual void FixtureSetUp() new FeatureSymbol("low?", "?") ) { - DefaultSymbolID = "low?" + DefaultSymbolID = "low?", }, new SymbolicFeature( "rnd", @@ -95,7 +95,7 @@ public virtual void FixtureSetUp() new FeatureSymbol("rnd?", "?") ) { - DefaultSymbolID = "rnd?" + DefaultSymbolID = "rnd?", }, new SymbolicFeature( "ant", @@ -104,7 +104,7 @@ public virtual void FixtureSetUp() new FeatureSymbol("ant?", "?") ) { - DefaultSymbolID = "ant?" + DefaultSymbolID = "ant?", }, new SymbolicFeature( "cor", @@ -113,7 +113,7 @@ public virtual void FixtureSetUp() new FeatureSymbol("cor?", "?") ) { - DefaultSymbolID = "cor?" + DefaultSymbolID = "cor?", }, new SymbolicFeature( "voice", @@ -122,7 +122,7 @@ public virtual void FixtureSetUp() new FeatureSymbol("voice?", "?") ) { - DefaultSymbolID = "voice?" + DefaultSymbolID = "voice?", }, new SymbolicFeature( "cont", @@ -131,7 +131,7 @@ public virtual void FixtureSetUp() new FeatureSymbol("cont?", "?") ) { - DefaultSymbolID = "cont?" + DefaultSymbolID = "cont?", }, new SymbolicFeature( "nas", @@ -140,7 +140,7 @@ public virtual void FixtureSetUp() new FeatureSymbol("nas?", "?") ) { - DefaultSymbolID = "nas?" + DefaultSymbolID = "nas?", }, new SymbolicFeature( "str", @@ -149,9 +149,9 @@ public virtual void FixtureSetUp() new FeatureSymbol("str?", "?") ) { - DefaultSymbolID = "str?" + DefaultSymbolID = "str?", }, - new StringFeature("strRep") + new StringFeature("strRep"), }; WordFeatSys = new FeatureSystem @@ -163,7 +163,7 @@ public virtual void FixtureSetUp() new FeatureSymbol("adj"), new FeatureSymbol("adv"), new FeatureSymbol("det") - ) + ), }; Word = new FeatureSymbol("Word"); @@ -645,7 +645,7 @@ public virtual void FixtureSetUp() { ',', FeatureStruct.New(PhoneticFeatSys).Symbol(Bdry).Feature("strRep").EqualTo(",").Value }, { ' ', FeatureStruct.New(PhoneticFeatSys).Symbol(Bdry).Feature("strRep").EqualTo(" ").Value }, { '.', FeatureStruct.New(PhoneticFeatSys).Symbol(Bdry).Feature("strRep").EqualTo(".").Value }, - { '0', FeatureStruct.New(PhoneticFeatSys).Symbol(Bdry).Feature("strRep").EqualTo("0").Value } + { '0', FeatureStruct.New(PhoneticFeatSys).Symbol(Bdry).Feature("strRep").EqualTo("0").Value }, }; } diff --git a/tests/SIL.Machine.Tests/PunctuationAnalysis/DepthBasedQuotationMarkResolverTests.cs b/tests/SIL.Machine.Tests/PunctuationAnalysis/DepthBasedQuotationMarkResolverTests.cs index 3576ed95f..61156777b 100644 --- a/tests/SIL.Machine.Tests/PunctuationAnalysis/DepthBasedQuotationMarkResolverTests.cs +++ b/tests/SIL.Machine.Tests/PunctuationAnalysis/DepthBasedQuotationMarkResolverTests.cs @@ -36,59 +36,59 @@ public void CurrentDepthQuotationMarkResolverState() public void HasOpenQuotationMark() { var state = new QuotationMarkResolverState(); - Assert.IsFalse(state.HasOpenQuotationMark); + Assert.That(state.HasOpenQuotationMark, Is.False); state.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) ); - Assert.IsTrue(state.HasOpenQuotationMark); + Assert.That(state.HasOpenQuotationMark, Is.True); state.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018").Build(), 0, 1) ); - Assert.IsTrue(state.HasOpenQuotationMark); + Assert.That(state.HasOpenQuotationMark, Is.True); state.AddClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019").Build(), 0, 1) ); - Assert.IsTrue(state.HasOpenQuotationMark); + Assert.That(state.HasOpenQuotationMark, Is.True); state.AddClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) ); - Assert.IsFalse(state.HasOpenQuotationMark); + Assert.That(state.HasOpenQuotationMark, Is.False); } [Test] public void AreMoreThanNQuotesOpen() { var state = new QuotationMarkResolverState(); - Assert.IsFalse(state.AreMoreThanNQuotesOpen(1)); - Assert.IsFalse(state.AreMoreThanNQuotesOpen(2)); + Assert.That(state.AreMoreThanNQuotesOpen(1), Is.False); + Assert.That(state.AreMoreThanNQuotesOpen(2), Is.False); state.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) ); - Assert.IsFalse(state.AreMoreThanNQuotesOpen(1)); - Assert.IsFalse(state.AreMoreThanNQuotesOpen(2)); + Assert.That(state.AreMoreThanNQuotesOpen(1), Is.False); + Assert.That(state.AreMoreThanNQuotesOpen(2), Is.False); state.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018").Build(), 0, 1) ); - Assert.IsTrue(state.AreMoreThanNQuotesOpen(1)); - Assert.IsFalse(state.AreMoreThanNQuotesOpen(2)); + Assert.That(state.AreMoreThanNQuotesOpen(1), Is.True); + Assert.That(state.AreMoreThanNQuotesOpen(2), Is.False); state.AddClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019").Build(), 0, 1) ); - Assert.IsFalse(state.AreMoreThanNQuotesOpen(1)); - Assert.IsFalse(state.AreMoreThanNQuotesOpen(2)); + Assert.That(state.AreMoreThanNQuotesOpen(1), Is.False); + Assert.That(state.AreMoreThanNQuotesOpen(2), Is.False); state.AddClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) ); - Assert.IsFalse(state.AreMoreThanNQuotesOpen(1)); - Assert.IsFalse(state.AreMoreThanNQuotesOpen(2)); + Assert.That(state.AreMoreThanNQuotesOpen(1), Is.False); + Assert.That(state.AreMoreThanNQuotesOpen(2), Is.False); } [Test] @@ -202,28 +202,28 @@ public void HasContinuerBeenObserved() ); var continuerState = new TestQuoteContinuerState(); - Assert.IsFalse(continuerState.ContinuerHasBeenObserved()); + Assert.That(continuerState.ContinuerHasBeenObserved(), Is.False); continuerState.AddQuoteContinuer( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1), resolverState, QuoteContinuerStyle.English ); - Assert.IsTrue(continuerState.ContinuerHasBeenObserved()); + Assert.That(continuerState.ContinuerHasBeenObserved(), Is.True); continuerState.AddQuoteContinuer( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018").Build(), 0, 1), resolverState, QuoteContinuerStyle.English ); - Assert.IsTrue(continuerState.ContinuerHasBeenObserved()); + Assert.That(continuerState.ContinuerHasBeenObserved(), Is.True); continuerState.AddQuoteContinuer( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1), resolverState, QuoteContinuerStyle.English ); - Assert.IsFalse(continuerState.ContinuerHasBeenObserved()); + Assert.That(continuerState.ContinuerHasBeenObserved(), Is.False); } [Test] @@ -344,7 +344,7 @@ public void AddQuotationContinuer() public void IsEnglishQuotationContinuer() { QuoteConvention standardEnglish = QuoteConventions.Standard.GetQuoteConventionByName("standard_english"); - Assert.IsNotNull(standardEnglish); + Assert.That(standardEnglish, Is.Not.Null); var settings = new QuoteConventionDetectionResolutionSettings(new QuoteConventionSet([standardEnglish])); var resolverState = new QuotationMarkResolverState(); @@ -357,7 +357,7 @@ public void IsEnglishQuotationContinuer() // Should always be false if the continuer style is Spanish continuerState.InternalContinuerStyle = QuoteContinuerStyle.English; - Assert.IsTrue( + Assert.That( categorizer.IsEnglishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -369,11 +369,12 @@ public void IsEnglishQuotationContinuer() ), null, null - ) + ), + Is.True ); continuerState.InternalContinuerStyle = QuoteContinuerStyle.Spanish; - Assert.IsFalse( + Assert.That( categorizer.IsEnglishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -385,20 +386,22 @@ public void IsEnglishQuotationContinuer() ), null, null - ) + ), + Is.False ); continuerState.InternalContinuerStyle = QuoteContinuerStyle.English; // Should be false if there's no preceding paragraph marker (and the settings say to rely on markers) - Assert.IsFalse( + Assert.That( categorizer.IsEnglishQuoteContinuer( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201ctest").Build(), 0, 1), null, null - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( categorizer.IsEnglishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -410,7 +413,8 @@ public void IsEnglishQuotationContinuer() ), null, null - ) + ), + Is.True ); var categorizerForDenorm = new QuotationMarkCategorizer( @@ -418,18 +422,19 @@ public void IsEnglishQuotationContinuer() resolverState, continuerState ); - Assert.IsTrue( + Assert.That( categorizerForDenorm.IsEnglishQuoteContinuer( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201ctest").Build(), 0, 1), null, null - ) + ), + Is.True ); // Should be false if there are no open quotation marks var emptyState = new QuotationMarkResolverState(); var emptyCategorizer = new QuotationMarkCategorizer(settings, emptyState, continuerState); - Assert.IsFalse( + Assert.That( emptyCategorizer.IsEnglishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -441,11 +446,12 @@ public void IsEnglishQuotationContinuer() ), null, null - ) + ), + Is.False ); // Should be false if the starting index of the quotation mark is greater than 0 - Assert.IsFalse( + Assert.That( categorizer.IsEnglishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -457,11 +463,12 @@ public void IsEnglishQuotationContinuer() ), null, null - ) + ), + Is.False ); // Should be false if the mark does not match the already opened mark - Assert.IsFalse( + Assert.That( categorizer.IsEnglishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -473,14 +480,15 @@ public void IsEnglishQuotationContinuer() ), null, null - ) + ), + Is.False ); // If there are multiple open quotes, the next quote continuer must follow immediately after the current one resolverState.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018").Build(), 0, 1) ); - Assert.IsFalse( + Assert.That( categorizer.IsEnglishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -492,9 +500,10 @@ public void IsEnglishQuotationContinuer() ), null, null - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( categorizer.IsEnglishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -513,9 +522,10 @@ public void IsEnglishQuotationContinuer() 1, 2 ) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( categorizer.IsEnglishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -534,7 +544,8 @@ public void IsEnglishQuotationContinuer() 1, 2 ) - ) + ), + Is.True ); // When there are multiple open quotes, the continuer must match the deepest observed mark @@ -551,7 +562,7 @@ public void IsEnglishQuotationContinuer() QuoteContinuerStyle.English ); - Assert.IsFalse( + Assert.That( categorizer.IsEnglishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -563,9 +574,10 @@ public void IsEnglishQuotationContinuer() ), null, null - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( categorizer.IsEnglishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -577,13 +589,14 @@ public void IsEnglishQuotationContinuer() ), null, null - ) + ), + Is.True ); resolverState.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) ); - Assert.IsTrue( + Assert.That( categorizer.IsEnglishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -595,7 +608,8 @@ public void IsEnglishQuotationContinuer() ), null, null - ) + ), + Is.True ); continuerState.AddQuoteContinuer( @@ -611,7 +625,7 @@ public void IsEnglishQuotationContinuer() QuoteContinuerStyle.English ); - Assert.IsFalse( + Assert.That( categorizer.IsEnglishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -623,9 +637,10 @@ public void IsEnglishQuotationContinuer() ), null, null - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( categorizer.IsEnglishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -637,7 +652,8 @@ public void IsEnglishQuotationContinuer() ), null, null - ) + ), + Is.True ); } @@ -647,7 +663,7 @@ public void IsSpanishQuotationContinuer() QuoteConvention westernEuropeanQuoteConvention = QuoteConventions.Standard.GetQuoteConventionByName( "western_european" ); - Assert.IsNotNull(westernEuropeanQuoteConvention); + Assert.That(westernEuropeanQuoteConvention, Is.Not.Null); var settings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([westernEuropeanQuoteConvention]) @@ -662,7 +678,7 @@ public void IsSpanishQuotationContinuer() // Should always be false if the continuer style is Spanish continuerState.InternalContinuerStyle = QuoteContinuerStyle.Spanish; - Assert.IsTrue( + Assert.That( categorizer.IsSpanishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -674,11 +690,12 @@ public void IsSpanishQuotationContinuer() ), null, null - ) + ), + Is.True ); continuerState.InternalContinuerStyle = QuoteContinuerStyle.English; - Assert.IsFalse( + Assert.That( categorizer.IsSpanishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -690,20 +707,22 @@ public void IsSpanishQuotationContinuer() ), null, null - ) + ), + Is.False ); continuerState.InternalContinuerStyle = QuoteContinuerStyle.Spanish; // Should be false if there's no preceding paragraph marker (and the settings say to rely on markers) - Assert.IsFalse( + Assert.That( categorizer.IsSpanishQuoteContinuer( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u00bbtest").Build(), 0, 1), null, null - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( categorizer.IsSpanishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -715,7 +734,8 @@ public void IsSpanishQuotationContinuer() ), null, null - ) + ), + Is.True ); var categorizerForDenorm = new QuotationMarkCategorizer( @@ -723,18 +743,19 @@ public void IsSpanishQuotationContinuer() resolverState, continuerState ); - Assert.IsTrue( + Assert.That( categorizerForDenorm.IsSpanishQuoteContinuer( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u00bbtest").Build(), 0, 1), null, null - ) + ), + Is.True ); // Should be false if there are no open quotation marks var emptyState = new QuotationMarkResolverState(); var emptyCategorizer = new QuotationMarkCategorizer(settings, emptyState, continuerState); - Assert.IsFalse( + Assert.That( emptyCategorizer.IsSpanishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -746,11 +767,12 @@ public void IsSpanishQuotationContinuer() ), null, null - ) + ), + Is.False ); // Should be false if the starting index of the quotation mark is greater than 0 - Assert.IsFalse( + Assert.That( categorizer.IsSpanishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -762,11 +784,12 @@ public void IsSpanishQuotationContinuer() ), null, null - ) + ), + Is.False ); // Should be false if the mark does not match the already opened mark - Assert.IsFalse( + Assert.That( categorizer.IsSpanishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -778,14 +801,15 @@ public void IsSpanishQuotationContinuer() ), null, null - ) + ), + Is.False ); // If there are multiple open quotes, the next quote continuer must follow immediately after the current one resolverState.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) ); - Assert.IsFalse( + Assert.That( categorizer.IsSpanishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -797,9 +821,10 @@ public void IsSpanishQuotationContinuer() ), null, null - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( categorizer.IsSpanishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -818,9 +843,10 @@ public void IsSpanishQuotationContinuer() 1, 2 ) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( categorizer.IsSpanishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -839,7 +865,8 @@ public void IsSpanishQuotationContinuer() 1, 2 ) - ) + ), + Is.True ); // When there are multiple open quotes, the continuer must match the deepest observed mark @@ -856,7 +883,7 @@ public void IsSpanishQuotationContinuer() QuoteContinuerStyle.Spanish ); - Assert.IsFalse( + Assert.That( categorizer.IsSpanishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -868,9 +895,10 @@ public void IsSpanishQuotationContinuer() ), null, null - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( categorizer.IsSpanishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -882,13 +910,14 @@ public void IsSpanishQuotationContinuer() ), null, null - ) + ), + Is.True ); resolverState.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018").Build(), 0, 1) ); - Assert.IsTrue( + Assert.That( categorizer.IsSpanishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -900,7 +929,8 @@ public void IsSpanishQuotationContinuer() ), null, null - ) + ), + Is.True ); continuerState.AddQuoteContinuer( @@ -916,7 +946,7 @@ public void IsSpanishQuotationContinuer() QuoteContinuerStyle.Spanish ); - Assert.IsFalse( + Assert.That( categorizer.IsSpanishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -928,9 +958,10 @@ public void IsSpanishQuotationContinuer() ), null, null - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( categorizer.IsSpanishQuoteContinuer( new QuotationMarkStringMatch( new TextSegment.Builder() @@ -942,7 +973,8 @@ public void IsSpanishQuotationContinuer() ), null, null - ) + ), + Is.True ); } @@ -952,7 +984,7 @@ public void IsOpeningQuote() QuoteConvention centralEuropeanQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("central_european") ); - Assert.IsNotNull(centralEuropeanQuoteConvention); + Assert.That(centralEuropeanQuoteConvention, Is.Not.Null); var centralEuropeanResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([centralEuropeanQuoteConvention]) ); @@ -967,7 +999,7 @@ public void IsOpeningQuote() QuoteConvention britishEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("british_english") ); - Assert.IsNotNull(britishEnglishQuoteConvention); + Assert.That(britishEnglishQuoteConvention, Is.Not.Null); var britishEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([britishEnglishQuoteConvention]) ); @@ -980,7 +1012,7 @@ public void IsOpeningQuote() QuoteConvention standardSwedishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("standard_swedish") ); - Assert.IsNotNull(standardSwedishQuoteConvention); + Assert.That(standardSwedishQuoteConvention, Is.Not.Null); var standardSwedishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([standardSwedishQuoteConvention]) ); @@ -991,9 +1023,11 @@ public void IsOpeningQuote() ); var threeConventionsResolverSettings = new QuoteConventionDetectionResolutionSettings( - new QuoteConventionSet( - [centralEuropeanQuoteConvention, britishEnglishQuoteConvention, standardSwedishQuoteConvention] - ) + new QuoteConventionSet([ + centralEuropeanQuoteConvention, + britishEnglishQuoteConvention, + standardSwedishQuoteConvention, + ]) ); var threeConventionsQuotationMarkCategorizer = new QuotationMarkCategorizer( threeConventionsResolverSettings, @@ -1002,289 +1036,343 @@ public void IsOpeningQuote() ); // It should only accept valid opening marks under the quote convention - Assert.IsTrue( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201e").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201a").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201c").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2018").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201d").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2019").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u00ab").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \"").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201e").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201a").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( britishEnglishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201c").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( britishEnglishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2018").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201d").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2019").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u00ab").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \"").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201e").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201a").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201c").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2018").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201d").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2019").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u00ab").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \"").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201e").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201a").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201c").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2018").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201d").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2019").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u00ab").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \"").Build(), 1, 2) - ) + ), + Is.False ); // Leading whitespace is not necessary for unambiguous opening quotes - Assert.IsTrue( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("text\u201e").Build(), 4, 5) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("text\u201a").Build(), 4, 5) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( britishEnglishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("text\u201c").Build(), 4, 5) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( britishEnglishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("text\u2018").Build(), 4, 5) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("text\u201e").Build(), 4, 5) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("text\u201a").Build(), 4, 5) - ) + ), + Is.True ); // An ambiguous quotation mark (opening/closing) is recognized as opening if it has a quote introducer beforehand - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(",\u201d").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(":\u2019").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(",\u201c").Build(), 1, 2) - ) + ), + Is.True ); // An ambiguous quotation mark (opening/closing) is recognized as opening if preceded by another opening mark quotationMarkResolverState.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c\u201d").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c\u2019").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c\u201c").Build(), 1, 2) - ) + ), + Is.True ); // An ambiguous quotation mark (opening/closing) is not recognized as opening if it has trailing whitespace or punctuation - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201d.").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(",\u201d ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c\u2019 ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c\u2019?").Build(), 1, 2) - ) + ), + Is.False ); } @@ -1294,7 +1382,7 @@ public void IsClosingQuote() QuoteConvention centralEuropeanQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("central_european") ); - Assert.IsNotNull(centralEuropeanQuoteConvention); + Assert.That(centralEuropeanQuoteConvention, Is.Not.Null); var centralEuropeanResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([centralEuropeanQuoteConvention]) ); @@ -1309,7 +1397,7 @@ public void IsClosingQuote() QuoteConvention britishEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("british_english") ); - Assert.IsNotNull(britishEnglishQuoteConvention); + Assert.That(britishEnglishQuoteConvention, Is.Not.Null); var britishEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([britishEnglishQuoteConvention]) ); @@ -1322,7 +1410,7 @@ public void IsClosingQuote() QuoteConvention standardSwedishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("standard_swedish") ); - Assert.IsNotNull(standardSwedishQuoteConvention); + Assert.That(standardSwedishQuoteConvention, Is.Not.Null); var standardSwedishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([standardSwedishQuoteConvention]) ); @@ -1335,7 +1423,7 @@ public void IsClosingQuote() QuoteConvention standardFrenchQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("standard_french") ); - Assert.IsNotNull(standardFrenchQuoteConvention); + Assert.That(standardFrenchQuoteConvention, Is.Not.Null); var standardFrenchResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([standardFrenchQuoteConvention]) ); @@ -1346,9 +1434,11 @@ public void IsClosingQuote() ); var threeConventionsResolverSettings = new QuoteConventionDetectionResolutionSettings( - new QuoteConventionSet( - [centralEuropeanQuoteConvention, britishEnglishQuoteConvention, standardSwedishQuoteConvention] - ) + new QuoteConventionSet([ + centralEuropeanQuoteConvention, + britishEnglishQuoteConvention, + standardSwedishQuoteConvention, + ]) ); var threeConventionsQuotationMarkCategorizer = new QuotationMarkCategorizer( threeConventionsResolverSettings, @@ -1357,206 +1447,244 @@ public void IsClosingQuote() ); // It should only accept valid closing marks under the quote convention - Assert.IsTrue( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c ").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018 ").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201e ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201a ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019 ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u00bb ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\" ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018 ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( britishEnglishQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d ").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( britishEnglishQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019 ").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u00bb ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\" ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018 ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d ").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019 ").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u00bb ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\" ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c ").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018 ").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d ").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019 ").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u00bb ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\" ").Build(), 0, 1) - ) + ), + Is.False ); // Trailing whitespace is not necessary for unambiguous closing quotes - Assert.IsTrue( + Assert.That( standardFrenchQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u00bbtext").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardFrenchQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u203atext").Build(), 0, 1) - ) + ), + Is.True ); // An ambiguous quotation mark (opening/closing) is recognized as closing if // followed by whitespace, punctuation or the end of the segment - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201dtext").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d ").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019text").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019?").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019\u201d").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201ctext").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c?").Build(), 0, 1) - ) + ), + Is.True ); // An ambiguous quotation mark (opening/closing) is not recognized as opening if // it has leading whitespace - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201d").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\t\u201c?").Build(), 1, 2) - ) + ), + Is.False ); } @@ -1566,7 +1694,7 @@ public void IsMalformedOpeningQuote() QuoteConvention centralEuropeanQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("central_european") ); - Assert.IsNotNull(centralEuropeanQuoteConvention); + Assert.That(centralEuropeanQuoteConvention, Is.Not.Null); var centralEuropeanResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([centralEuropeanQuoteConvention]) ); @@ -1581,7 +1709,7 @@ public void IsMalformedOpeningQuote() QuoteConvention britishEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("british_english") ); - Assert.IsNotNull(britishEnglishQuoteConvention); + Assert.That(britishEnglishQuoteConvention, Is.Not.Null); var britishEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([britishEnglishQuoteConvention]) ); @@ -1594,7 +1722,7 @@ public void IsMalformedOpeningQuote() QuoteConvention standardSwedishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("standard_swedish") ); - Assert.IsNotNull(standardSwedishQuoteConvention); + Assert.That(standardSwedishQuoteConvention, Is.Not.Null); var standardSwedishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([standardSwedishQuoteConvention]) ); @@ -1605,9 +1733,11 @@ public void IsMalformedOpeningQuote() ); var threeConventionsResolverSettings = new QuoteConventionDetectionResolutionSettings( - new QuoteConventionSet( - [centralEuropeanQuoteConvention, britishEnglishQuoteConvention, standardSwedishQuoteConvention] - ) + new QuoteConventionSet([ + centralEuropeanQuoteConvention, + britishEnglishQuoteConvention, + standardSwedishQuoteConvention, + ]) ); var threeConventionsQuotationMarkCategorizer = new QuotationMarkCategorizer( threeConventionsResolverSettings, @@ -1616,252 +1746,299 @@ public void IsMalformedOpeningQuote() ); // It should only accept valid opening marks under the quote convention - Assert.IsTrue( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201e ").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201a ").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201c ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2018 ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201d ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2019 ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u00ab ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \" ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201e ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201a ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201c ").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2018 ").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201d ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2019 ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u00ab ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \" ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201e ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201a ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201c ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2018 ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201d ").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2019 ").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u00ab ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \" ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201e ").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201a ").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201c ").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2018 ").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201d ").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2019 ").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u00ab ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \" ").Build(), 1, 2) - ) + ), + Is.False ); // Should return true if there is a leading quote introducer - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(",\u201d ").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019 ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(":\u2019 ").Build(), 1, 2) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(",\u201c ").Build(), 1, 2) - ) + ), + Is.True ); // Should return false unless the mark has leading and trailing whitespace - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201d").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201d ").Build(), 1, 2) - ) + ), + Is.True ); // Should return false if there is already an open quotation mark on the stack quotationMarkResolverState.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201d ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2019 ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201c ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201d ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2019 ").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsMalformedOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201c ").Build(), 1, 2) - ) + ), + Is.False ); } @@ -1871,7 +2048,7 @@ public void IsMalformedClosingQuote() QuoteConvention centralEuropeanQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("central_european") ); - Assert.IsNotNull(centralEuropeanQuoteConvention); + Assert.That(centralEuropeanQuoteConvention, Is.Not.Null); var centralEuropeanResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([centralEuropeanQuoteConvention]) ); @@ -1886,7 +2063,7 @@ public void IsMalformedClosingQuote() QuoteConvention britishEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("british_english") ); - Assert.IsNotNull(britishEnglishQuoteConvention); + Assert.That(britishEnglishQuoteConvention, Is.Not.Null); var britishEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([britishEnglishQuoteConvention]) ); @@ -1899,7 +2076,7 @@ public void IsMalformedClosingQuote() QuoteConvention standardSwedishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("standard_swedish") ); - Assert.IsNotNull(standardSwedishQuoteConvention); + Assert.That(standardSwedishQuoteConvention, Is.Not.Null); var standardSwedishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([standardSwedishQuoteConvention]) ); @@ -1910,9 +2087,11 @@ public void IsMalformedClosingQuote() ); var threeConventionsResolverSettings = new QuoteConventionDetectionResolutionSettings( - new QuoteConventionSet( - [centralEuropeanQuoteConvention, britishEnglishQuoteConvention, standardSwedishQuoteConvention] - ) + new QuoteConventionSet([ + centralEuropeanQuoteConvention, + britishEnglishQuoteConvention, + standardSwedishQuoteConvention, + ]) ); var threeConventionsQuotationMarkCategorizer = new QuotationMarkCategorizer( threeConventionsResolverSettings, @@ -1924,45 +2103,53 @@ public void IsMalformedClosingQuote() quotationMarkResolverState.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201e").Build(), 0, 1) ); - Assert.IsTrue( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201e").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201a").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u00bb").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"").Build(), 0, 1) - ) + ), + Is.False ); quotationMarkResolverState.AddClosingQuotationMark( @@ -1971,35 +2158,41 @@ public void IsMalformedClosingQuote() quotationMarkResolverState.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018").Build(), 0, 1) ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u00bb").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"").Build(), 0, 1) - ) + ), + Is.False ); quotationMarkResolverState.AddClosingQuotationMark( @@ -2008,107 +2201,125 @@ public void IsMalformedClosingQuote() quotationMarkResolverState.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u00bb").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u00bb").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"").Build(), 0, 1) - ) + ), + Is.False ); // Returns true if it's at the end of the segment - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d ").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) - ) + ), + Is.True ); // Returns true if it does not have trailing whitespace - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d-").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201dtext").Build(), 0, 1) - ) + ), + Is.True ); // Returns true if it has trailing and leading whitespace - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201d ").Build(), 1, 2) - ) + ), + Is.True ); // Requires there to be an open quotation mark on the stack quotationMarkResolverState.AddClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d ").Build(), 0, 1) - ) + ), + Is.False ); // Requires the quotation mark on the stack to be a valid pair with the @@ -2116,34 +2327,39 @@ public void IsMalformedClosingQuote() quotationMarkResolverState.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) ); - Assert.IsTrue( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019").Build(), 0, 1) - ) + ), + Is.False ); quotationMarkResolverState.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018").Build(), 0, 1) ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( britishEnglishQuotationMarkCategorizer.IsMalformedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019").Build(), 0, 1) - ) + ), + Is.True ); } @@ -2153,7 +2369,7 @@ public void IsUnpairedClosingQuote() QuoteConvention centralEuropeanQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("central_european") ); - Assert.IsNotNull(centralEuropeanQuoteConvention); + Assert.That(centralEuropeanQuoteConvention, Is.Not.Null); var centralEuropeanResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([centralEuropeanQuoteConvention]) ); @@ -2168,7 +2384,7 @@ public void IsUnpairedClosingQuote() QuoteConvention britishEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("british_english") ); - Assert.IsNotNull(britishEnglishQuoteConvention); + Assert.That(britishEnglishQuoteConvention, Is.Not.Null); var britishEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([britishEnglishQuoteConvention]) ); @@ -2181,7 +2397,7 @@ public void IsUnpairedClosingQuote() QuoteConvention standardSwedishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("standard_swedish") ); - Assert.IsNotNull(standardSwedishQuoteConvention); + Assert.That(standardSwedishQuoteConvention, Is.Not.Null); var standardSwedishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([standardSwedishQuoteConvention]) ); @@ -2192,9 +2408,11 @@ public void IsUnpairedClosingQuote() ); var threeConventionsResolverSettings = new QuoteConventionDetectionResolutionSettings( - new QuoteConventionSet( - [centralEuropeanQuoteConvention, britishEnglishQuoteConvention, standardSwedishQuoteConvention] - ) + new QuoteConventionSet([ + centralEuropeanQuoteConvention, + britishEnglishQuoteConvention, + standardSwedishQuoteConvention, + ]) ); var threeConventionsQuotationMarkCategorizer = new QuotationMarkCategorizer( threeConventionsResolverSettings, @@ -2203,226 +2421,267 @@ public void IsUnpairedClosingQuote() ); // It should only accept valid closing marks under the quote convention - Assert.IsTrue( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201e").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201a").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u00bb").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( britishEnglishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( britishEnglishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u00bb").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardSwedishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u00bb").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( threeConventionsQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u00bb").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"").Build(), 0, 1) - ) + ), + Is.False ); // There must not be an opening quotation mark on the stack quotationMarkResolverState.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( centralEuropeanQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardSwedishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( threeConventionsQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019").Build(), 0, 1) - ) + ), + Is.False ); // There must not be leading whitespace quotationMarkResolverState.AddClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u201d").Build(), 1, 2) - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\t\u2019").Build(), 1, 2) - ) + ), + Is.False ); // The quotation mark must be either at the end of the segment // or have trailing whitespace - Assert.IsTrue( + Assert.That( britishEnglishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( britishEnglishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d ").Build(), 0, 1) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( britishEnglishQuotationMarkCategorizer.IsUnpairedClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201d?").Build(), 0, 1) - ) + ), + Is.False ); } @@ -2432,7 +2691,7 @@ public void IsApostrophe() QuoteConvention standardEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("standard_english") ); - Assert.IsNotNull(standardEnglishQuoteConvention); + Assert.That(standardEnglishQuoteConvention, Is.Not.Null); var standardEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([standardEnglishQuoteConvention]) ); @@ -2447,7 +2706,7 @@ public void IsApostrophe() QuoteConvention typewriterEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("typewriter_english") ); - Assert.IsNotNull(typewriterEnglishQuoteConvention); + Assert.That(typewriterEnglishQuoteConvention, Is.Not.Null); var typewriterEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([typewriterEnglishQuoteConvention]) ); @@ -2458,146 +2717,167 @@ public void IsApostrophe() ); // The quotation mark must make for a plausible apostrophe - Assert.IsTrue( + Assert.That( typewriterEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("a'b").Build(), 1, 2), null - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( typewriterEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("a\u2019b").Build(), 1, 2), null - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( typewriterEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("a\u2018b").Build(), 1, 2), null - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( typewriterEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("a\u201cb").Build(), 1, 2), null - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( typewriterEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("a\"b").Build(), 1, 2), null - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("a'b").Build(), 1, 2), null - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("a\u2019b").Build(), 1, 2), null - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("a\u2018b").Build(), 1, 2), null - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("a\u201cb").Build(), 1, 2), null - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("a\"b").Build(), 1, 2), null - ) + ), + Is.False ); // Returns true if the mark has Latin letters on both sides quotationMarkResolverState.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018").Build(), 0, 1) ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("a\u2019Ƅ").Build(), 1, 2), null - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("ǡ\u2019b").Build(), 1, 2), null - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("ᴀ\u2019B").Build(), 1, 2), null - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("𝼀\u2019Ꝙ").Build(), 1, 2), null - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("a\u2019ℵ").Build(), 1, 2), null - ) + ), + Is.False ); - Assert.IsTrue( + Assert.That( typewriterEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("a\u2019ℵ").Build(), 1, 2), null - ) + ), + Is.True ); // Recognizes s possessives (e.G. Moses') quotationMarkResolverState.AddClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2019").Build(), 0, 1) ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("s\u2019 ").Build(), 1, 2), null - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("Moses\u2019 ").Build(), 5, 6), null - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("s\u2019?").Build(), 1, 2), null - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("s\u20195").Build(), 1, 2), null - ) + ), + Is.False ); quotationMarkResolverState.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"").Build(), 0, 1) ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("s\u2019 ").Build(), 1, 2), null - ) + ), + Is.True ); quotationMarkResolverState.AddClosingQuotationMark( @@ -2606,48 +2886,54 @@ public void IsApostrophe() quotationMarkResolverState.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u2018").Build(), 0, 1) ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("s\u2019 ").Build(), 1, 2), new QuotationMarkStringMatch(new TextSegment.Builder().SetText("word\u2019").Build(), 4, 5) - ) + ), + Is.True ); - Assert.IsFalse( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("s\u2019 ").Build(), 1, 2), new QuotationMarkStringMatch(new TextSegment.Builder().SetText("word\u201d").Build(), 4, 5) - ) + ), + Is.False ); // the straight quote should always be an apostrophe if it's not a valid quotation mark - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("5'ℵ").Build(), 1, 2), null - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" ' ").Build(), 1, 2), null - ) + ), + Is.True ); // the straight quote should be an apostrophe if there's nothing on the quotation mark stack quotationMarkResolverState.AddClosingQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"").Build(), 0, 1) ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("5'ℵ").Build(), 1, 2), null - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" ' ").Build(), 1, 2), null - ) + ), + Is.True ); // any matching mark should be an apostrophe if it doesn't pair with the @@ -2656,41 +2942,47 @@ public void IsApostrophe() quotationMarkResolverState.AddOpeningQuotationMark( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1) ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("5'ℵ").Build(), 1, 2), null - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" ' ").Build(), 1, 2), null - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("5\u2018ℵ").Build(), 1, 2), null - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2018 ").Build(), 1, 2), null - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText("5\u2019ℵ").Build(), 1, 2), null - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( standardEnglishQuotationMarkCategorizer.IsApostrophe( new QuotationMarkStringMatch(new TextSegment.Builder().SetText(" \u2019 ").Build(), 1, 2), null - ) + ), + Is.True ); } @@ -2700,16 +2992,16 @@ public void DepthBasedQuotationMarkResolverReset() QuoteConvention standardEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("standard_english") ); - Assert.IsNotNull(standardEnglishQuoteConvention); + Assert.That(standardEnglishQuoteConvention, Is.Not.Null); var standardEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([standardEnglishQuoteConvention]) ); var standardEnglishQuotationMarkResolver = new DepthBasedQuotationMarkResolver(standardEnglishResolverSettings); standardEnglishQuotationMarkResolver - .ResolveQuotationMarks( - [new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201cThis is a quote").Build(), 0, 1)] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201cThis is a quote").Build(), 0, 1), + ]) .ToList(); Assert.That( @@ -2722,15 +3014,13 @@ [new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201cThis is a Assert.That(standardEnglishQuotationMarkResolver.GetIssues(), Has.Count.EqualTo(0)); standardEnglishQuotationMarkResolver - .ResolveQuotationMarks( - [ - new QuotationMarkStringMatch( - new TextSegment.Builder().SetText("This is a quote\u2019").Build(), - 15, - 16 - ) - ] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch( + new TextSegment.Builder().SetText("This is a quote\u2019").Build(), + 15, + 16 + ), + ]) .ToList(); Assert.That( @@ -2746,7 +3036,7 @@ public void BasicQuotationMarkRecognition() QuoteConvention standardEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("standard_english") ); - Assert.IsNotNull(standardEnglishQuoteConvention); + Assert.That(standardEnglishQuoteConvention, Is.Not.Null); var standardEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([standardEnglishQuoteConvention]) ); @@ -2755,22 +3045,18 @@ public void BasicQuotationMarkRecognition() TextSegment textSegment = new TextSegment.Builder().SetText("\u201cThis is a \u2018quote\u2019\u201d").Build(); Assert.That( standardEnglishQuotationMarkResolver - .ResolveQuotationMarks( - [ - new QuotationMarkStringMatch(textSegment, 0, 1), - new QuotationMarkStringMatch(textSegment, 11, 12), - new QuotationMarkStringMatch(textSegment, 17, 18), - new QuotationMarkStringMatch(textSegment, 18, 19), - ] - ) - .SequenceEqual( - [ - new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), - new QuotationMarkMetadata("\u2018", 2, QuotationMarkDirection.Opening, textSegment, 11, 12), - new QuotationMarkMetadata("\u2019", 2, QuotationMarkDirection.Closing, textSegment, 17, 18), - new QuotationMarkMetadata("\u201d", 1, QuotationMarkDirection.Closing, textSegment, 18, 19), - ] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch(textSegment, 0, 1), + new QuotationMarkStringMatch(textSegment, 11, 12), + new QuotationMarkStringMatch(textSegment, 17, 18), + new QuotationMarkStringMatch(textSegment, 18, 19), + ]) + .SequenceEqual([ + new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), + new QuotationMarkMetadata("\u2018", 2, QuotationMarkDirection.Opening, textSegment, 11, 12), + new QuotationMarkMetadata("\u2019", 2, QuotationMarkDirection.Closing, textSegment, 17, 18), + new QuotationMarkMetadata("\u201d", 1, QuotationMarkDirection.Closing, textSegment, 18, 19), + ]) ); Assert.That(standardEnglishQuotationMarkResolver.GetIssues(), Has.Count.EqualTo(0)); } @@ -2781,7 +3067,7 @@ public void ResolutionOnlyOfPassedMatches() QuoteConvention standardEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("standard_english") ); - Assert.IsNotNull(standardEnglishQuoteConvention); + Assert.That(standardEnglishQuoteConvention, Is.Not.Null); var standardEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([standardEnglishQuoteConvention]) ); @@ -2790,10 +3076,10 @@ public void ResolutionOnlyOfPassedMatches() TextSegment textSegment = new TextSegment.Builder().SetText("\u201cThis is a \u2018quote\u2019\u201d").Build(); Assert.That( standardEnglishQuotationMarkResolver - .ResolveQuotationMarks([new QuotationMarkStringMatch(textSegment, 0, 1),]) - .SequenceEqual( - [new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment, 0, 1),] - ) + .ResolveQuotationMarks([new QuotationMarkStringMatch(textSegment, 0, 1)]) + .SequenceEqual([ + new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), + ]) ); Assert.That( standardEnglishQuotationMarkResolver @@ -2804,7 +3090,7 @@ [new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegm textSegment = new TextSegment.Builder().SetText("\u201cThis is a \u2018quote\u2019\u201d").Build(); Assert.That( standardEnglishQuotationMarkResolver - .ResolveQuotationMarks([new QuotationMarkStringMatch(textSegment, 17, 18),]) + .ResolveQuotationMarks([new QuotationMarkStringMatch(textSegment, 17, 18)]) .Count(), Is.EqualTo(0) ); @@ -2821,7 +3107,7 @@ public void ResolutionAcrossSegments() QuoteConvention standardEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("standard_english") ); - Assert.IsNotNull(standardEnglishQuoteConvention); + Assert.That(standardEnglishQuoteConvention, Is.Not.Null); var standardEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([standardEnglishQuoteConvention]) ); @@ -2831,22 +3117,18 @@ public void ResolutionAcrossSegments() TextSegment textSegment2 = new TextSegment.Builder().SetText("\u2018quote\u2019\u201d").Build(); Assert.That( standardEnglishQuotationMarkResolver - .ResolveQuotationMarks( - [ - new QuotationMarkStringMatch(textSegment1, 0, 1), - new QuotationMarkStringMatch(textSegment2, 0, 1), - new QuotationMarkStringMatch(textSegment2, 6, 7), - new QuotationMarkStringMatch(textSegment2, 7, 8), - ] - ) - .SequenceEqual( - [ - new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment1, 0, 1), - new QuotationMarkMetadata("\u2018", 2, QuotationMarkDirection.Opening, textSegment2, 0, 1), - new QuotationMarkMetadata("\u2019", 2, QuotationMarkDirection.Closing, textSegment2, 6, 7), - new QuotationMarkMetadata("\u201d", 1, QuotationMarkDirection.Closing, textSegment2, 7, 8), - ] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch(textSegment1, 0, 1), + new QuotationMarkStringMatch(textSegment2, 0, 1), + new QuotationMarkStringMatch(textSegment2, 6, 7), + new QuotationMarkStringMatch(textSegment2, 7, 8), + ]) + .SequenceEqual([ + new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment1, 0, 1), + new QuotationMarkMetadata("\u2018", 2, QuotationMarkDirection.Opening, textSegment2, 0, 1), + new QuotationMarkMetadata("\u2019", 2, QuotationMarkDirection.Closing, textSegment2, 6, 7), + new QuotationMarkMetadata("\u201d", 1, QuotationMarkDirection.Closing, textSegment2, 7, 8), + ]) ); Assert.That(standardEnglishQuotationMarkResolver.GetIssues(), Has.Count.EqualTo(0)); } @@ -2857,7 +3139,7 @@ public void ResolutionWithApostrophes() QuoteConvention standardEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("standard_english") ); - Assert.IsNotNull(standardEnglishQuoteConvention); + Assert.That(standardEnglishQuoteConvention, Is.Not.Null); var standardEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([standardEnglishQuoteConvention]) ); @@ -2871,30 +3153,26 @@ public void ResolutionWithApostrophes() ); Assert.That( standardEnglishQuotationMarkResolver - .ResolveQuotationMarks( - [ - new QuotationMarkStringMatch(textSegment, 0, 1), - new QuotationMarkStringMatch(textSegment, 5, 6), - new QuotationMarkStringMatch(textSegment, 12, 13), - new QuotationMarkStringMatch(textSegment, 18, 19), - new QuotationMarkStringMatch(textSegment, 19, 20), - ] - ) - .SequenceEqual( - [ - new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), - new QuotationMarkMetadata("\u2018", 2, QuotationMarkDirection.Opening, textSegment, 12, 13), - new QuotationMarkMetadata("\u2019", 2, QuotationMarkDirection.Closing, textSegment, 18, 19), - new QuotationMarkMetadata("\u201d", 1, QuotationMarkDirection.Closing, textSegment, 19, 20), - ] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch(textSegment, 0, 1), + new QuotationMarkStringMatch(textSegment, 5, 6), + new QuotationMarkStringMatch(textSegment, 12, 13), + new QuotationMarkStringMatch(textSegment, 18, 19), + new QuotationMarkStringMatch(textSegment, 19, 20), + ]) + .SequenceEqual([ + new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), + new QuotationMarkMetadata("\u2018", 2, QuotationMarkDirection.Opening, textSegment, 12, 13), + new QuotationMarkMetadata("\u2019", 2, QuotationMarkDirection.Closing, textSegment, 18, 19), + new QuotationMarkMetadata("\u201d", 1, QuotationMarkDirection.Closing, textSegment, 19, 20), + ]) ); Assert.That(standardEnglishQuotationMarkResolver.GetIssues(), Has.Count.EqualTo(0)); QuoteConvention typewriterEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("typewriter_english") ); - Assert.IsNotNull(typewriterEnglishQuoteConvention); + Assert.That(typewriterEnglishQuoteConvention, Is.Not.Null); var typewriterEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([typewriterEnglishQuoteConvention]) ); @@ -2908,23 +3186,19 @@ public void ResolutionWithApostrophes() .Build(); Assert.That( typewriterEnglishQuotationMarkResolver - .ResolveQuotationMarks( - [ - new QuotationMarkStringMatch(textSegment, 0, 1), - new QuotationMarkStringMatch(textSegment, 5, 6), - new QuotationMarkStringMatch(textSegment, 12, 13), - new QuotationMarkStringMatch(textSegment, 18, 19), - new QuotationMarkStringMatch(textSegment, 19, 20), - ] - ) - .SequenceEqual( - [ - new QuotationMarkMetadata("\"", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), - new QuotationMarkMetadata("'", 2, QuotationMarkDirection.Opening, textSegment, 12, 13), - new QuotationMarkMetadata("'", 2, QuotationMarkDirection.Closing, textSegment, 18, 19), - new QuotationMarkMetadata("\"", 1, QuotationMarkDirection.Closing, textSegment, 19, 20), - ] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch(textSegment, 0, 1), + new QuotationMarkStringMatch(textSegment, 5, 6), + new QuotationMarkStringMatch(textSegment, 12, 13), + new QuotationMarkStringMatch(textSegment, 18, 19), + new QuotationMarkStringMatch(textSegment, 19, 20), + ]) + .SequenceEqual([ + new QuotationMarkMetadata("\"", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), + new QuotationMarkMetadata("'", 2, QuotationMarkDirection.Opening, textSegment, 12, 13), + new QuotationMarkMetadata("'", 2, QuotationMarkDirection.Closing, textSegment, 18, 19), + new QuotationMarkMetadata("\"", 1, QuotationMarkDirection.Closing, textSegment, 19, 20), + ]) ); Assert.That(standardEnglishQuotationMarkResolver.GetIssues(), Has.Count.EqualTo(0)); } @@ -2935,7 +3209,7 @@ public void EnglishQuoteContinuers() QuoteConvention standardEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("standard_english") ); - Assert.IsNotNull(standardEnglishQuoteConvention); + Assert.That(standardEnglishQuoteConvention, Is.Not.Null); var standardEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([standardEnglishQuoteConvention]) ); @@ -2950,26 +3224,22 @@ public void EnglishQuoteContinuers() ); Assert.That( standardEnglishQuotationMarkResolver - .ResolveQuotationMarks( - [ - new QuotationMarkStringMatch(textSegment1, 0, 1), - new QuotationMarkStringMatch(textSegment1, 11, 12), - new QuotationMarkStringMatch(textSegment2, 0, 1), - new QuotationMarkStringMatch(textSegment2, 1, 2), - new QuotationMarkStringMatch(textSegment2, 18, 19), - new QuotationMarkStringMatch(textSegment2, 25, 26), - ] - ) - .SequenceEqual( - [ - new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment1, 0, 1), - new QuotationMarkMetadata("\u2018", 2, QuotationMarkDirection.Opening, textSegment1, 11, 12), - new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment2, 0, 1), - new QuotationMarkMetadata("\u2018", 2, QuotationMarkDirection.Opening, textSegment2, 1, 2), - new QuotationMarkMetadata("\u2019", 2, QuotationMarkDirection.Closing, textSegment2, 18, 19), - new QuotationMarkMetadata("\u201d", 1, QuotationMarkDirection.Closing, textSegment2, 25, 26), - ] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch(textSegment1, 0, 1), + new QuotationMarkStringMatch(textSegment1, 11, 12), + new QuotationMarkStringMatch(textSegment2, 0, 1), + new QuotationMarkStringMatch(textSegment2, 1, 2), + new QuotationMarkStringMatch(textSegment2, 18, 19), + new QuotationMarkStringMatch(textSegment2, 25, 26), + ]) + .SequenceEqual([ + new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment1, 0, 1), + new QuotationMarkMetadata("\u2018", 2, QuotationMarkDirection.Opening, textSegment1, 11, 12), + new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment2, 0, 1), + new QuotationMarkMetadata("\u2018", 2, QuotationMarkDirection.Opening, textSegment2, 1, 2), + new QuotationMarkMetadata("\u2019", 2, QuotationMarkDirection.Closing, textSegment2, 18, 19), + new QuotationMarkMetadata("\u201d", 1, QuotationMarkDirection.Closing, textSegment2, 25, 26), + ]) ); Assert.That(standardEnglishQuotationMarkResolver.GetIssues(), Has.Count.EqualTo(0)); } @@ -2980,7 +3250,7 @@ public void SpanishQuoteContinuers() QuoteConvention westernEuropeanQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("western_european") ); - Assert.IsNotNull(westernEuropeanQuoteConvention); + Assert.That(westernEuropeanQuoteConvention, Is.Not.Null); var westernEuropeanResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([westernEuropeanQuoteConvention]) ); @@ -2995,26 +3265,22 @@ public void SpanishQuoteContinuers() ); Assert.That( westernEuropeanQuotationMarkResolver - .ResolveQuotationMarks( - [ - new QuotationMarkStringMatch(textSegment1, 0, 1), - new QuotationMarkStringMatch(textSegment1, 11, 12), - new QuotationMarkStringMatch(textSegment2, 0, 1), - new QuotationMarkStringMatch(textSegment2, 1, 2), - new QuotationMarkStringMatch(textSegment2, 18, 19), - new QuotationMarkStringMatch(textSegment2, 25, 26), - ] - ) - .SequenceEqual( - [ - new QuotationMarkMetadata("\u00ab", 1, QuotationMarkDirection.Opening, textSegment1, 0, 1), - new QuotationMarkMetadata("\u201c", 2, QuotationMarkDirection.Opening, textSegment1, 11, 12), - new QuotationMarkMetadata("\u00bb", 1, QuotationMarkDirection.Opening, textSegment2, 0, 1), - new QuotationMarkMetadata("\u201d", 2, QuotationMarkDirection.Opening, textSegment2, 1, 2), - new QuotationMarkMetadata("\u201d", 2, QuotationMarkDirection.Closing, textSegment2, 18, 19), - new QuotationMarkMetadata("\u00bb", 1, QuotationMarkDirection.Closing, textSegment2, 25, 26), - ] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch(textSegment1, 0, 1), + new QuotationMarkStringMatch(textSegment1, 11, 12), + new QuotationMarkStringMatch(textSegment2, 0, 1), + new QuotationMarkStringMatch(textSegment2, 1, 2), + new QuotationMarkStringMatch(textSegment2, 18, 19), + new QuotationMarkStringMatch(textSegment2, 25, 26), + ]) + .SequenceEqual([ + new QuotationMarkMetadata("\u00ab", 1, QuotationMarkDirection.Opening, textSegment1, 0, 1), + new QuotationMarkMetadata("\u201c", 2, QuotationMarkDirection.Opening, textSegment1, 11, 12), + new QuotationMarkMetadata("\u00bb", 1, QuotationMarkDirection.Opening, textSegment2, 0, 1), + new QuotationMarkMetadata("\u201d", 2, QuotationMarkDirection.Opening, textSegment2, 1, 2), + new QuotationMarkMetadata("\u201d", 2, QuotationMarkDirection.Closing, textSegment2, 18, 19), + new QuotationMarkMetadata("\u00bb", 1, QuotationMarkDirection.Closing, textSegment2, 25, 26), + ]) ); Assert.That(westernEuropeanQuotationMarkResolver.GetIssues(), Has.Count.EqualTo(0)); } @@ -3025,7 +3291,7 @@ public void MalformedQuotationMarks() QuoteConvention standardEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("standard_english") ); - Assert.IsNotNull(standardEnglishQuoteConvention); + Assert.That(standardEnglishQuoteConvention, Is.Not.Null); var standardEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([standardEnglishQuoteConvention]) ); @@ -3040,22 +3306,18 @@ public void MalformedQuotationMarks() ); Assert.That( standardEnglishQuotationMarkResolver - .ResolveQuotationMarks( - [ - new QuotationMarkStringMatch(textSegment1, 0, 1), - new QuotationMarkStringMatch(textSegment1, 12, 13), - new QuotationMarkStringMatch(textSegment2, 17, 18), - new QuotationMarkStringMatch(textSegment2, 25, 26), - ] - ) - .SequenceEqual( - [ - new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment1, 0, 1), - new QuotationMarkMetadata("\u2018", 2, QuotationMarkDirection.Opening, textSegment1, 12, 13), - new QuotationMarkMetadata("\u2019", 2, QuotationMarkDirection.Closing, textSegment2, 17, 18), - new QuotationMarkMetadata("\u201d", 1, QuotationMarkDirection.Closing, textSegment2, 25, 26), - ] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch(textSegment1, 0, 1), + new QuotationMarkStringMatch(textSegment1, 12, 13), + new QuotationMarkStringMatch(textSegment2, 17, 18), + new QuotationMarkStringMatch(textSegment2, 25, 26), + ]) + .SequenceEqual([ + new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment1, 0, 1), + new QuotationMarkMetadata("\u2018", 2, QuotationMarkDirection.Opening, textSegment1, 12, 13), + new QuotationMarkMetadata("\u2019", 2, QuotationMarkDirection.Closing, textSegment2, 17, 18), + new QuotationMarkMetadata("\u201d", 1, QuotationMarkDirection.Closing, textSegment2, 25, 26), + ]) ); Assert.That(standardEnglishQuotationMarkResolver.GetIssues(), Has.Count.EqualTo(0)); } @@ -3066,7 +3328,7 @@ public void UnpairedQuotationMarkIssue() QuoteConvention standardEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("standard_english") ); - Assert.IsNotNull(standardEnglishQuoteConvention); + Assert.That(standardEnglishQuoteConvention, Is.Not.Null); var standardEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([standardEnglishQuoteConvention]) ); @@ -3075,20 +3337,16 @@ public void UnpairedQuotationMarkIssue() TextSegment textSegment = new TextSegment.Builder().SetText("\u201cThis is a \u2018quote\u2019").Build(); Assert.That( standardEnglishQuotationMarkResolver - .ResolveQuotationMarks( - [ - new QuotationMarkStringMatch(textSegment, 0, 1), - new QuotationMarkStringMatch(textSegment, 11, 12), - new QuotationMarkStringMatch(textSegment, 17, 18), - ] - ) - .SequenceEqual( - [ - new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), - new QuotationMarkMetadata("\u2018", 2, QuotationMarkDirection.Opening, textSegment, 11, 12), - new QuotationMarkMetadata("\u2019", 2, QuotationMarkDirection.Closing, textSegment, 17, 18), - ] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch(textSegment, 0, 1), + new QuotationMarkStringMatch(textSegment, 11, 12), + new QuotationMarkStringMatch(textSegment, 17, 18), + ]) + .SequenceEqual([ + new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), + new QuotationMarkMetadata("\u2018", 2, QuotationMarkDirection.Opening, textSegment, 11, 12), + new QuotationMarkMetadata("\u2019", 2, QuotationMarkDirection.Closing, textSegment, 17, 18), + ]) ); Assert.That( standardEnglishQuotationMarkResolver @@ -3099,10 +3357,10 @@ public void UnpairedQuotationMarkIssue() textSegment = new TextSegment.Builder().SetText("another quote\u201d").Build(); Assert.That( standardEnglishQuotationMarkResolver - .ResolveQuotationMarks([new QuotationMarkStringMatch(textSegment, 13, 14),]) - .SequenceEqual( - [new QuotationMarkMetadata("\u201d", 1, QuotationMarkDirection.Closing, textSegment, 13, 14),] - ) + .ResolveQuotationMarks([new QuotationMarkStringMatch(textSegment, 13, 14)]) + .SequenceEqual([ + new QuotationMarkMetadata("\u201d", 1, QuotationMarkDirection.Closing, textSegment, 13, 14), + ]) ); Assert.That( standardEnglishQuotationMarkResolver @@ -3117,7 +3375,7 @@ public void TooDeepNestingIssue() QuoteConvention standardEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("standard_english") ); - Assert.IsNotNull(standardEnglishQuoteConvention); + Assert.That(standardEnglishQuoteConvention, Is.Not.Null); var standardEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([standardEnglishQuoteConvention]) ); @@ -3128,30 +3386,27 @@ public void TooDeepNestingIssue() .Build(); Assert.That( standardEnglishQuotationMarkResolver - .ResolveQuotationMarks( - [ - new QuotationMarkStringMatch(textSegment, 0, 1), - new QuotationMarkStringMatch(textSegment, 6, 7), - new QuotationMarkStringMatch(textSegment, 10, 11), - new QuotationMarkStringMatch(textSegment, 13, 14), - new QuotationMarkStringMatch(textSegment, 20, 21), - ] - ) - .SequenceEqual( - [ - new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), - new QuotationMarkMetadata("\u2018", 2, QuotationMarkDirection.Opening, textSegment, 6, 7), - new QuotationMarkMetadata("\u201c", 3, QuotationMarkDirection.Opening, textSegment, 10, 11), - new QuotationMarkMetadata("\u2018", 4, QuotationMarkDirection.Opening, textSegment, 13, 14), - ] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch(textSegment, 0, 1), + new QuotationMarkStringMatch(textSegment, 6, 7), + new QuotationMarkStringMatch(textSegment, 10, 11), + new QuotationMarkStringMatch(textSegment, 13, 14), + new QuotationMarkStringMatch(textSegment, 20, 21), + ]) + .SequenceEqual([ + new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), + new QuotationMarkMetadata("\u2018", 2, QuotationMarkDirection.Opening, textSegment, 6, 7), + new QuotationMarkMetadata("\u201c", 3, QuotationMarkDirection.Opening, textSegment, 10, 11), + new QuotationMarkMetadata("\u2018", 4, QuotationMarkDirection.Opening, textSegment, 13, 14), + ]) ); Assert.That( standardEnglishQuotationMarkResolver .GetIssues() - .SequenceEqual( - [QuotationMarkResolutionIssue.TooDeepNesting, QuotationMarkResolutionIssue.UnpairedQuotationMark,] - ) + .SequenceEqual([ + QuotationMarkResolutionIssue.TooDeepNesting, + QuotationMarkResolutionIssue.UnpairedQuotationMark, + ]) ); } @@ -3161,7 +3416,7 @@ public void IncompatibleQuotationMarkIssue() QuoteConvention standardEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("standard_english") ); - Assert.IsNotNull(standardEnglishQuoteConvention); + Assert.That(standardEnglishQuoteConvention, Is.Not.Null); var standardEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([standardEnglishQuoteConvention]) ); @@ -3170,22 +3425,18 @@ public void IncompatibleQuotationMarkIssue() TextSegment textSegment = new TextSegment.Builder().SetText("\u201cThis is a \u201cquote\u201d\u201d").Build(); Assert.That( standardEnglishQuotationMarkResolver - .ResolveQuotationMarks( - [ - new QuotationMarkStringMatch(textSegment, 0, 1), - new QuotationMarkStringMatch(textSegment, 11, 12), - new QuotationMarkStringMatch(textSegment, 17, 18), - new QuotationMarkStringMatch(textSegment, 18, 19), - ] - ) - .SequenceEqual( - [ - new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), - new QuotationMarkMetadata("\u201c", 2, QuotationMarkDirection.Opening, textSegment, 11, 12), - new QuotationMarkMetadata("\u201d", 2, QuotationMarkDirection.Closing, textSegment, 17, 18), - new QuotationMarkMetadata("\u201d", 1, QuotationMarkDirection.Closing, textSegment, 18, 19), - ] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch(textSegment, 0, 1), + new QuotationMarkStringMatch(textSegment, 11, 12), + new QuotationMarkStringMatch(textSegment, 17, 18), + new QuotationMarkStringMatch(textSegment, 18, 19), + ]) + .SequenceEqual([ + new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), + new QuotationMarkMetadata("\u201c", 2, QuotationMarkDirection.Opening, textSegment, 11, 12), + new QuotationMarkMetadata("\u201d", 2, QuotationMarkDirection.Closing, textSegment, 17, 18), + new QuotationMarkMetadata("\u201d", 1, QuotationMarkDirection.Closing, textSegment, 18, 19), + ]) ); Assert.That( standardEnglishQuotationMarkResolver @@ -3200,7 +3451,7 @@ public void AmbiguousQuotationMarkIssue() QuoteConvention typewriterEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("typewriter_english") ); - Assert.IsNotNull(typewriterEnglishQuoteConvention); + Assert.That(typewriterEnglishQuoteConvention, Is.Not.Null); var typewriterEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([typewriterEnglishQuoteConvention]) ); @@ -3211,7 +3462,7 @@ public void AmbiguousQuotationMarkIssue() TextSegment textSegment = new TextSegment.Builder().SetText("This\"is an ambiguous quotation mark").Build(); Assert.That( typewriterEnglishQuotationMarkResolver - .ResolveQuotationMarks([new QuotationMarkStringMatch(textSegment, 4, 5),]) + .ResolveQuotationMarks([new QuotationMarkStringMatch(textSegment, 4, 5)]) .Count(), Is.EqualTo(0) ); @@ -3242,7 +3493,7 @@ public void TypewriterEnglishQuotationMarkRecognition() QuoteConvention typewriterEnglishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("typewriter_english") ); - Assert.IsNotNull(typewriterEnglishQuoteConvention); + Assert.That(typewriterEnglishQuoteConvention, Is.Not.Null); var typewriterEnglishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([typewriterEnglishQuoteConvention]) ); @@ -3258,22 +3509,18 @@ public void TypewriterEnglishQuotationMarkRecognition() ); Assert.That( typewriterEnglishQuotationMarkResolver - .ResolveQuotationMarks( - [ - new QuotationMarkStringMatch(textSegment, 0, 1), - new QuotationMarkStringMatch(textSegment, 11, 12), - new QuotationMarkStringMatch(textSegment, 17, 18), - new QuotationMarkStringMatch(textSegment, 18, 19), - ] - ) - .SequenceEqual( - [ - new QuotationMarkMetadata("\"", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), - new QuotationMarkMetadata("'", 2, QuotationMarkDirection.Opening, textSegment, 11, 12), - new QuotationMarkMetadata("'", 2, QuotationMarkDirection.Closing, textSegment, 17, 18), - new QuotationMarkMetadata("\"", 1, QuotationMarkDirection.Closing, textSegment, 18, 19), - ] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch(textSegment, 0, 1), + new QuotationMarkStringMatch(textSegment, 11, 12), + new QuotationMarkStringMatch(textSegment, 17, 18), + new QuotationMarkStringMatch(textSegment, 18, 19), + ]) + .SequenceEqual([ + new QuotationMarkMetadata("\"", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), + new QuotationMarkMetadata("'", 2, QuotationMarkDirection.Opening, textSegment, 11, 12), + new QuotationMarkMetadata("'", 2, QuotationMarkDirection.Closing, textSegment, 17, 18), + new QuotationMarkMetadata("\"", 1, QuotationMarkDirection.Closing, textSegment, 18, 19), + ]) ); Assert.That(typewriterEnglishQuotationMarkResolver.GetIssues(), Has.Count.EqualTo(0)); } @@ -3284,7 +3531,7 @@ public void TypewriterFrenchMarkRecognition() QuoteConvention typewriterFrenchQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("typewriter_french") ); - Assert.IsNotNull(typewriterFrenchQuoteConvention); + Assert.That(typewriterFrenchQuoteConvention, Is.Not.Null); var typewriterFrenchResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([typewriterFrenchQuoteConvention]) ); @@ -3295,22 +3542,18 @@ public void TypewriterFrenchMarkRecognition() TextSegment textSegment = new TextSegment.Builder().SetText("<>>").Build(); Assert.That( typewriterFrenchQuotationMarkResolver - .ResolveQuotationMarks( - [ - new QuotationMarkStringMatch(textSegment, 0, 2), - new QuotationMarkStringMatch(textSegment, 12, 13), - new QuotationMarkStringMatch(textSegment, 18, 19), - new QuotationMarkStringMatch(textSegment, 19, 21), - ] - ) - .SequenceEqual( - [ - new QuotationMarkMetadata("<<", 1, QuotationMarkDirection.Opening, textSegment, 0, 2), - new QuotationMarkMetadata("<", 2, QuotationMarkDirection.Opening, textSegment, 12, 13), - new QuotationMarkMetadata(">", 2, QuotationMarkDirection.Closing, textSegment, 18, 19), - new QuotationMarkMetadata(">>", 1, QuotationMarkDirection.Closing, textSegment, 19, 21), - ] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch(textSegment, 0, 2), + new QuotationMarkStringMatch(textSegment, 12, 13), + new QuotationMarkStringMatch(textSegment, 18, 19), + new QuotationMarkStringMatch(textSegment, 19, 21), + ]) + .SequenceEqual([ + new QuotationMarkMetadata("<<", 1, QuotationMarkDirection.Opening, textSegment, 0, 2), + new QuotationMarkMetadata("<", 2, QuotationMarkDirection.Opening, textSegment, 12, 13), + new QuotationMarkMetadata(">", 2, QuotationMarkDirection.Closing, textSegment, 18, 19), + new QuotationMarkMetadata(">>", 1, QuotationMarkDirection.Closing, textSegment, 19, 21), + ]) ); Assert.That(typewriterFrenchQuotationMarkResolver.GetIssues(), Has.Count.EqualTo(0)); } @@ -3321,7 +3564,7 @@ public void CentralEuropeanQuotationMarkRecognition() QuoteConvention centralEuropeanQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("central_european") ); - Assert.IsNotNull(centralEuropeanQuoteConvention); + Assert.That(centralEuropeanQuoteConvention, Is.Not.Null); var centralEuropeanResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([centralEuropeanQuoteConvention]) ); @@ -3335,22 +3578,18 @@ public void CentralEuropeanQuotationMarkRecognition() ); Assert.That( centralEuropeanQuotationMarkResolver - .ResolveQuotationMarks( - [ - new QuotationMarkStringMatch(textSegment, 0, 1), - new QuotationMarkStringMatch(textSegment, 11, 12), - new QuotationMarkStringMatch(textSegment, 17, 18), - new QuotationMarkStringMatch(textSegment, 18, 19), - ] - ) - .SequenceEqual( - [ - new QuotationMarkMetadata("\u201e", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), - new QuotationMarkMetadata("\u201a", 2, QuotationMarkDirection.Opening, textSegment, 11, 12), - new QuotationMarkMetadata("\u2018", 2, QuotationMarkDirection.Closing, textSegment, 17, 18), - new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Closing, textSegment, 18, 19), - ] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch(textSegment, 0, 1), + new QuotationMarkStringMatch(textSegment, 11, 12), + new QuotationMarkStringMatch(textSegment, 17, 18), + new QuotationMarkStringMatch(textSegment, 18, 19), + ]) + .SequenceEqual([ + new QuotationMarkMetadata("\u201e", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), + new QuotationMarkMetadata("\u201a", 2, QuotationMarkDirection.Opening, textSegment, 11, 12), + new QuotationMarkMetadata("\u2018", 2, QuotationMarkDirection.Closing, textSegment, 17, 18), + new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Closing, textSegment, 18, 19), + ]) ); Assert.That(centralEuropeanQuotationMarkResolver.GetIssues(), Has.Count.EqualTo(0)); } @@ -3361,7 +3600,7 @@ public void StandardSwedishQuotationMarkRecognition() QuoteConvention standardSwedishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("standard_swedish") ); - Assert.IsNotNull(standardSwedishQuoteConvention); + Assert.That(standardSwedishQuoteConvention, Is.Not.Null); var standardSwedishResolverSettings = new QuoteConventionDetectionResolutionSettings( new QuoteConventionSet([standardSwedishQuoteConvention]) ); @@ -3375,22 +3614,18 @@ public void StandardSwedishQuotationMarkRecognition() ); Assert.That( standardSwedishQuotationMarkResolver - .ResolveQuotationMarks( - [ - new QuotationMarkStringMatch(textSegment, 0, 1), - new QuotationMarkStringMatch(textSegment, 11, 12), - new QuotationMarkStringMatch(textSegment, 17, 18), - new QuotationMarkStringMatch(textSegment, 18, 19), - ] - ) - .SequenceEqual( - [ - new QuotationMarkMetadata("\u201d", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), - new QuotationMarkMetadata("\u2019", 2, QuotationMarkDirection.Opening, textSegment, 11, 12), - new QuotationMarkMetadata("\u2019", 2, QuotationMarkDirection.Closing, textSegment, 17, 18), - new QuotationMarkMetadata("\u201d", 1, QuotationMarkDirection.Closing, textSegment, 18, 19), - ] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch(textSegment, 0, 1), + new QuotationMarkStringMatch(textSegment, 11, 12), + new QuotationMarkStringMatch(textSegment, 17, 18), + new QuotationMarkStringMatch(textSegment, 18, 19), + ]) + .SequenceEqual([ + new QuotationMarkMetadata("\u201d", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), + new QuotationMarkMetadata("\u2019", 2, QuotationMarkDirection.Opening, textSegment, 11, 12), + new QuotationMarkMetadata("\u2019", 2, QuotationMarkDirection.Closing, textSegment, 17, 18), + new QuotationMarkMetadata("\u201d", 1, QuotationMarkDirection.Closing, textSegment, 18, 19), + ]) ); Assert.That(standardSwedishQuotationMarkResolver.GetIssues(), Has.Count.EqualTo(0)); } @@ -3402,21 +3637,23 @@ public void MultipleConventionsQuotationMarkRecognition() "typewriter_french" ); - Assert.IsNotNull(typewriterFrenchQuoteConvention); + Assert.That(typewriterFrenchQuoteConvention, Is.Not.Null); QuoteConvention centralEuropeanQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("central_european") ); - Assert.IsNotNull(centralEuropeanQuoteConvention); + Assert.That(centralEuropeanQuoteConvention, Is.Not.Null); QuoteConvention standardSwedishQuoteConvention = ( QuoteConventions.Standard.GetQuoteConventionByName("standard_swedish") ); - Assert.IsNotNull(standardSwedishQuoteConvention); + Assert.That(standardSwedishQuoteConvention, Is.Not.Null); var multipleConventionsResolverSettings = new QuoteConventionDetectionResolutionSettings( - new QuoteConventionSet( - [typewriterFrenchQuoteConvention, centralEuropeanQuoteConvention, standardSwedishQuoteConvention] - ) + new QuoteConventionSet([ + typewriterFrenchQuoteConvention, + centralEuropeanQuoteConvention, + standardSwedishQuoteConvention, + ]) ); var multipleConventionsQuotationMarkResolver = new DepthBasedQuotationMarkResolver( multipleConventionsResolverSettings @@ -3430,22 +3667,18 @@ public void MultipleConventionsQuotationMarkRecognition() ); Assert.That( multipleConventionsQuotationMarkResolver - .ResolveQuotationMarks( - [ - new QuotationMarkStringMatch(textSegment, 0, 1), - new QuotationMarkStringMatch(textSegment, 11, 12), - new QuotationMarkStringMatch(textSegment, 17, 18), - new QuotationMarkStringMatch(textSegment, 18, 19), - ] - ) - .SequenceEqual( - [ - new QuotationMarkMetadata("\u201e", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), - new QuotationMarkMetadata("\u2019", 2, QuotationMarkDirection.Opening, textSegment, 11, 12), - new QuotationMarkMetadata(">", 2, QuotationMarkDirection.Closing, textSegment, 17, 18), - new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Closing, textSegment, 18, 19), - ] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch(textSegment, 0, 1), + new QuotationMarkStringMatch(textSegment, 11, 12), + new QuotationMarkStringMatch(textSegment, 17, 18), + new QuotationMarkStringMatch(textSegment, 18, 19), + ]) + .SequenceEqual([ + new QuotationMarkMetadata("\u201e", 1, QuotationMarkDirection.Opening, textSegment, 0, 1), + new QuotationMarkMetadata("\u2019", 2, QuotationMarkDirection.Opening, textSegment, 11, 12), + new QuotationMarkMetadata(">", 2, QuotationMarkDirection.Closing, textSegment, 17, 18), + new QuotationMarkMetadata("\u201c", 1, QuotationMarkDirection.Closing, textSegment, 18, 19), + ]) ); Assert.That(multipleConventionsQuotationMarkResolver.GetIssues(), Has.Count.EqualTo(0)); } diff --git a/tests/SIL.Machine.Tests/PunctuationAnalysis/FallbackQuotationMarkResolverTests.cs b/tests/SIL.Machine.Tests/PunctuationAnalysis/FallbackQuotationMarkResolverTests.cs index 5a6ea8aee..17ebda93a 100644 --- a/tests/SIL.Machine.Tests/PunctuationAnalysis/FallbackQuotationMarkResolverTests.cs +++ b/tests/SIL.Machine.Tests/PunctuationAnalysis/FallbackQuotationMarkResolverTests.cs @@ -9,7 +9,7 @@ public class FallbackQuotationMarkResolverTests public void Reset() { QuoteConvention englishQuoteConvention = QuoteConventions.Standard.GetQuoteConventionByName("standard_english"); - Assert.IsNotNull(englishQuoteConvention); + Assert.That(englishQuoteConvention, Is.Not.Null); var basicQuotationMarkResolver = new FallbackQuotationMarkResolver( new QuotationMarkUpdateResolutionSettings(englishQuoteConvention) @@ -26,7 +26,7 @@ public void Reset() basicQuotationMarkResolver.Issues.Add(QuotationMarkResolutionIssue.UnexpectedQuotationMark); basicQuotationMarkResolver.Reset(); - Assert.IsNull(basicQuotationMarkResolver.LastQuotationMark); + Assert.That(basicQuotationMarkResolver.LastQuotationMark, Is.Null); Assert.That(basicQuotationMarkResolver.Issues.Count, Is.EqualTo(0)); } @@ -34,16 +34,16 @@ public void Reset() public void SimpleQuotationMarkResolutionWithNoPreviousMark() { QuoteConvention englishQuoteConvention = QuoteConventions.Standard.GetQuoteConventionByName("standard_english"); - Assert.IsNotNull(englishQuoteConvention); + Assert.That(englishQuoteConvention, Is.Not.Null); var basicQuotationMarkResolver = new FallbackQuotationMarkResolver( new QuotationMarkUpdateResolutionSettings(englishQuoteConvention.Normalize()) ); var actualResolvedQuotationMarks = basicQuotationMarkResolver - .ResolveQuotationMarks( - [new QuotationMarkStringMatch(new TextSegment.Builder().SetText("test \" text").Build(), 5, 6),] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch(new TextSegment.Builder().SetText("test \" text").Build(), 5, 6), + ]) .ToList(); List expectedResolvedQuotationMarks = [ @@ -54,7 +54,7 @@ [new QuotationMarkStringMatch(new TextSegment.Builder().SetText("test \" text"). new TextSegment.Builder().SetText("test \" text").Build(), 5, 6 - ) + ), ]; AssertResolvedQuotationMarksEqual(actualResolvedQuotationMarks, expectedResolvedQuotationMarks); @@ -64,19 +64,17 @@ [new QuotationMarkStringMatch(new TextSegment.Builder().SetText("test \" text"). public void SimpleQuotationMarkResolutionWithPreviousOpeningMark() { QuoteConvention englishQuoteConvention = QuoteConventions.Standard.GetQuoteConventionByName("standard_english"); - Assert.IsNotNull(englishQuoteConvention); + Assert.That(englishQuoteConvention, Is.Not.Null); var basicQuotationMarkResolver = new FallbackQuotationMarkResolver( new QuotationMarkUpdateResolutionSettings(englishQuoteConvention.Normalize()) ); var actualResolvedQuotationMarks = basicQuotationMarkResolver - .ResolveQuotationMarks( - [ - new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"test \" text").Build(), 0, 1), - new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"test \" text").Build(), 6, 7), - ] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"test \" text").Build(), 0, 1), + new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"test \" text").Build(), 6, 7), + ]) .ToList(); List expectedResolvedQuotationMarks = [ @@ -105,19 +103,17 @@ public void SimpleQuotationMarkResolutionWithPreviousOpeningMark() public void SimpleQuotationMarkResolutionWithPreviousClosingMark() { QuoteConvention englishQuoteConvention = QuoteConventions.Standard.GetQuoteConventionByName("standard_english"); - Assert.IsNotNull(englishQuoteConvention); + Assert.That(englishQuoteConvention, Is.Not.Null); var basicQuotationMarkResolver = new FallbackQuotationMarkResolver( new QuotationMarkUpdateResolutionSettings(englishQuoteConvention.Normalize()) ); var actualResolvedQuotationMarks = basicQuotationMarkResolver - .ResolveQuotationMarks( - [ - new QuotationMarkStringMatch(new TextSegment.Builder().SetText("test\" \" text").Build(), 4, 5), - new QuotationMarkStringMatch(new TextSegment.Builder().SetText("test\" \" text").Build(), 6, 7), - ] - ) + .ResolveQuotationMarks([ + new QuotationMarkStringMatch(new TextSegment.Builder().SetText("test\" \" text").Build(), 4, 5), + new QuotationMarkStringMatch(new TextSegment.Builder().SetText("test\" \" text").Build(), 6, 7), + ]) .ToList(); List expectedResolvedQuotationMarks = [ @@ -136,7 +132,7 @@ public void SimpleQuotationMarkResolutionWithPreviousClosingMark() new TextSegment.Builder().SetText("test\" \" text").Build(), 6, 7 - ) + ), ]; AssertResolvedQuotationMarksEqual(actualResolvedQuotationMarks, expectedResolvedQuotationMarks); @@ -146,7 +142,7 @@ public void SimpleQuotationMarkResolutionWithPreviousClosingMark() public void IsOpeningQuote() { QuoteConvention englishQuoteConvention = QuoteConventions.Standard.GetQuoteConventionByName("standard_english"); - Assert.IsNotNull(englishQuoteConvention); + Assert.That(englishQuoteConvention, Is.Not.Null); var basicQuotationMarkResolver = new FallbackQuotationMarkResolver( new QuotationMarkUpdateResolutionSettings(englishQuoteConvention.Normalize()) @@ -154,42 +150,42 @@ public void IsOpeningQuote() // valid opening quote at start of segment var quoteMatch = new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"test text\"").Build(), 0, 1); - Assert.IsTrue(basicQuotationMarkResolver.IsOpeningQuotationMark(quoteMatch)); + Assert.That(basicQuotationMarkResolver.IsOpeningQuotationMark(quoteMatch), Is.True); // opening quote with leading whitespace quoteMatch = new QuotationMarkStringMatch(new TextSegment.Builder().SetText("test \"text\"").Build(), 5, 6); - Assert.IsTrue(basicQuotationMarkResolver.IsOpeningQuotationMark(quoteMatch)); + Assert.That(basicQuotationMarkResolver.IsOpeningQuotationMark(quoteMatch), Is.True); // opening quote with quote introducer quoteMatch = new QuotationMarkStringMatch(new TextSegment.Builder().SetText("test:\"text\"").Build(), 5, 6); - Assert.IsTrue(basicQuotationMarkResolver.IsOpeningQuotationMark(quoteMatch)); + Assert.That(basicQuotationMarkResolver.IsOpeningQuotationMark(quoteMatch), Is.True); // QuotationMarkStringMatch indices don't indicate a quotation mark quoteMatch = new QuotationMarkStringMatch(new TextSegment.Builder().SetText("test \"text\"").Build(), 0, 1); - Assert.IsFalse(basicQuotationMarkResolver.IsOpeningQuotationMark(quoteMatch)); + Assert.That(basicQuotationMarkResolver.IsOpeningQuotationMark(quoteMatch), Is.False); // the quotation mark is not valid under the current quote convention quoteMatch = new QuotationMarkStringMatch(new TextSegment.Builder().SetText("").Build(), 10, 11); - Assert.IsFalse(basicQuotationMarkResolver.IsClosingQuotationMark(quoteMatch)); + Assert.That(basicQuotationMarkResolver.IsClosingQuotationMark(quoteMatch), Is.False); // no trailing whitespace after quotation mark quoteMatch = new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"test\"text").Build(), 5, 6); - Assert.IsFalse(basicQuotationMarkResolver.IsClosingQuotationMark(quoteMatch)); + Assert.That(basicQuotationMarkResolver.IsClosingQuotationMark(quoteMatch), Is.False); // opening quote at the start of the segment quoteMatch = new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"test text\"").Build(), 0, 1); - Assert.IsFalse(basicQuotationMarkResolver.IsClosingQuotationMark(quoteMatch)); + Assert.That(basicQuotationMarkResolver.IsClosingQuotationMark(quoteMatch), Is.False); // opening quote with leading whitespace quoteMatch = new QuotationMarkStringMatch(new TextSegment.Builder().SetText("test \"text\"").Build(), 5, 6); - Assert.IsFalse(basicQuotationMarkResolver.IsClosingQuotationMark(quoteMatch)); + Assert.That(basicQuotationMarkResolver.IsClosingQuotationMark(quoteMatch), Is.False); } [Test] public void IsClosingQuoteWithUnambiguousQuoteConvention() { QuoteConvention englishQuoteConvention = QuoteConventions.Standard.GetQuoteConventionByName("standard_english"); - Assert.IsNotNull(englishQuoteConvention); + Assert.That(englishQuoteConvention, Is.Not.Null); var basicQuotationMarkResolver = new FallbackQuotationMarkResolver( new QuoteConventionDetectionResolutionSettings(new QuoteConventionSet([englishQuoteConvention])) @@ -369,26 +365,26 @@ public void IsClosingQuoteWithUnambiguousQuoteConvention() // unambiguous closing quote at end of segment var quoteMatch = new QuotationMarkStringMatch(new TextSegment.Builder().SetText("“test text”").Build(), 10, 11); - Assert.IsTrue(basicQuotationMarkResolver.IsClosingQuotationMark(quoteMatch)); + Assert.That(basicQuotationMarkResolver.IsClosingQuotationMark(quoteMatch), Is.True); // unambiguous closing quote with trailing whitespace quoteMatch = new QuotationMarkStringMatch(new TextSegment.Builder().SetText("“test” text").Build(), 5, 6); - Assert.IsTrue(basicQuotationMarkResolver.IsClosingQuotationMark(quoteMatch)); + Assert.That(basicQuotationMarkResolver.IsClosingQuotationMark(quoteMatch), Is.True); // unambiguous closing quote without the "correct" context quoteMatch = new QuotationMarkStringMatch(new TextSegment.Builder().SetText("“test”text").Build(), 5, 6); - Assert.IsTrue(basicQuotationMarkResolver.IsClosingQuotationMark(quoteMatch)); + Assert.That(basicQuotationMarkResolver.IsClosingQuotationMark(quoteMatch), Is.True); // unambiguous opening quote quoteMatch = new QuotationMarkStringMatch(new TextSegment.Builder().SetText("test “text”").Build(), 5, 6); - Assert.IsFalse(basicQuotationMarkResolver.IsClosingQuotationMark(quoteMatch)); + Assert.That(basicQuotationMarkResolver.IsClosingQuotationMark(quoteMatch), Is.False); } [Test] public void ResolveOpeningQuote() { QuoteConvention englishQuoteConvention = QuoteConventions.Standard.GetQuoteConventionByName("standard_english"); - Assert.IsNotNull(englishQuoteConvention); + Assert.That(englishQuoteConvention, Is.Not.Null); var basicQuotationMarkResolver = new FallbackQuotationMarkResolver( new QuotationMarkUpdateResolutionSettings(englishQuoteConvention.Normalize()) @@ -413,7 +409,7 @@ public void ResolveOpeningQuote() public void ResolveClosingQuote() { QuoteConvention englishQuoteConvention = QuoteConventions.Standard.GetQuoteConventionByName("standard_english"); - Assert.IsNotNull(englishQuoteConvention); + Assert.That(englishQuoteConvention, Is.Not.Null); var basicQuotationMarkResolver = new FallbackQuotationMarkResolver( new QuotationMarkUpdateResolutionSettings(englishQuoteConvention.Normalize()) diff --git a/tests/SIL.Machine.Tests/PunctuationAnalysis/ParatextProjectQuoteConventionDetectorTests.cs b/tests/SIL.Machine.Tests/PunctuationAnalysis/ParatextProjectQuoteConventionDetectorTests.cs index 09bc1e0c7..6b10ddbff 100644 --- a/tests/SIL.Machine.Tests/PunctuationAnalysis/ParatextProjectQuoteConventionDetectorTests.cs +++ b/tests/SIL.Machine.Tests/PunctuationAnalysis/ParatextProjectQuoteConventionDetectorTests.cs @@ -23,7 +23,7 @@ public void TestGetQuotationAnalysis() $@"\id MAT {GetTestChapter(1, StandardEnglishQuoteConvention)} " - } + }, } ); QuoteConventionAnalysis analysis = env.GetQuoteConvention(); @@ -49,7 +49,7 @@ public void TestGetQuotationByBook() $@"\id MRK {GetTestChapter(1, StandardFrenchQuoteConvention)} " - } + }, } ); QuoteConventionAnalysis analysis = env.GetQuoteConvention("MRK"); @@ -79,7 +79,7 @@ public void TestGetQuoteConventionByChapter() {GetTestChapter(4, StandardEnglishQuoteConvention)} {GetTestChapter(5, StandardFrenchQuoteConvention)} " - } + }, } ); QuoteConventionAnalysis analysis = env.GetQuoteConvention("MRK2,4-5"); @@ -101,7 +101,7 @@ public void TestGetQuoteConventionByChapterIndeterminate() {GetTestChapter(2, StandardEnglishQuoteConvention)} {GetTestChapter(3)} " - } + }, } ); QuoteConventionAnalysis analysis = env.GetQuoteConvention("MAT1,3"); @@ -119,7 +119,7 @@ public void TestGetQuoteConventionInvalidBookCode() $@"\id LUK {GetTestChapter(1, StandardEnglishQuoteConvention)} " - } + }, } ); QuoteConventionAnalysis analysis = env.GetQuoteConvention("MAT"); @@ -144,7 +144,7 @@ public void TestGetQuoteConventionWeightedAverageOfMultipleBooks() \c 1 \v 1 This ""sentence uses a different"" convention " - } + }, } ); QuoteConventionAnalysis analysis = env.GetQuoteConvention(); diff --git a/tests/SIL.Machine.Tests/PunctuationAnalysis/PreliminaryQuotationMarkAnalyzerTests.cs b/tests/SIL.Machine.Tests/PunctuationAnalysis/PreliminaryQuotationMarkAnalyzerTests.cs index 29d04e551..858baf8af 100644 --- a/tests/SIL.Machine.Tests/PunctuationAnalysis/PreliminaryQuotationMarkAnalyzerTests.cs +++ b/tests/SIL.Machine.Tests/PunctuationAnalysis/PreliminaryQuotationMarkAnalyzerTests.cs @@ -12,33 +12,33 @@ public void ApostropheProportionStatisticsReset() var apostropheProportionStatistics = new ApostropheProportionStatistics(); apostropheProportionStatistics.CountCharacters(new TextSegment.Builder().SetText("'").Build()); apostropheProportionStatistics.AddApostrophe(); - Assert.IsTrue(apostropheProportionStatistics.IsApostropheProportionGreaterThan(0.5)); + Assert.That(apostropheProportionStatistics.IsApostropheProportionGreaterThan(0.5), Is.True); apostropheProportionStatistics.Reset(); - Assert.IsFalse(apostropheProportionStatistics.IsApostropheProportionGreaterThan(0.5)); + Assert.That(apostropheProportionStatistics.IsApostropheProportionGreaterThan(0.5), Is.False); } [Test] public void IsApostropheProportionGreaterThan() { var apostropheProportionStatistics = new ApostropheProportionStatistics(); - Assert.IsFalse(apostropheProportionStatistics.IsApostropheProportionGreaterThan(0.0)); + Assert.That(apostropheProportionStatistics.IsApostropheProportionGreaterThan(0.0), Is.False); // invalid case where no characters have been counted apostropheProportionStatistics.AddApostrophe(); - Assert.IsFalse(apostropheProportionStatistics.IsApostropheProportionGreaterThan(0.0)); + Assert.That(apostropheProportionStatistics.IsApostropheProportionGreaterThan(0.0), Is.False); apostropheProportionStatistics.CountCharacters(new TextSegment.Builder().SetText("a").Build()); - Assert.IsTrue(apostropheProportionStatistics.IsApostropheProportionGreaterThan(0.99)); + Assert.That(apostropheProportionStatistics.IsApostropheProportionGreaterThan(0.99), Is.True); apostropheProportionStatistics.AddApostrophe(); apostropheProportionStatistics.CountCharacters(new TextSegment.Builder().SetText("bcd").Build()); - Assert.IsTrue(apostropheProportionStatistics.IsApostropheProportionGreaterThan(0.4)); - Assert.IsFalse(apostropheProportionStatistics.IsApostropheProportionGreaterThan(0.5)); + Assert.That(apostropheProportionStatistics.IsApostropheProportionGreaterThan(0.4), Is.True); + Assert.That(apostropheProportionStatistics.IsApostropheProportionGreaterThan(0.5), Is.False); apostropheProportionStatistics.CountCharacters(new TextSegment.Builder().SetText("ef").Build()); - Assert.IsTrue(apostropheProportionStatistics.IsApostropheProportionGreaterThan(0.3)); - Assert.IsFalse(apostropheProportionStatistics.IsApostropheProportionGreaterThan(0.4)); + Assert.That(apostropheProportionStatistics.IsApostropheProportionGreaterThan(0.3), Is.True); + Assert.That(apostropheProportionStatistics.IsApostropheProportionGreaterThan(0.4), Is.False); } #endregion @@ -48,13 +48,13 @@ public void IsApostropheProportionGreaterThan() public void IsMarkRarelyInitial() { var quotationMarkWordPositions = new QuotationMarkWordPositions(); - Assert.IsFalse(quotationMarkWordPositions.IsMarkRarelyInitial("\u201d")); + Assert.That(quotationMarkWordPositions.IsMarkRarelyInitial("\u201d"), Is.False); quotationMarkWordPositions.CountWordFinalApostrophe("\u201d"); - Assert.IsTrue(quotationMarkWordPositions.IsMarkRarelyInitial("\u201d")); + Assert.That(quotationMarkWordPositions.IsMarkRarelyInitial("\u201d"), Is.True); quotationMarkWordPositions.CountWordInitialApostrophe("\u201d"); - Assert.IsFalse(quotationMarkWordPositions.IsMarkRarelyInitial("\u201d")); + Assert.That(quotationMarkWordPositions.IsMarkRarelyInitial("\u201d"), Is.False); quotationMarkWordPositions.CountWordFinalApostrophe("\u201d"); quotationMarkWordPositions.CountWordFinalApostrophe("\u201d"); @@ -66,31 +66,31 @@ public void IsMarkRarelyInitial() quotationMarkWordPositions.CountWordFinalApostrophe("\u201d"); quotationMarkWordPositions.CountWordFinalApostrophe("\u201d"); quotationMarkWordPositions.CountWordFinalApostrophe("\u201d"); - Assert.IsTrue(quotationMarkWordPositions.IsMarkRarelyInitial("\u201d")); + Assert.That(quotationMarkWordPositions.IsMarkRarelyInitial("\u201d"), Is.True); quotationMarkWordPositions.CountWordFinalApostrophe("\u201c"); - Assert.IsTrue(quotationMarkWordPositions.IsMarkRarelyInitial("\u201d")); + Assert.That(quotationMarkWordPositions.IsMarkRarelyInitial("\u201d"), Is.True); quotationMarkWordPositions.CountWordFinalApostrophe("\u201c"); quotationMarkWordPositions.CountWordInitialApostrophe("\u201c"); - Assert.IsTrue(quotationMarkWordPositions.IsMarkRarelyInitial("\u201d")); + Assert.That(quotationMarkWordPositions.IsMarkRarelyInitial("\u201d"), Is.True); quotationMarkWordPositions.CountWordInitialApostrophe("\u201d"); quotationMarkWordPositions.CountMidWordApostrophe("\u201d"); - Assert.IsFalse(quotationMarkWordPositions.IsMarkRarelyInitial("\u201d")); + Assert.That(quotationMarkWordPositions.IsMarkRarelyInitial("\u201d"), Is.False); } [Test] public void IsMarkRarelyFinal() { var quotationMarkWordPositions = new QuotationMarkWordPositions(); - Assert.IsFalse(quotationMarkWordPositions.IsMarkRarelyFinal("\u201d")); + Assert.That(quotationMarkWordPositions.IsMarkRarelyFinal("\u201d"), Is.False); quotationMarkWordPositions.CountWordInitialApostrophe("\u201d"); - Assert.IsTrue(quotationMarkWordPositions.IsMarkRarelyFinal("\u201d")); + Assert.That(quotationMarkWordPositions.IsMarkRarelyFinal("\u201d"), Is.True); quotationMarkWordPositions.CountWordFinalApostrophe("\u201d"); - Assert.IsFalse(quotationMarkWordPositions.IsMarkRarelyFinal("\u201d")); + Assert.That(quotationMarkWordPositions.IsMarkRarelyFinal("\u201d"), Is.False); quotationMarkWordPositions.CountWordInitialApostrophe("\u201d"); quotationMarkWordPositions.CountWordInitialApostrophe("\u201d"); @@ -102,41 +102,41 @@ public void IsMarkRarelyFinal() quotationMarkWordPositions.CountWordInitialApostrophe("\u201d"); quotationMarkWordPositions.CountWordInitialApostrophe("\u201d"); quotationMarkWordPositions.CountWordInitialApostrophe("\u201d"); - Assert.IsTrue(quotationMarkWordPositions.IsMarkRarelyFinal("\u201d")); + Assert.That(quotationMarkWordPositions.IsMarkRarelyFinal("\u201d"), Is.True); quotationMarkWordPositions.CountWordInitialApostrophe("\u201c"); - Assert.IsTrue(quotationMarkWordPositions.IsMarkRarelyFinal("\u201d")); + Assert.That(quotationMarkWordPositions.IsMarkRarelyFinal("\u201d"), Is.True); quotationMarkWordPositions.CountWordInitialApostrophe("\u201c"); quotationMarkWordPositions.CountWordFinalApostrophe("\u201c"); - Assert.IsTrue(quotationMarkWordPositions.IsMarkRarelyFinal("\u201d")); + Assert.That(quotationMarkWordPositions.IsMarkRarelyFinal("\u201d"), Is.True); quotationMarkWordPositions.CountWordFinalApostrophe("\u201d"); quotationMarkWordPositions.CountMidWordApostrophe("\u201d"); - Assert.IsFalse(quotationMarkWordPositions.IsMarkRarelyFinal("\u201d")); + Assert.That(quotationMarkWordPositions.IsMarkRarelyFinal("\u201d"), Is.False); } [Test] public void AreInitialAndFinalRatesSimilar() { var quotationMarkWordPositions = new QuotationMarkWordPositions(); - Assert.IsFalse(quotationMarkWordPositions.AreInitialAndFinalRatesSimilar("\u201d")); + Assert.That(quotationMarkWordPositions.AreInitialAndFinalRatesSimilar("\u201d"), Is.False); quotationMarkWordPositions.CountWordInitialApostrophe("\u201d"); quotationMarkWordPositions.CountWordFinalApostrophe("\u201d"); - Assert.IsTrue(quotationMarkWordPositions.AreInitialAndFinalRatesSimilar("\u201d")); + Assert.That(quotationMarkWordPositions.AreInitialAndFinalRatesSimilar("\u201d"), Is.True); quotationMarkWordPositions.CountWordInitialApostrophe("\u201d"); - Assert.IsFalse(quotationMarkWordPositions.AreInitialAndFinalRatesSimilar("\u201d")); + Assert.That(quotationMarkWordPositions.AreInitialAndFinalRatesSimilar("\u201d"), Is.False); quotationMarkWordPositions.CountWordInitialApostrophe("\u201d"); quotationMarkWordPositions.CountWordFinalApostrophe("\u201d"); - Assert.IsTrue(quotationMarkWordPositions.AreInitialAndFinalRatesSimilar("\u201d")); + Assert.That(quotationMarkWordPositions.AreInitialAndFinalRatesSimilar("\u201d"), Is.True); quotationMarkWordPositions.CountWordInitialApostrophe("\u201d"); quotationMarkWordPositions.CountWordInitialApostrophe("\u201d"); quotationMarkWordPositions.CountWordInitialApostrophe("\u201d"); - Assert.IsFalse(quotationMarkWordPositions.AreInitialAndFinalRatesSimilar("\u201d")); + Assert.That(quotationMarkWordPositions.AreInitialAndFinalRatesSimilar("\u201d"), Is.False); quotationMarkWordPositions.CountMidWordApostrophe("\u201d"); quotationMarkWordPositions.CountMidWordApostrophe("\u201d"); @@ -144,26 +144,26 @@ public void AreInitialAndFinalRatesSimilar() quotationMarkWordPositions.CountMidWordApostrophe("\u201d"); quotationMarkWordPositions.CountMidWordApostrophe("\u201d"); quotationMarkWordPositions.CountMidWordApostrophe("\u201d"); - Assert.IsTrue(quotationMarkWordPositions.AreInitialAndFinalRatesSimilar("\u201d")); + Assert.That(quotationMarkWordPositions.AreInitialAndFinalRatesSimilar("\u201d"), Is.True); } [Test] public void IsMarkCommonlyMidWord() { var quotationMarkWordPositions = new QuotationMarkWordPositions(); - Assert.IsFalse(quotationMarkWordPositions.IsMarkCommonlyMidWord("'")); + Assert.That(quotationMarkWordPositions.IsMarkCommonlyMidWord("'"), Is.False); quotationMarkWordPositions.CountMidWordApostrophe("'"); - Assert.IsTrue(quotationMarkWordPositions.IsMarkCommonlyMidWord("'")); + Assert.That(quotationMarkWordPositions.IsMarkCommonlyMidWord("'"), Is.True); quotationMarkWordPositions.CountWordInitialApostrophe("'"); quotationMarkWordPositions.CountWordFinalApostrophe("'"); quotationMarkWordPositions.CountWordInitialApostrophe("'"); quotationMarkWordPositions.CountWordFinalApostrophe("'"); - Assert.IsFalse(quotationMarkWordPositions.IsMarkCommonlyMidWord("'")); + Assert.That(quotationMarkWordPositions.IsMarkCommonlyMidWord("'"), Is.False); quotationMarkWordPositions.CountMidWordApostrophe("'"); - Assert.IsTrue(quotationMarkWordPositions.IsMarkCommonlyMidWord("'")); + Assert.That(quotationMarkWordPositions.IsMarkCommonlyMidWord("'"), Is.True); } [Test] @@ -175,11 +175,11 @@ public void QuotationMarkWordPositionsReset() quotationMarkWordPositions.CountMidWordApostrophe("\u201d"); quotationMarkWordPositions.CountMidWordApostrophe("\u201d"); - Assert.IsTrue(quotationMarkWordPositions.IsMarkCommonlyMidWord("\u201d")); + Assert.That(quotationMarkWordPositions.IsMarkCommonlyMidWord("\u201d"), Is.True); quotationMarkWordPositions.Reset(); - Assert.IsFalse(quotationMarkWordPositions.IsMarkCommonlyMidWord("\u201d")); + Assert.That(quotationMarkWordPositions.IsMarkCommonlyMidWord("\u201d"), Is.False); } #endregion #region QuotationMarkSequence @@ -188,7 +188,7 @@ public void QuotationMarkWordPositionsReset() public void IsMarkMuchMoreCommonEarlier() { var quotationMarkSequences = new QuotationMarkSequences(); - Assert.IsFalse(quotationMarkSequences.IsMarkMuchMoreCommonEarlier("\"")); + Assert.That(quotationMarkSequences.IsMarkMuchMoreCommonEarlier("\""), Is.False); quotationMarkSequences.CountEarlierQuotationMark("\""); quotationMarkSequences.CountEarlierQuotationMark("\""); @@ -196,27 +196,27 @@ public void IsMarkMuchMoreCommonEarlier() quotationMarkSequences.CountEarlierQuotationMark("\""); quotationMarkSequences.CountEarlierQuotationMark("\""); quotationMarkSequences.CountEarlierQuotationMark("\""); - Assert.IsTrue(quotationMarkSequences.IsMarkMuchMoreCommonEarlier("\"")); + Assert.That(quotationMarkSequences.IsMarkMuchMoreCommonEarlier("\""), Is.True); quotationMarkSequences.CountLaterQuotationMark("\""); - Assert.IsFalse(quotationMarkSequences.IsMarkMuchMoreCommonEarlier("\"")); + Assert.That(quotationMarkSequences.IsMarkMuchMoreCommonEarlier("\""), Is.False); quotationMarkSequences.CountEarlierQuotationMark("\""); quotationMarkSequences.CountEarlierQuotationMark("\""); quotationMarkSequences.CountEarlierQuotationMark("\""); quotationMarkSequences.CountEarlierQuotationMark("\""); quotationMarkSequences.CountEarlierQuotationMark("\""); - Assert.IsTrue(quotationMarkSequences.IsMarkMuchMoreCommonEarlier("\"")); + Assert.That(quotationMarkSequences.IsMarkMuchMoreCommonEarlier("\""), Is.True); quotationMarkSequences.CountLaterQuotationMark("\""); - Assert.IsFalse(quotationMarkSequences.IsMarkMuchMoreCommonEarlier("\"")); + Assert.That(quotationMarkSequences.IsMarkMuchMoreCommonEarlier("\""), Is.False); } [Test] public void IsMarkMuchMoreCommonLater() { var quotationMarkSequences = new QuotationMarkSequences(); - Assert.IsFalse(quotationMarkSequences.IsMarkMuchMoreCommonLater("\"")); + Assert.That(quotationMarkSequences.IsMarkMuchMoreCommonLater("\""), Is.False); quotationMarkSequences.CountLaterQuotationMark("\""); quotationMarkSequences.CountLaterQuotationMark("\""); @@ -224,31 +224,31 @@ public void IsMarkMuchMoreCommonLater() quotationMarkSequences.CountLaterQuotationMark("\""); quotationMarkSequences.CountLaterQuotationMark("\""); quotationMarkSequences.CountLaterQuotationMark("\""); - Assert.IsTrue(quotationMarkSequences.IsMarkMuchMoreCommonLater("\"")); + Assert.That(quotationMarkSequences.IsMarkMuchMoreCommonLater("\""), Is.True); quotationMarkSequences.CountEarlierQuotationMark("\""); - Assert.IsFalse(quotationMarkSequences.IsMarkMuchMoreCommonLater("\"")); + Assert.That(quotationMarkSequences.IsMarkMuchMoreCommonLater("\""), Is.False); quotationMarkSequences.CountLaterQuotationMark("\""); quotationMarkSequences.CountLaterQuotationMark("\""); quotationMarkSequences.CountLaterQuotationMark("\""); quotationMarkSequences.CountLaterQuotationMark("\""); quotationMarkSequences.CountLaterQuotationMark("\""); - Assert.IsTrue(quotationMarkSequences.IsMarkMuchMoreCommonLater("\"")); + Assert.That(quotationMarkSequences.IsMarkMuchMoreCommonLater("\""), Is.True); quotationMarkSequences.CountEarlierQuotationMark("\""); - Assert.IsFalse(quotationMarkSequences.IsMarkMuchMoreCommonLater("\"")); + Assert.That(quotationMarkSequences.IsMarkMuchMoreCommonLater("\""), Is.False); } [Test] public void IsMarkCommonEarlyAndLate() { var quotationMarkSequences = new QuotationMarkSequences(); - Assert.IsFalse(quotationMarkSequences.AreEarlyAndLateMarkRatesSimilar("\"")); + Assert.That(quotationMarkSequences.AreEarlyAndLateMarkRatesSimilar("\""), Is.False); quotationMarkSequences.CountEarlierQuotationMark("\""); quotationMarkSequences.CountLaterQuotationMark("\""); - Assert.IsTrue(quotationMarkSequences.AreEarlyAndLateMarkRatesSimilar("\"")); + Assert.That(quotationMarkSequences.AreEarlyAndLateMarkRatesSimilar("\""), Is.True); quotationMarkSequences.CountEarlierQuotationMark("\""); quotationMarkSequences.CountLaterQuotationMark("\""); @@ -260,14 +260,14 @@ public void IsMarkCommonEarlyAndLate() quotationMarkSequences.CountLaterQuotationMark("\""); quotationMarkSequences.CountEarlierQuotationMark("\""); quotationMarkSequences.CountLaterQuotationMark("\""); - Assert.IsTrue(quotationMarkSequences.AreEarlyAndLateMarkRatesSimilar("\"")); + Assert.That(quotationMarkSequences.AreEarlyAndLateMarkRatesSimilar("\""), Is.True); quotationMarkSequences.CountLaterQuotationMark("\""); - Assert.IsTrue(quotationMarkSequences.AreEarlyAndLateMarkRatesSimilar("\"")); + Assert.That(quotationMarkSequences.AreEarlyAndLateMarkRatesSimilar("\""), Is.True); quotationMarkSequences.CountLaterQuotationMark("\""); quotationMarkSequences.CountLaterQuotationMark("\""); - Assert.IsFalse(quotationMarkSequences.AreEarlyAndLateMarkRatesSimilar("\"")); + Assert.That(quotationMarkSequences.AreEarlyAndLateMarkRatesSimilar("\""), Is.False); } #endregion @@ -471,9 +471,9 @@ public void HasDistinctPairedQuotationMarks() [], new QuoteConventionSet([standardEnglishQuoteConvention]) ); - Assert.IsFalse(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u201c")); - Assert.IsFalse(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u201d")); - Assert.IsFalse(quotationMarkGrouper.HasDistinctPairedQuotationMark("")); + Assert.That(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u201c"), Is.False); + Assert.That(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u201d"), Is.False); + Assert.That(quotationMarkGrouper.HasDistinctPairedQuotationMark(""), Is.False); // basic paired quotation marks quotationMarkGrouper = new QuotationMarkGrouper( @@ -483,8 +483,8 @@ public void HasDistinctPairedQuotationMarks() ], new QuoteConventionSet([standardEnglishQuoteConvention]) ); - Assert.IsTrue(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u201c")); - Assert.IsTrue(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u201d")); + Assert.That(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u201c"), Is.True); + Assert.That(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u201d"), Is.True); // second-level paired quotation marks quotationMarkGrouper = new QuotationMarkGrouper( @@ -494,16 +494,16 @@ public void HasDistinctPairedQuotationMarks() ], new QuoteConventionSet([standardEnglishQuoteConvention]) ); - Assert.IsTrue(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u2018")); - Assert.IsTrue(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u2019")); + Assert.That(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u2018"), Is.True); + Assert.That(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u2019"), Is.True); // only one half of the pair observed quotationMarkGrouper = new QuotationMarkGrouper( - [new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1),], + [new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build(), 0, 1)], new QuoteConventionSet([standardEnglishQuoteConvention]) ); - Assert.IsFalse(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u201c")); - Assert.IsTrue(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u201d")); + Assert.That(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u201c"), Is.False); + Assert.That(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u201d"), Is.True); // quotation marks that don't match the convention set quotationMarkGrouper = new QuotationMarkGrouper( @@ -513,8 +513,8 @@ [new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build( ], new QuoteConventionSet([typewriterEnglishQuoteConvention]) ); - Assert.IsFalse(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u201c")); - Assert.IsFalse(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u201d")); + Assert.That(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u201c"), Is.False); + Assert.That(quotationMarkGrouper.HasDistinctPairedQuotationMark("\u201d"), Is.False); // ambiguous quotation marks quotationMarkGrouper = new QuotationMarkGrouper( @@ -524,7 +524,7 @@ [new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\u201c").Build( ], new QuoteConventionSet([typewriterEnglishQuoteConvention]) ); - Assert.IsFalse(quotationMarkGrouper.HasDistinctPairedQuotationMark("\"")); + Assert.That(quotationMarkGrouper.HasDistinctPairedQuotationMark("\""), Is.False); } #endregion @@ -564,11 +564,11 @@ public void ThatTheMarkMustBeAnApostrophe() ), ] ); - Assert.IsTrue(preliminaryApostropheAnalyzer.IsApostropheOnly("'")); - Assert.IsTrue(preliminaryApostropheAnalyzer.IsApostropheOnly("\u2019")); - Assert.IsFalse(preliminaryApostropheAnalyzer.IsApostropheOnly("\u2018")); - Assert.IsFalse(preliminaryApostropheAnalyzer.IsApostropheOnly("\u201c")); - Assert.IsFalse(preliminaryApostropheAnalyzer.IsApostropheOnly("\u201d")); + Assert.That(preliminaryApostropheAnalyzer.IsApostropheOnly("'"), Is.True); + Assert.That(preliminaryApostropheAnalyzer.IsApostropheOnly("\u2019"), Is.True); + Assert.That(preliminaryApostropheAnalyzer.IsApostropheOnly("\u2018"), Is.False); + Assert.That(preliminaryApostropheAnalyzer.IsApostropheOnly("\u201c"), Is.False); + Assert.That(preliminaryApostropheAnalyzer.IsApostropheOnly("\u201d"), Is.False); } [Test] @@ -595,7 +595,7 @@ public void ThatARarelyInitialOrFinalMarkIsAnApostrophe() new QuotationMarkStringMatch(new TextSegment.Builder().SetText("word' final apostrophe").Build(), 4, 5), ] ); - Assert.IsFalse(negativePreliminaryApostropheAnalyzer.IsApostropheOnly("'")); + Assert.That(negativePreliminaryApostropheAnalyzer.IsApostropheOnly("'"), Is.False); var positivePreliminaryApostropheAnalyzer = new PreliminaryApostropheAnalyzer(); positivePreliminaryApostropheAnalyzer.ProcessQuotationMarks( @@ -641,7 +641,7 @@ public void ThatARarelyInitialOrFinalMarkIsAnApostrophe() new QuotationMarkStringMatch(new TextSegment.Builder().SetText("mid'word apostrophe").Build(), 3, 4), ] ); - Assert.IsTrue(positivePreliminaryApostropheAnalyzer.IsApostropheOnly("'")); + Assert.That(positivePreliminaryApostropheAnalyzer.IsApostropheOnly("'"), Is.True); } [Test] @@ -702,7 +702,7 @@ public void ThatAMarkWithSimilarFinalAndInitialRatesIsAnApostrophe() new QuotationMarkStringMatch(new TextSegment.Builder().SetText("mid'word apostrophe").Build(), 3, 4), ] ); - Assert.IsFalse(negativePreliminaryApostropheAnalyzer.IsApostropheOnly("'")); + Assert.That(negativePreliminaryApostropheAnalyzer.IsApostropheOnly("'"), Is.False); var negativePreliminaryApostropheAnalyzer2 = new PreliminaryApostropheAnalyzer(); negativePreliminaryApostropheAnalyzer2.ProcessQuotationMarks( @@ -747,7 +747,7 @@ public void ThatAMarkWithSimilarFinalAndInitialRatesIsAnApostrophe() new QuotationMarkStringMatch(new TextSegment.Builder().SetText("mid'word apostrophe").Build(), 3, 4), ] ); - Assert.IsFalse(negativePreliminaryApostropheAnalyzer2.IsApostropheOnly("'")); + Assert.That(negativePreliminaryApostropheAnalyzer2.IsApostropheOnly("'"), Is.False); var positivePreliminaryApostropheAnalyzer = new PreliminaryApostropheAnalyzer(); positivePreliminaryApostropheAnalyzer.ProcessQuotationMarks( @@ -800,7 +800,7 @@ public void ThatAMarkWithSimilarFinalAndInitialRatesIsAnApostrophe() new QuotationMarkStringMatch(new TextSegment.Builder().SetText("mid'word apostrophe").Build(), 3, 4), ] ); - Assert.IsTrue(positivePreliminaryApostropheAnalyzer.IsApostropheOnly("'")); + Assert.That(positivePreliminaryApostropheAnalyzer.IsApostropheOnly("'"), Is.True); } [Test] @@ -827,7 +827,7 @@ public void ThatACommonlyMidWordMarkIsAnApostrophe() new QuotationMarkStringMatch(new TextSegment.Builder().SetText("word' final apostrophe").Build(), 4, 5), ] ); - Assert.IsFalse(negativePreliminaryApostropheAnalyzer.IsApostropheOnly("'")); + Assert.That(negativePreliminaryApostropheAnalyzer.IsApostropheOnly("'"), Is.False); var positivePreliminaryApostropheAnalyzer = new PreliminaryApostropheAnalyzer(); positivePreliminaryApostropheAnalyzer.ProcessQuotationMarks( @@ -851,7 +851,7 @@ public void ThatACommonlyMidWordMarkIsAnApostrophe() new QuotationMarkStringMatch(new TextSegment.Builder().SetText("mid'word apostrophe").Build(), 3, 4), ] ); - Assert.IsTrue(positivePreliminaryApostropheAnalyzer.IsApostropheOnly("'")); + Assert.That(positivePreliminaryApostropheAnalyzer.IsApostropheOnly("'"), Is.True); } [Test] @@ -878,11 +878,11 @@ public void ThatAFrequentlyOccurringCharacterIsAnApostrophe() new QuotationMarkStringMatch(new TextSegment.Builder().SetText("word' final apostrophe").Build(), 4, 5), ] ); - Assert.IsFalse(negativePreliminaryApostropheAnalyzer.IsApostropheOnly("'")); + Assert.That(negativePreliminaryApostropheAnalyzer.IsApostropheOnly("'"), Is.False); var positivePreliminaryApostropheAnalyzer = new PreliminaryApostropheAnalyzer(); positivePreliminaryApostropheAnalyzer.ProcessQuotationMarks( - [new TextSegment.Builder().SetText("Very short text").Build(),], + [new TextSegment.Builder().SetText("Very short text").Build()], [ new QuotationMarkStringMatch( new TextSegment.Builder().SetText("'word initial apostrophe").Build(), @@ -892,7 +892,7 @@ [new TextSegment.Builder().SetText("Very short text").Build(),], new QuotationMarkStringMatch(new TextSegment.Builder().SetText("word' final apostrophe").Build(), 4, 5), ] ); - Assert.IsTrue(positivePreliminaryApostropheAnalyzer.IsApostropheOnly("'")); + Assert.That(positivePreliminaryApostropheAnalyzer.IsApostropheOnly("'"), Is.True); } #endregion @@ -948,184 +948,128 @@ public void ThatQuotationMarkSequenceIsUsedToDetermineOpeningAndClosingQuotes() ); var preliminaryQuotationAnalyzer = new PreliminaryQuotationMarkAnalyzer( - new QuoteConventionSet( - [ - standardEnglishQuoteConvention, - typewriterEnglishQuoteConvention, - standardFrenchQuoteConvention, - westernEuropeanQuoteConvention, - standardSwedishQuoteConvention, - ] - ) + new QuoteConventionSet([ + standardEnglishQuoteConvention, + typewriterEnglishQuoteConvention, + standardFrenchQuoteConvention, + westernEuropeanQuoteConvention, + standardSwedishQuoteConvention, + ]) ); Assert.That( - preliminaryQuotationAnalyzer.NarrowDownPossibleQuoteConventions( - [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("initial text \u201c quoted English text \u201d final text") - .Build() - ] - ) - ] - ) - ] - ), + preliminaryQuotationAnalyzer.NarrowDownPossibleQuoteConventions([ + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("initial text \u201c quoted English text \u201d final text") + .Build(), + ]), + ]), + ]), Is.EqualTo(new QuoteConventionSet([standardEnglishQuoteConvention])) ); preliminaryQuotationAnalyzer.Reset(); Assert.That( - preliminaryQuotationAnalyzer.NarrowDownPossibleQuoteConventions( - [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("initial text \u201d quoted Swedish text \u201d final text") - .Build(), - ] - ) - ] - ) - ] - ), + preliminaryQuotationAnalyzer.NarrowDownPossibleQuoteConventions([ + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("initial text \u201d quoted Swedish text \u201d final text") + .Build(), + ]), + ]), + ]), Is.EqualTo(new QuoteConventionSet([standardSwedishQuoteConvention])) ); preliminaryQuotationAnalyzer.Reset(); Assert.That( - preliminaryQuotationAnalyzer.NarrowDownPossibleQuoteConventions( - [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText( - "initial text \u00ab quoted French/Western European text \u00bb final text" - ) - .Build(), - ] - ) - ] - ) - ] - ), + preliminaryQuotationAnalyzer.NarrowDownPossibleQuoteConventions([ + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("initial text \u00ab quoted French/Western European text \u00bb final text") + .Build(), + ]), + ]), + ]), Is.EqualTo(new QuoteConventionSet([standardFrenchQuoteConvention, westernEuropeanQuoteConvention])) ); preliminaryQuotationAnalyzer.Reset(); Assert.That( - preliminaryQuotationAnalyzer.NarrowDownPossibleQuoteConventions( - [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("initial text \" quoted typewriter English text \" final text") - .Build(), - ] - ) - ] - ) - ] - ), + preliminaryQuotationAnalyzer.NarrowDownPossibleQuoteConventions([ + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("initial text \" quoted typewriter English text \" final text") + .Build(), + ]), + ]), + ]), Is.EqualTo(new QuoteConventionSet([typewriterEnglishQuoteConvention])) ); preliminaryQuotationAnalyzer.Reset(); Assert.That( - preliminaryQuotationAnalyzer.NarrowDownPossibleQuoteConventions( - [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("initial text \u201c quoted English text \u201d final text") - .Build(), - new TextSegment.Builder() - .SetText("second level \u2018 English quotes \u2019") - .Build(), - ] - ) - ] - ) - ] - ), + preliminaryQuotationAnalyzer.NarrowDownPossibleQuoteConventions([ + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("initial text \u201c quoted English text \u201d final text") + .Build(), + new TextSegment.Builder().SetText("second level \u2018 English quotes \u2019").Build(), + ]), + ]), + ]), Is.EqualTo(new QuoteConventionSet([standardEnglishQuoteConvention])) ); preliminaryQuotationAnalyzer.Reset(); Assert.That( - preliminaryQuotationAnalyzer.NarrowDownPossibleQuoteConventions( - [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("initial text \" quoted typewriter English text \" final text") - .Build(), - new TextSegment.Builder().SetText("second level 'typewriter quotes'").Build(), - ] - ) - ] - ) - ] - ), + preliminaryQuotationAnalyzer.NarrowDownPossibleQuoteConventions([ + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("initial text \" quoted typewriter English text \" final text") + .Build(), + new TextSegment.Builder().SetText("second level 'typewriter quotes'").Build(), + ]), + ]), + ]), Is.EqualTo(new QuoteConventionSet([typewriterEnglishQuoteConvention])) ); preliminaryQuotationAnalyzer.Reset(); Assert.That( - preliminaryQuotationAnalyzer.NarrowDownPossibleQuoteConventions( - [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("initial text \u201c quoted English text \u201d final text") - .Build(), - new TextSegment.Builder() - .SetText("the quotes \u201d in this segment \u201c are backwards") - .Build(), - ] - ) - ] - ) - ] - ), + preliminaryQuotationAnalyzer.NarrowDownPossibleQuoteConventions([ + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("initial text \u201c quoted English text \u201d final text") + .Build(), + new TextSegment.Builder() + .SetText("the quotes \u201d in this segment \u201c are backwards") + .Build(), + ]), + ]), + ]), Is.EqualTo(new QuoteConventionSet([])) ); preliminaryQuotationAnalyzer.Reset(); Assert.That( - preliminaryQuotationAnalyzer.NarrowDownPossibleQuoteConventions( - [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText( - "first-level quotes \u2018 must be observed \u2019 to retain a quote convention" - ) - .Build(), - ] - ) - ] - ) - ] - ), + preliminaryQuotationAnalyzer.NarrowDownPossibleQuoteConventions([ + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("first-level quotes \u2018 must be observed \u2019 to retain a quote convention") + .Build(), + ]), + ]), + ]), Is.EqualTo(new QuoteConventionSet([])) ); } @@ -1153,25 +1097,19 @@ public void ThatApostrophesNotConsideredAsQuotationMarks() ); var preliminaryQuotationAnalyzer = new PreliminaryQuotationMarkAnalyzer( - new QuoteConventionSet([standardEnglishQuoteConvention, typewriterEnglishQuoteConvention,]) + new QuoteConventionSet([standardEnglishQuoteConvention, typewriterEnglishQuoteConvention]) ); Assert.That( - preliminaryQuotationAnalyzer.NarrowDownPossibleQuoteConventions( - [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("ini'tial 'text \u201c quo'ted English text' \u201d fi'nal text") - .Build() - ] - ) - ] - ) - ] - ), + preliminaryQuotationAnalyzer.NarrowDownPossibleQuoteConventions([ + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("ini'tial 'text \u201c quo'ted English text' \u201d fi'nal text") + .Build(), + ]), + ]), + ]), Is.EqualTo(new QuoteConventionSet([standardEnglishQuoteConvention])) ); } diff --git a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationDenormalizationTests.cs b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationDenormalizationTests.cs index 58c5c5d6e..fa3f31c00 100644 --- a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationDenormalizationTests.cs +++ b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationDenormalizationTests.cs @@ -34,7 +34,7 @@ of the field which Yahweh God had made. QuoteConvention standardEnglishQuoteConvention = QuoteConventions.Standard.GetQuoteConventionByName( "standard_english" ); - Assert.IsNotNull(standardEnglishQuoteConvention); + Assert.That(standardEnglishQuoteConvention, Is.Not.Null); var quotationMarkDenormalizationFirstPass = new QuotationMarkDenormalizationFirstPass( standardEnglishQuoteConvention diff --git a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationDenormalizationUsfmBlockUpdateHandlerTests.cs b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationDenormalizationUsfmBlockUpdateHandlerTests.cs index 02cd3b803..649a044aa 100644 --- a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationDenormalizationUsfmBlockUpdateHandlerTests.cs +++ b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationDenormalizationUsfmBlockUpdateHandlerTests.cs @@ -502,7 +502,7 @@ public void AssertUsfmEqual(string observedUsfm, string expectedUsfm) public QuoteConvention GetQuoteConventionByName(string name) { QuoteConvention quoteConvention = QuoteConventions.Standard.GetQuoteConventionByName(name); - Assert.IsNotNull(quoteConvention); + Assert.That(quoteConvention, Is.Not.Null); return quoteConvention; } } diff --git a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkFinderTests.cs b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkFinderTests.cs index 056efa238..21c2c312e 100644 --- a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkFinderTests.cs +++ b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkFinderTests.cs @@ -14,20 +14,18 @@ public void ThatAllPossibleQuotationMarksAreIdentified() .FindAllPotentialQuotationMarksInTextSegment( new TextSegment.Builder().SetText("\u201cSample Text\u201d").Build() ) - .SequenceEqual( - [ - new QuotationMarkStringMatch( - new TextSegment.Builder().SetText("\u201cSample Text\u201d").Build(), - 0, - 1 - ), - new QuotationMarkStringMatch( - new TextSegment.Builder().SetText("\u201cSample Text\u201d").Build(), - 12, - 13 - ), - ] - ) + .SequenceEqual([ + new QuotationMarkStringMatch( + new TextSegment.Builder().SetText("\u201cSample Text\u201d").Build(), + 0, + 1 + ), + new QuotationMarkStringMatch( + new TextSegment.Builder().SetText("\u201cSample Text\u201d").Build(), + 12, + 13 + ), + ]) ); Assert.That( @@ -35,16 +33,10 @@ public void ThatAllPossibleQuotationMarksAreIdentified() .FindAllPotentialQuotationMarksInTextSegment( new TextSegment.Builder().SetText("\"Sample Text'").Build() ) - .SequenceEqual( - [ - new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"Sample Text'").Build(), 0, 1), - new QuotationMarkStringMatch( - new TextSegment.Builder().SetText("\"Sample Text'").Build(), - 12, - 13 - ), - ] - ) + .SequenceEqual([ + new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"Sample Text'").Build(), 0, 1), + new QuotationMarkStringMatch(new TextSegment.Builder().SetText("\"Sample Text'").Build(), 12, 13), + ]) ); Assert.That( @@ -52,38 +44,36 @@ public void ThatAllPossibleQuotationMarksAreIdentified() .FindAllPotentialQuotationMarksInTextSegment( new TextSegment.Builder().SetText("All \u201cthe \u2019English quotation\u2018 marks\u201d").Build() ) - .SequenceEqual( - [ - new QuotationMarkStringMatch( - new TextSegment.Builder() - .SetText("All \u201cthe \u2019English quotation\u2018 marks\u201d") - .Build(), - 4, - 5 - ), - new QuotationMarkStringMatch( - new TextSegment.Builder() - .SetText("All \u201cthe \u2019English quotation\u2018 marks\u201d") - .Build(), - 9, - 10 - ), - new QuotationMarkStringMatch( - new TextSegment.Builder() - .SetText("All \u201cthe \u2019English quotation\u2018 marks\u201d") - .Build(), - 27, - 28 - ), - new QuotationMarkStringMatch( - new TextSegment.Builder() - .SetText("All \u201cthe \u2019English quotation\u2018 marks\u201d") - .Build(), - 34, - 35 - ) - ] - ) + .SequenceEqual([ + new QuotationMarkStringMatch( + new TextSegment.Builder() + .SetText("All \u201cthe \u2019English quotation\u2018 marks\u201d") + .Build(), + 4, + 5 + ), + new QuotationMarkStringMatch( + new TextSegment.Builder() + .SetText("All \u201cthe \u2019English quotation\u2018 marks\u201d") + .Build(), + 9, + 10 + ), + new QuotationMarkStringMatch( + new TextSegment.Builder() + .SetText("All \u201cthe \u2019English quotation\u2018 marks\u201d") + .Build(), + 27, + 28 + ), + new QuotationMarkStringMatch( + new TextSegment.Builder() + .SetText("All \u201cthe \u2019English quotation\u2018 marks\u201d") + .Build(), + 34, + 35 + ), + ]) ); Assert.That( @@ -91,38 +81,36 @@ public void ThatAllPossibleQuotationMarksAreIdentified() .FindAllPotentialQuotationMarksInTextSegment( new TextSegment.Builder().SetText("All \u00abthe \u2039French quotation\u203a marks\u00bb").Build() ) - .SequenceEqual( - [ - new QuotationMarkStringMatch( - new TextSegment.Builder() - .SetText("All \u00abthe \u2039French quotation\u203a marks\u00bb") - .Build(), - 4, - 5 - ), - new QuotationMarkStringMatch( - new TextSegment.Builder() - .SetText("All \u00abthe \u2039French quotation\u203a marks\u00bb") - .Build(), - 9, - 10 - ), - new QuotationMarkStringMatch( - new TextSegment.Builder() - .SetText("All \u00abthe \u2039French quotation\u203a marks\u00bb") - .Build(), - 26, - 27 - ), - new QuotationMarkStringMatch( - new TextSegment.Builder() - .SetText("All \u00abthe \u2039French quotation\u203a marks\u00bb") - .Build(), - 33, - 34 - ), - ] - ) + .SequenceEqual([ + new QuotationMarkStringMatch( + new TextSegment.Builder() + .SetText("All \u00abthe \u2039French quotation\u203a marks\u00bb") + .Build(), + 4, + 5 + ), + new QuotationMarkStringMatch( + new TextSegment.Builder() + .SetText("All \u00abthe \u2039French quotation\u203a marks\u00bb") + .Build(), + 9, + 10 + ), + new QuotationMarkStringMatch( + new TextSegment.Builder() + .SetText("All \u00abthe \u2039French quotation\u203a marks\u00bb") + .Build(), + 26, + 27 + ), + new QuotationMarkStringMatch( + new TextSegment.Builder() + .SetText("All \u00abthe \u2039French quotation\u203a marks\u00bb") + .Build(), + 33, + 34 + ), + ]) ); Assert.That( @@ -130,20 +118,18 @@ public void ThatAllPossibleQuotationMarksAreIdentified() .FindAllPotentialQuotationMarksInTextSegment( new TextSegment.Builder().SetText("All \"the 'typewriter quotation marks").Build() ) - .SequenceEqual( - [ - new QuotationMarkStringMatch( - new TextSegment.Builder().SetText("All \"the 'typewriter quotation marks").Build(), - 4, - 5 - ), - new QuotationMarkStringMatch( - new TextSegment.Builder().SetText("All \"the 'typewriter quotation marks").Build(), - 9, - 10 - ), - ] - ) + .SequenceEqual([ + new QuotationMarkStringMatch( + new TextSegment.Builder().SetText("All \"the 'typewriter quotation marks").Build(), + 4, + 5 + ), + new QuotationMarkStringMatch( + new TextSegment.Builder().SetText("All \"the 'typewriter quotation marks").Build(), + 9, + 10 + ), + ]) ); Assert.That( @@ -153,38 +139,36 @@ public void ThatAllPossibleQuotationMarksAreIdentified() .SetText("This has \u201equotes from \u00bbdifferent conventions < 0); + Assert.That(quotationMarkResolver.QuotationMarkResolverState.CurrentDepth > 0, Is.True); quotationMarkResolver.Reset(); diff --git a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkStringMatchTests.cs b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkStringMatchTests.cs index d099426d8..bc340e5d8 100644 --- a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkStringMatchTests.cs +++ b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkStringMatchTests.cs @@ -46,28 +46,28 @@ public void IsValidOpeningQuotationMark() 0, 1 ); - Assert.IsTrue(quotationMarkStringMatch.IsValidOpeningQuotationMark(standardEnglishQuoteConventionSet)); + Assert.That(quotationMarkStringMatch.IsValidOpeningQuotationMark(standardEnglishQuoteConventionSet), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("\u201d").Build(), 0, 1 ); - Assert.IsFalse(quotationMarkStringMatch.IsValidOpeningQuotationMark(standardEnglishQuoteConventionSet)); + Assert.That(quotationMarkStringMatch.IsValidOpeningQuotationMark(standardEnglishQuoteConventionSet), Is.False); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("\u201d\u201c").Build(), 1, 2 ); - Assert.IsTrue(quotationMarkStringMatch.IsValidOpeningQuotationMark(standardEnglishQuoteConventionSet)); + Assert.That(quotationMarkStringMatch.IsValidOpeningQuotationMark(standardEnglishQuoteConventionSet), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("\u201d\u201c").Build(), 0, 2 ); - Assert.IsFalse(quotationMarkStringMatch.IsValidOpeningQuotationMark(standardEnglishQuoteConventionSet)); + Assert.That(quotationMarkStringMatch.IsValidOpeningQuotationMark(standardEnglishQuoteConventionSet), Is.False); } [Test] @@ -89,28 +89,28 @@ public void IsValidClosingQuotationMark() 0, 1 ); - Assert.IsTrue(quotationMarkStringMatch.IsValidClosingQuotationMark(standardEnglishQuoteConventionSet)); + Assert.That(quotationMarkStringMatch.IsValidClosingQuotationMark(standardEnglishQuoteConventionSet), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("\u201c").Build(), 0, 1 ); - Assert.IsFalse(quotationMarkStringMatch.IsValidClosingQuotationMark(standardEnglishQuoteConventionSet)); + Assert.That(quotationMarkStringMatch.IsValidClosingQuotationMark(standardEnglishQuoteConventionSet), Is.False); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("\u201d\u201c").Build(), 0, 1 ); - Assert.IsTrue(quotationMarkStringMatch.IsValidClosingQuotationMark(standardEnglishQuoteConventionSet)); + Assert.That(quotationMarkStringMatch.IsValidClosingQuotationMark(standardEnglishQuoteConventionSet), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("\u201d\u201c").Build(), 0, 2 ); - Assert.IsFalse(quotationMarkStringMatch.IsValidClosingQuotationMark(standardEnglishQuoteConventionSet)); + Assert.That(quotationMarkStringMatch.IsValidClosingQuotationMark(standardEnglishQuoteConventionSet), Is.False); } [Test] @@ -121,9 +121,9 @@ public void DoesQuotationMarkMatch() 0, 1 ); - Assert.IsTrue(quotationMarkStringMatch.QuotationMarkMatches(new Regex(@"^s$", RegexOptions.Compiled))); - Assert.IsFalse(quotationMarkStringMatch.QuotationMarkMatches(new Regex(@"a", RegexOptions.Compiled))); - Assert.IsFalse(quotationMarkStringMatch.QuotationMarkMatches(new Regex(@"sa", RegexOptions.Compiled))); + Assert.That(quotationMarkStringMatch.QuotationMarkMatches(new Regex(@"^s$", RegexOptions.Compiled)), Is.True); + Assert.That(quotationMarkStringMatch.QuotationMarkMatches(new Regex(@"a", RegexOptions.Compiled)), Is.False); + Assert.That(quotationMarkStringMatch.QuotationMarkMatches(new Regex(@"sa", RegexOptions.Compiled)), Is.False); } [Test] @@ -134,16 +134,16 @@ public void DoesNextCharacterMatch() 0, 1 ); - Assert.IsFalse(quotationMarkStringMatch.NextCharacterMatches(new Regex(@"^s$", RegexOptions.Compiled))); - Assert.IsTrue(quotationMarkStringMatch.NextCharacterMatches(new Regex(@"a", RegexOptions.Compiled))); - Assert.IsFalse(quotationMarkStringMatch.NextCharacterMatches(new Regex(@"sa", RegexOptions.Compiled))); + Assert.That(quotationMarkStringMatch.NextCharacterMatches(new Regex(@"^s$", RegexOptions.Compiled)), Is.False); + Assert.That(quotationMarkStringMatch.NextCharacterMatches(new Regex(@"a", RegexOptions.Compiled)), Is.True); + Assert.That(quotationMarkStringMatch.NextCharacterMatches(new Regex(@"sa", RegexOptions.Compiled)), Is.False); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").Build(), 10, 11 ); - Assert.IsFalse(quotationMarkStringMatch.NextCharacterMatches(new Regex(@".*", RegexOptions.Compiled))); + Assert.That(quotationMarkStringMatch.NextCharacterMatches(new Regex(@".*", RegexOptions.Compiled)), Is.False); } [Test] @@ -154,16 +154,28 @@ public void DoesPreviousCharacterMatch() 1, 2 ); - Assert.IsTrue(quotationMarkStringMatch.PreviousCharacterMatches(new Regex(@"^s$", RegexOptions.Compiled))); - Assert.IsFalse(quotationMarkStringMatch.PreviousCharacterMatches(new Regex(@"a", RegexOptions.Compiled))); - Assert.IsFalse(quotationMarkStringMatch.PreviousCharacterMatches(new Regex(@"sa", RegexOptions.Compiled))); + Assert.That( + quotationMarkStringMatch.PreviousCharacterMatches(new Regex(@"^s$", RegexOptions.Compiled)), + Is.True + ); + Assert.That( + quotationMarkStringMatch.PreviousCharacterMatches(new Regex(@"a", RegexOptions.Compiled)), + Is.False + ); + Assert.That( + quotationMarkStringMatch.PreviousCharacterMatches(new Regex(@"sa", RegexOptions.Compiled)), + Is.False + ); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").Build(), 0, 1 ); - Assert.IsFalse(quotationMarkStringMatch.PreviousCharacterMatches(new Regex(@".*", RegexOptions.Compiled))); + Assert.That( + quotationMarkStringMatch.PreviousCharacterMatches(new Regex(@".*", RegexOptions.Compiled)), + Is.False + ); } [Test] @@ -188,7 +200,7 @@ public void GetPreviousCharacter() 0, 1 ); - Assert.IsNull(quotationMarkStringMatch.PreviousCharacter); + Assert.That(quotationMarkStringMatch.PreviousCharacter, Is.Null); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("\u201c\u201d").Build(), @@ -247,21 +259,30 @@ public void DoesLeadingSubstringMatch() 5, 6 ); - Assert.IsTrue(quotationMarkStringMatch.LeadingSubstringMatches(new Regex(@"^sampl$", RegexOptions.Compiled))); + Assert.That( + quotationMarkStringMatch.LeadingSubstringMatches(new Regex(@"^sampl$", RegexOptions.Compiled)), + Is.True + ); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").Build(), 0, 1 ); - Assert.IsFalse(quotationMarkStringMatch.LeadingSubstringMatches(new Regex(@".+", RegexOptions.Compiled))); + Assert.That( + quotationMarkStringMatch.LeadingSubstringMatches(new Regex(@".+", RegexOptions.Compiled)), + Is.False + ); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("\u201c\u201d").Build(), 1, 2 ); - Assert.IsTrue(quotationMarkStringMatch.LeadingSubstringMatches(new Regex(@"\u201c", RegexOptions.Compiled))); + Assert.That( + quotationMarkStringMatch.LeadingSubstringMatches(new Regex(@"\u201c", RegexOptions.Compiled)), + Is.True + ); } [Test] @@ -272,21 +293,30 @@ public void DoesTrailingSubstringMatch() 5, 6 ); - Assert.IsTrue(quotationMarkStringMatch.TrailingSubstringMatches(new Regex(@"^ text$", RegexOptions.Compiled))); + Assert.That( + quotationMarkStringMatch.TrailingSubstringMatches(new Regex(@"^ text$", RegexOptions.Compiled)), + Is.True + ); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").Build(), 10, 11 ); - Assert.IsFalse(quotationMarkStringMatch.TrailingSubstringMatches(new Regex(@".+", RegexOptions.Compiled))); + Assert.That( + quotationMarkStringMatch.TrailingSubstringMatches(new Regex(@".+", RegexOptions.Compiled)), + Is.False + ); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("\u201c\u201d").Build(), 0, 1 ); - Assert.IsTrue(quotationMarkStringMatch.TrailingSubstringMatches(new Regex(@"\u201d", RegexOptions.Compiled))); + Assert.That( + quotationMarkStringMatch.TrailingSubstringMatches(new Regex(@"\u201d", RegexOptions.Compiled)), + Is.True + ); } [Test] @@ -348,28 +378,28 @@ public void IsAtStartOfSegment() 0, 1 ); - Assert.IsTrue(quotationMarkStringMatch.IsAtStartOfSegment); + Assert.That(quotationMarkStringMatch.IsAtStartOfSegment, Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").Build(), 1, 2 ); - Assert.IsFalse(quotationMarkStringMatch.IsAtStartOfSegment); + Assert.That(quotationMarkStringMatch.IsAtStartOfSegment, Is.False); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("\u201csample text").Build(), 0, 1 ); - Assert.IsTrue(quotationMarkStringMatch.IsAtStartOfSegment); + Assert.That(quotationMarkStringMatch.IsAtStartOfSegment, Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").Build(), 15, 16 ); - Assert.IsFalse(quotationMarkStringMatch.IsAtStartOfSegment); + Assert.That(quotationMarkStringMatch.IsAtStartOfSegment, Is.False); } [Test] @@ -380,28 +410,28 @@ public void IsAtEndOfSegment() 10, 11 ); - Assert.IsTrue(quotationMarkStringMatch.IsAtEndOfSegment); + Assert.That(quotationMarkStringMatch.IsAtEndOfSegment, Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").Build(), 0, 1 ); - Assert.IsFalse(quotationMarkStringMatch.IsAtEndOfSegment); + Assert.That(quotationMarkStringMatch.IsAtEndOfSegment, Is.False); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("\u201csample text\u201d").Build(), 12, 13 ); - Assert.IsTrue(quotationMarkStringMatch.IsAtEndOfSegment); + Assert.That(quotationMarkStringMatch.IsAtEndOfSegment, Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").Build(), 15, 16 ); - Assert.IsFalse(quotationMarkStringMatch.IsAtEndOfSegment); + Assert.That(quotationMarkStringMatch.IsAtEndOfSegment, Is.False); } [Test] @@ -412,63 +442,63 @@ public void HasLeadingWhitespace() 7, 8 ); - Assert.IsTrue(quotationMarkStringMatch.HasLeadingWhitespace()); + Assert.That(quotationMarkStringMatch.HasLeadingWhitespace(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample\ttext").Build(), 7, 8 ); - Assert.IsTrue(quotationMarkStringMatch.HasLeadingWhitespace()); + Assert.That(quotationMarkStringMatch.HasLeadingWhitespace(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").Build(), 0, 1 ); - Assert.IsFalse(quotationMarkStringMatch.HasLeadingWhitespace()); + Assert.That(quotationMarkStringMatch.HasLeadingWhitespace(), Is.False); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").AddPrecedingMarker(UsfmMarkerType.Paragraph).Build(), 0, 1 ); - Assert.IsTrue(quotationMarkStringMatch.HasLeadingWhitespace()); + Assert.That(quotationMarkStringMatch.HasLeadingWhitespace(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").AddPrecedingMarker(UsfmMarkerType.Embed).Build(), 0, 1 ); - Assert.IsTrue(quotationMarkStringMatch.HasLeadingWhitespace()); + Assert.That(quotationMarkStringMatch.HasLeadingWhitespace(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").AddPrecedingMarker(UsfmMarkerType.Verse).Build(), 0, 1 ); - Assert.IsTrue(quotationMarkStringMatch.HasLeadingWhitespace()); + Assert.That(quotationMarkStringMatch.HasLeadingWhitespace(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").AddPrecedingMarker(UsfmMarkerType.Chapter).Build(), 0, 1 ); - Assert.IsFalse(quotationMarkStringMatch.HasLeadingWhitespace()); + Assert.That(quotationMarkStringMatch.HasLeadingWhitespace(), Is.False); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").AddPrecedingMarker(UsfmMarkerType.Character).Build(), 0, 1 ); - Assert.IsFalse(quotationMarkStringMatch.HasLeadingWhitespace()); + Assert.That(quotationMarkStringMatch.HasLeadingWhitespace(), Is.False); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("\u201csample text").AddPrecedingMarker(UsfmMarkerType.Verse).Build(), 0, 1 ); - Assert.IsTrue(quotationMarkStringMatch.HasLeadingWhitespace()); + Assert.That(quotationMarkStringMatch.HasLeadingWhitespace(), Is.True); } [Test] @@ -479,42 +509,42 @@ public void HasTrailingWhitespace() 5, 6 ); - Assert.IsTrue(quotationMarkStringMatch.HasTrailingWhitespace()); + Assert.That(quotationMarkStringMatch.HasTrailingWhitespace(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample\ttext").Build(), 5, 6 ); - Assert.IsTrue(quotationMarkStringMatch.HasTrailingWhitespace()); + Assert.That(quotationMarkStringMatch.HasTrailingWhitespace(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").Build(), 10, 11 ); - Assert.IsFalse(quotationMarkStringMatch.HasTrailingWhitespace()); + Assert.That(quotationMarkStringMatch.HasTrailingWhitespace(), Is.False); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").AddPrecedingMarker(UsfmMarkerType.Paragraph).Build(), 10, 11 ); - Assert.IsFalse(quotationMarkStringMatch.HasTrailingWhitespace()); + Assert.That(quotationMarkStringMatch.HasTrailingWhitespace(), Is.False); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").AddPrecedingMarker(UsfmMarkerType.Embed).Build(), 10, 11 ); - Assert.IsFalse(quotationMarkStringMatch.HasTrailingWhitespace()); + Assert.That(quotationMarkStringMatch.HasTrailingWhitespace(), Is.False); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").AddPrecedingMarker(UsfmMarkerType.Verse).Build(), 10, 11 ); - Assert.IsFalse(quotationMarkStringMatch.HasTrailingWhitespace()); + Assert.That(quotationMarkStringMatch.HasTrailingWhitespace(), Is.False); } [Test] @@ -525,35 +555,35 @@ public void HasLeadingPunctuation() 7, 8 ); - Assert.IsTrue(quotationMarkStringMatch.HasLeadingPunctuation()); + Assert.That(quotationMarkStringMatch.HasLeadingPunctuation(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample) \u201d text").Build(), 8, 9 ); - Assert.IsFalse(quotationMarkStringMatch.HasLeadingPunctuation()); + Assert.That(quotationMarkStringMatch.HasLeadingPunctuation(), Is.False); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample,\u201d text").Build(), 7, 8 ); - Assert.IsTrue(quotationMarkStringMatch.HasLeadingPunctuation()); + Assert.That(quotationMarkStringMatch.HasLeadingPunctuation(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample.\u201d text").Build(), 7, 8 ); - Assert.IsTrue(quotationMarkStringMatch.HasLeadingPunctuation()); + Assert.That(quotationMarkStringMatch.HasLeadingPunctuation(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("\u201csample text").Build(), 0, 1 ); - Assert.IsFalse(quotationMarkStringMatch.HasLeadingPunctuation()); + Assert.That(quotationMarkStringMatch.HasLeadingPunctuation(), Is.False); } [Test] @@ -564,28 +594,28 @@ public void HasTrailingPunctuation() 7, 8 ); - Assert.IsTrue(quotationMarkStringMatch.HasTrailingPunctuation()); + Assert.That(quotationMarkStringMatch.HasTrailingPunctuation(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample \u201c text").Build(), 7, 8 ); - Assert.IsFalse(quotationMarkStringMatch.HasTrailingPunctuation()); + Assert.That(quotationMarkStringMatch.HasTrailingPunctuation(), Is.False); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text\u201d").Build(), 11, 12 ); - Assert.IsFalse(quotationMarkStringMatch.HasTrailingPunctuation()); + Assert.That(quotationMarkStringMatch.HasTrailingPunctuation(), Is.False); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample', text\u201d").Build(), 6, 7 ); - Assert.IsTrue(quotationMarkStringMatch.HasTrailingPunctuation()); + Assert.That(quotationMarkStringMatch.HasTrailingPunctuation(), Is.True); } [Test] @@ -596,21 +626,21 @@ public void HasLetterInLeadingSubstring() 1, 2 ); - Assert.IsTrue(quotationMarkStringMatch.HasLetterInLeadingSubstring()); + Assert.That(quotationMarkStringMatch.HasLetterInLeadingSubstring(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("ꮪample text").Build(), 1, 2 ); - Assert.IsTrue(quotationMarkStringMatch.HasLetterInLeadingSubstring()); + Assert.That(quotationMarkStringMatch.HasLetterInLeadingSubstring(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").Build(), 0, 1 ); - Assert.IsFalse(quotationMarkStringMatch.HasLetterInLeadingSubstring()); + Assert.That(quotationMarkStringMatch.HasLetterInLeadingSubstring(), Is.False); } [Test] @@ -621,21 +651,21 @@ public void HasLetterInTrailingSubstring() 9, 10 ); - Assert.IsTrue(quotationMarkStringMatch.HasLetterInTrailingSubstring()); + Assert.That(quotationMarkStringMatch.HasLetterInTrailingSubstring(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample tex𑢼").Build(), 9, 10 ); - Assert.IsTrue(quotationMarkStringMatch.HasLetterInTrailingSubstring()); + Assert.That(quotationMarkStringMatch.HasLetterInTrailingSubstring(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").Build(), 10, 11 ); - Assert.IsFalse(quotationMarkStringMatch.HasLetterInTrailingSubstring()); + Assert.That(quotationMarkStringMatch.HasLetterInTrailingSubstring(), Is.False); } [Test] @@ -646,28 +676,28 @@ public void HasLeadingLatinLetter() 1, 2 ); - Assert.IsTrue(quotationMarkStringMatch.HasLeadingLatinLetter()); + Assert.That(quotationMarkStringMatch.HasLeadingLatinLetter(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("5ample text").Build(), 1, 2 ); - Assert.IsFalse(quotationMarkStringMatch.HasLeadingLatinLetter()); + Assert.That(quotationMarkStringMatch.HasLeadingLatinLetter(), Is.False); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("Sample text").Build(), 1, 2 ); - Assert.IsTrue(quotationMarkStringMatch.HasLeadingLatinLetter()); + Assert.That(quotationMarkStringMatch.HasLeadingLatinLetter(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").Build(), 0, 1 ); - Assert.IsFalse(quotationMarkStringMatch.HasLeadingLatinLetter()); + Assert.That(quotationMarkStringMatch.HasLeadingLatinLetter(), Is.False); } [Test] @@ -678,21 +708,21 @@ public void HasTrailingLatinLetter() 9, 10 ); - Assert.IsTrue(quotationMarkStringMatch.HasTrailingLatinLetter()); + Assert.That(quotationMarkStringMatch.HasTrailingLatinLetter(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample texT").Build(), 9, 10 ); - Assert.IsTrue(quotationMarkStringMatch.HasTrailingLatinLetter()); + Assert.That(quotationMarkStringMatch.HasTrailingLatinLetter(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample text").Build(), 10, 11 ); - Assert.IsFalse(quotationMarkStringMatch.HasTrailingLatinLetter()); + Assert.That(quotationMarkStringMatch.HasTrailingLatinLetter(), Is.False); } [Test] @@ -703,55 +733,55 @@ public void HasQuoteIntroducerInLeadingSubstring() 8, 9 ); - Assert.IsTrue(quotationMarkStringMatch.HasQuoteIntroducerInLeadingSubstring()); + Assert.That(quotationMarkStringMatch.HasQuoteIntroducerInLeadingSubstring(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample,\u201ctext").Build(), 7, 8 ); - Assert.IsTrue(quotationMarkStringMatch.HasQuoteIntroducerInLeadingSubstring()); + Assert.That(quotationMarkStringMatch.HasQuoteIntroducerInLeadingSubstring(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample: \u201ctext").Build(), 8, 9 ); - Assert.IsTrue(quotationMarkStringMatch.HasQuoteIntroducerInLeadingSubstring()); + Assert.That(quotationMarkStringMatch.HasQuoteIntroducerInLeadingSubstring(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample:\u201ctext").Build(), 7, 8 ); - Assert.IsTrue(quotationMarkStringMatch.HasQuoteIntroducerInLeadingSubstring()); + Assert.That(quotationMarkStringMatch.HasQuoteIntroducerInLeadingSubstring(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample, \u201ctext").Build(), 9, 10 ); - Assert.IsTrue(quotationMarkStringMatch.HasQuoteIntroducerInLeadingSubstring()); + Assert.That(quotationMarkStringMatch.HasQuoteIntroducerInLeadingSubstring(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample,, \u201ctext").Build(), 9, 10 ); - Assert.IsTrue(quotationMarkStringMatch.HasQuoteIntroducerInLeadingSubstring()); + Assert.That(quotationMarkStringMatch.HasQuoteIntroducerInLeadingSubstring(), Is.True); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample, a \u201ctext").Build(), 10, 11 ); - Assert.IsFalse(quotationMarkStringMatch.HasQuoteIntroducerInLeadingSubstring()); + Assert.That(quotationMarkStringMatch.HasQuoteIntroducerInLeadingSubstring(), Is.False); quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("sample, text").Build(), 8, 9 ); - Assert.IsTrue(quotationMarkStringMatch.HasQuoteIntroducerInLeadingSubstring()); + Assert.That(quotationMarkStringMatch.HasQuoteIntroducerInLeadingSubstring(), Is.True); } } diff --git a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkTabulatorTests.cs b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkTabulatorTests.cs index e9962af3c..73f3fa2be 100644 --- a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkTabulatorTests.cs +++ b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkTabulatorTests.cs @@ -66,26 +66,24 @@ public void CalculateNumDifferences() public void CalculateSimilarity() { var singleLevelQuotationMarkTabulator = new QuotationMarkTabulator(); - singleLevelQuotationMarkTabulator.Tabulate( - [ - new QuotationMarkMetadata( - "\u201c", - 1, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 0, - 1 - ), - new QuotationMarkMetadata( - "\u201d", - 1, - QuotationMarkDirection.Closing, - new TextSegment.Builder().Build(), - 0, - 1 - ), - ] - ); + singleLevelQuotationMarkTabulator.Tabulate([ + new QuotationMarkMetadata( + "\u201c", + 1, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 0, + 1 + ), + new QuotationMarkMetadata( + "\u201d", + 1, + QuotationMarkDirection.Closing, + new TextSegment.Builder().Build(), + 0, + 1 + ), + ]); Assert.That( singleLevelQuotationMarkTabulator.CalculateSimilarity( @@ -114,7 +112,7 @@ public void CalculateSimilarity() "", [ new SingleLevelQuoteConvention("\u201c", "\u201d"), - new SingleLevelQuoteConvention("\u00ab", "\u00bb") + new SingleLevelQuoteConvention("\u00ab", "\u00bb"), ] ) ), @@ -129,42 +127,40 @@ public void CalculateSimilarity() Is.EqualTo(0.0) ); var twoLevelQuotationMarkTabulator = new QuotationMarkTabulator(); - twoLevelQuotationMarkTabulator.Tabulate( - [ - new QuotationMarkMetadata( - "\u201c", - 1, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 0, - 1 - ), - new QuotationMarkMetadata( - "\u201d", - 1, - QuotationMarkDirection.Closing, - new TextSegment.Builder().Build(), - 0, - 1 - ), - new QuotationMarkMetadata( - "\u2018", - 2, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 0, - 2 - ), - new QuotationMarkMetadata( - "\u2019", - 2, - QuotationMarkDirection.Closing, - new TextSegment.Builder().Build(), - 0, - 2 - ), - ] - ); + twoLevelQuotationMarkTabulator.Tabulate([ + new QuotationMarkMetadata( + "\u201c", + 1, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 0, + 1 + ), + new QuotationMarkMetadata( + "\u201d", + 1, + QuotationMarkDirection.Closing, + new TextSegment.Builder().Build(), + 0, + 1 + ), + new QuotationMarkMetadata( + "\u2018", + 2, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 0, + 2 + ), + new QuotationMarkMetadata( + "\u2019", + 2, + QuotationMarkDirection.Closing, + new TextSegment.Builder().Build(), + 0, + 2 + ), + ]); Assert.That( twoLevelQuotationMarkTabulator.CalculateSimilarity( new QuoteConvention("", [new SingleLevelQuoteConvention("\u201c", "\u201d")]) @@ -177,7 +173,7 @@ public void CalculateSimilarity() "", [ new SingleLevelQuoteConvention("\u201c", "\u201d"), - new SingleLevelQuoteConvention("\u2018", "\u2019") + new SingleLevelQuoteConvention("\u2018", "\u2019"), ] ) ), @@ -189,7 +185,7 @@ public void CalculateSimilarity() "", [ new SingleLevelQuoteConvention("\u201c", "\u201d"), - new SingleLevelQuoteConvention("\u00ab", "\u00bb") + new SingleLevelQuoteConvention("\u00ab", "\u00bb"), ] ) ), @@ -201,7 +197,7 @@ public void CalculateSimilarity() "", [ new SingleLevelQuoteConvention("\u2018", "\u2019"), - new SingleLevelQuoteConvention("\u2018", "\u2019") + new SingleLevelQuoteConvention("\u2018", "\u2019"), ] ) ), diff --git a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkUpdateFirstPassTests.cs b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkUpdateFirstPassTests.cs index aabce3b35..93d7e83eb 100644 --- a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkUpdateFirstPassTests.cs +++ b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkUpdateFirstPassTests.cs @@ -15,85 +15,98 @@ public void CheckWhetherFallbackModeWillWork() ); // Cases where we expect fallback mode to work - Assert.IsTrue( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("standard_english"), GetQuoteConventionByName("standard_english") - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("standard_french"), GetQuoteConventionByName("british_english") - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("typewriter_western_european"), GetQuoteConventionByName("standard_russian") - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("typewriter_western_european_variant"), GetQuoteConventionByName("standard_arabic") - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("central_european"), GetQuoteConventionByName("british_typewriter_english") - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("standard_swedish"), GetQuoteConventionByName("typewriter_french") - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("standard_finnish"), GetQuoteConventionByName("british_inspired_western_european") - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("eastern_european"), GetQuoteConventionByName("central_european") - ) + ), + Is.True ); // Cases where we expect fallback mode to fail - Assert.IsFalse( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("standard_english"), GetQuoteConventionByName("western_european") - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("typewriter_french"), GetQuoteConventionByName("western_european") - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("standard_french"), GetQuoteConventionByName("french_variant") - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("central_european"), GetQuoteConventionByName("typewriter_western_european") - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("eastern_european"), GetQuoteConventionByName("standard_russian") - ) + ), + Is.False ); } @@ -106,97 +119,112 @@ public void CheckWhetherFallbackModeWillWorkWithNormalizedConventions() ); // Cases where we expect fallback mode to work - Assert.IsTrue( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("standard_english").Normalize(), GetQuoteConventionByName("standard_english") - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("standard_french").Normalize(), GetQuoteConventionByName("british_english") - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("typewriter_western_european").Normalize(), GetQuoteConventionByName("standard_russian") - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("typewriter_western_european_variant").Normalize(), GetQuoteConventionByName("standard_arabic") - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("central_european").Normalize(), GetQuoteConventionByName("british_typewriter_english") - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("standard_swedish").Normalize(), GetQuoteConventionByName("typewriter_french") - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("standard_finnish").Normalize(), GetQuoteConventionByName("british_inspired_western_european") - ) + ), + Is.True ); - Assert.IsTrue( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("eastern_european").Normalize(), GetQuoteConventionByName("central_european") - ) + ), + Is.True ); // Cases where we expect fallback mode to fail - Assert.IsFalse( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("western_european").Normalize(), GetQuoteConventionByName("standard_english") - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("french_variant").Normalize(), GetQuoteConventionByName("hybrid_typewriter_english") - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("british_inspired_western_european").Normalize(), GetQuoteConventionByName("standard_russian") - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("typewriter_english").Normalize(), GetQuoteConventionByName("western_european") - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("central_european_guillemets").Normalize(), GetQuoteConventionByName("french_variant") - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("standard_arabic").Normalize(), GetQuoteConventionByName("hybrid_typewriter_english") - ) + ), + Is.False ); - Assert.IsFalse( + Assert.That( firstPassAnalyzer.CheckWhetherFallbackModeWillWork( GetQuoteConventionByName("standard_russian").Normalize(), GetQuoteConventionByName("standard_french") - ) + ), + Is.False ); } @@ -209,7 +237,7 @@ public void ChooseBestActionForChapter() "Now the serpent was more subtle than any animal " + "of the field which Yahweh God had made. " + "He said to the woman, “Has God really said, " - + "‘You shall not eat of any tree of the garden’?”" + + "‘You shall not eat of any tree of the garden’?”", ], "standard_english", "standard_english" @@ -223,7 +251,7 @@ public void ChooseBestActionForChapter() "Now the serpent was more subtle than any animal " + "of the field which Yahweh God had made. " + "He said to the woman, “Has God really said, " - + "‘You shall not eat of any tree of the garden’?" + + "‘You shall not eat of any tree of the garden’?", ], "standard_english", "standard_english" @@ -237,7 +265,7 @@ public void ChooseBestActionForChapter() "Now the serpent was more subtle than any animal " + "of the field which Yahweh God had made. " + "He said to the woman, Has God really said, " - + "You shall not eat of any tree of the garden?”" + + "You shall not eat of any tree of the garden?”", ], "standard_english", "standard_english" @@ -251,7 +279,7 @@ public void ChooseBestActionForChapter() "“Now the serpent was more “subtle than any animal " + "of the “field which “Yahweh God had made. " + "He said to the woman, “Has God really said, " - + "“You shall not eat of any tree of the garden?" + + "“You shall not eat of any tree of the garden?", ], "standard_english", "standard_english" @@ -265,7 +293,7 @@ public void ChooseBestActionForChapter() "Now the serpent was more subtle than any animal " + "of the field which Yahweh God had made. " + "He said to the woman\"Has God really said, " - + "You shall not eat of any tree of the garden?" + + "You shall not eat of any tree of the garden?", ], "typewriter_english", "standard_english" @@ -279,7 +307,7 @@ public void ChooseBestActionForChapter() "Now the serpent was more subtle than any animal " + "of the field which Yahweh God had made. " + "He said to the woman\"Has God really said, " - + "You shall not eat of any tree of the garden?" + + "You shall not eat of any tree of the garden?", ], "typewriter_english", "standard_english" @@ -293,7 +321,7 @@ public void ChooseBestActionForChapter() "\"Now the serpent was more \"subtle than any animal " + "of the \"field which \"Yahweh God had made. " + "He said to the woman, \"Has God really said, " - + "\"You shall not eat of any tree of the garden?" + + "\"You shall not eat of any tree of the garden?", ], "typewriter_english", "standard_english" @@ -317,15 +345,15 @@ public void ChooseBestActionBasedOnObservedIssues() // Test with one issue Assert.That( - firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues( - [QuotationMarkResolutionIssue.UnpairedQuotationMark] - ), + firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues([ + QuotationMarkResolutionIssue.UnpairedQuotationMark, + ]), Is.EqualTo(QuotationMarkUpdateStrategy.Skip) ); Assert.That( - firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues( - [QuotationMarkResolutionIssue.AmbiguousQuotationMark] - ), + firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues([ + QuotationMarkResolutionIssue.AmbiguousQuotationMark, + ]), Is.EqualTo(QuotationMarkUpdateStrategy.Skip) ); Assert.That( @@ -335,24 +363,24 @@ public void ChooseBestActionBasedOnObservedIssues() // Test with multiple issues Assert.That( - firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues( - [QuotationMarkResolutionIssue.TooDeepNesting, QuotationMarkResolutionIssue.AmbiguousQuotationMark,] - ), + firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues([ + QuotationMarkResolutionIssue.TooDeepNesting, + QuotationMarkResolutionIssue.AmbiguousQuotationMark, + ]), Is.EqualTo(QuotationMarkUpdateStrategy.Skip) ); Assert.That( - firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues( - [ - QuotationMarkResolutionIssue.UnpairedQuotationMark, - QuotationMarkResolutionIssue.AmbiguousQuotationMark, - ] - ), + firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues([ + QuotationMarkResolutionIssue.UnpairedQuotationMark, + QuotationMarkResolutionIssue.AmbiguousQuotationMark, + ]), Is.EqualTo(QuotationMarkUpdateStrategy.Skip) ); Assert.That( - firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues( - [QuotationMarkResolutionIssue.TooDeepNesting, QuotationMarkResolutionIssue.UnpairedQuotationMark,] - ), + firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues([ + QuotationMarkResolutionIssue.TooDeepNesting, + QuotationMarkResolutionIssue.UnpairedQuotationMark, + ]), Is.EqualTo(QuotationMarkUpdateStrategy.Skip) ); } @@ -372,15 +400,15 @@ public void ChooseBestActionBasedOnObservedIssuesWithBasicFallback() // Test with one issue Assert.That( - firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues( - [QuotationMarkResolutionIssue.UnpairedQuotationMark] - ), + firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues([ + QuotationMarkResolutionIssue.UnpairedQuotationMark, + ]), Is.EqualTo(QuotationMarkUpdateStrategy.ApplyFallback) ); Assert.That( - firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues( - [QuotationMarkResolutionIssue.AmbiguousQuotationMark] - ), + firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues([ + QuotationMarkResolutionIssue.AmbiguousQuotationMark, + ]), Is.EqualTo(QuotationMarkUpdateStrategy.Skip) ); Assert.That( @@ -390,24 +418,24 @@ public void ChooseBestActionBasedOnObservedIssuesWithBasicFallback() // Test with multiple issues Assert.That( - firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues( - [ - QuotationMarkResolutionIssue.AmbiguousQuotationMark, - QuotationMarkResolutionIssue.UnpairedQuotationMark, - ] - ), + firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues([ + QuotationMarkResolutionIssue.AmbiguousQuotationMark, + QuotationMarkResolutionIssue.UnpairedQuotationMark, + ]), Is.EqualTo(QuotationMarkUpdateStrategy.Skip) ); Assert.That( - firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues( - [QuotationMarkResolutionIssue.AmbiguousQuotationMark, QuotationMarkResolutionIssue.TooDeepNesting,] - ), + firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues([ + QuotationMarkResolutionIssue.AmbiguousQuotationMark, + QuotationMarkResolutionIssue.TooDeepNesting, + ]), Is.EqualTo(QuotationMarkUpdateStrategy.Skip) ); Assert.That( - firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues( - [QuotationMarkResolutionIssue.TooDeepNesting, QuotationMarkResolutionIssue.UnpairedQuotationMark,] - ), + firstPassAnalyzer.ChooseBestStrategyBasedOnObservedIssues([ + QuotationMarkResolutionIssue.TooDeepNesting, + QuotationMarkResolutionIssue.UnpairedQuotationMark, + ]), Is.EqualTo(QuotationMarkUpdateStrategy.ApplyFallback) ); @@ -527,7 +555,7 @@ of the field which Yahweh God had made. List expectedActions = [ QuotationMarkUpdateStrategy.ApplyFull, - QuotationMarkUpdateStrategy.ApplyFull + QuotationMarkUpdateStrategy.ApplyFull, ]; List observedActions = RunFirstPass( normalizedUsfm, @@ -551,7 +579,7 @@ You shall not eat of any tree of the garden?” List expectedActions = [ QuotationMarkUpdateStrategy.ApplyFull, - QuotationMarkUpdateStrategy.ApplyFallback + QuotationMarkUpdateStrategy.ApplyFallback, ]; List observedActions = RunFirstPass( normalizedUsfm, @@ -575,7 +603,7 @@ of the field which Yahweh God had” made. List expectedActions = [ QuotationMarkUpdateStrategy.ApplyFallback, - QuotationMarkUpdateStrategy.ApplyFull + QuotationMarkUpdateStrategy.ApplyFull, ]; List observedActions = RunFirstPass( normalizedUsfm, @@ -599,7 +627,7 @@ You shall not""eat of any tree of the garden?"" List expectedActions = [ QuotationMarkUpdateStrategy.ApplyFull, - QuotationMarkUpdateStrategy.Skip + QuotationMarkUpdateStrategy.Skip, ]; List observedActions = RunFirstPass( normalizedUsfm, @@ -623,7 +651,7 @@ of the field""which Yahweh God had made. List expectedActions = [ QuotationMarkUpdateStrategy.Skip, - QuotationMarkUpdateStrategy.ApplyFull + QuotationMarkUpdateStrategy.ApplyFull, ]; List observedActions = RunFirstPass( normalizedUsfm, @@ -647,7 +675,7 @@ You shall not eat of any tree of the garden?” List expectedActions = [ QuotationMarkUpdateStrategy.ApplyFallback, - QuotationMarkUpdateStrategy.ApplyFallback + QuotationMarkUpdateStrategy.ApplyFallback, ]; List observedActions = RunFirstPass( normalizedUsfm, @@ -671,7 +699,7 @@ You shall not eat of any""tree of the garden? List expectedActions = [ QuotationMarkUpdateStrategy.Skip, - QuotationMarkUpdateStrategy.Skip + QuotationMarkUpdateStrategy.Skip, ]; List observedActions = RunFirstPass( normalizedUsfm, @@ -695,7 +723,7 @@ You shall not eat of any""tree of the garden? List expectedActions = [ QuotationMarkUpdateStrategy.ApplyFallback, - QuotationMarkUpdateStrategy.Skip + QuotationMarkUpdateStrategy.Skip, ]; List observedActions = RunFirstPass( normalizedUsfm, @@ -719,7 +747,7 @@ You shall not eat of any tree of the garden ? "" List expectedActions = [ QuotationMarkUpdateStrategy.Skip, - QuotationMarkUpdateStrategy.ApplyFallback + QuotationMarkUpdateStrategy.ApplyFallback, ]; List observedActions = RunFirstPass( normalizedUsfm, @@ -739,12 +767,12 @@ string targetQuoteConventionName QuoteConvention sourceQuoteConvention = QuoteConventions.Standard.GetQuoteConventionByName( sourceQuoteConventionName ); - Assert.IsNotNull(sourceQuoteConvention); + Assert.That(sourceQuoteConvention, Is.Not.Null); QuoteConvention targetQuoteConvention = QuoteConventions.Standard.GetQuoteConventionByName( targetQuoteConventionName ); - Assert.IsNotNull(targetQuoteConvention); + Assert.That(targetQuoteConvention, Is.Not.Null); var firstPassAnalyzer = new QuotationMarkUpdateFirstPass(sourceQuoteConvention, targetQuoteConvention); UsfmParser.Parse(normalizedUsfm, firstPassAnalyzer); @@ -761,12 +789,12 @@ string targetQuoteConventionName QuoteConvention sourceQuoteConvention = QuoteConventions.Standard.GetQuoteConventionByName( sourceQuoteConventionName ); - Assert.IsNotNull(sourceQuoteConvention); + Assert.That(sourceQuoteConvention, Is.Not.Null); QuoteConvention targetQuoteConvention = QuoteConventions.Standard.GetQuoteConventionByName( targetQuoteConventionName ); - Assert.IsNotNull(targetQuoteConvention); + Assert.That(targetQuoteConvention, Is.Not.Null); var firstPassAnalyzer = new QuotationMarkUpdateFirstPass(sourceQuoteConvention, targetQuoteConvention); @@ -780,7 +808,7 @@ string targetQuoteConventionName private static QuoteConvention GetQuoteConventionByName(string name) { QuoteConvention quoteConvention = QuoteConventions.Standard.GetQuoteConventionByName(name); - Assert.IsNotNull(quoteConvention); + Assert.That(quoteConvention, Is.Not.Null); return quoteConvention; } } diff --git a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuoteConventionChangingUsfmBlockUpdateHandlerTests.cs b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuoteConventionChangingUsfmBlockUpdateHandlerTests.cs index 083b9f505..dd9ca7272 100644 --- a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuoteConventionChangingUsfmBlockUpdateHandlerTests.cs +++ b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuoteConventionChangingUsfmBlockUpdateHandlerTests.cs @@ -372,7 +372,7 @@ You shall not eat of any tree of the garden'?"" chapterStrategies: [ QuotationMarkUpdateStrategy.ApplyFallback, - QuotationMarkUpdateStrategy.ApplyFallback + QuotationMarkUpdateStrategy.ApplyFallback, ] ) ); @@ -531,8 +531,8 @@ public void CreateTextSegmentsBasic() Assert.That(textSegments[0].Text, Is.EqualTo("test segment")); Assert.That(textSegments[0].ImmediatePrecedingMarker, Is.EqualTo(UsfmMarkerType.NoMarker)); Assert.That(textSegments[0].MarkersInPrecedingContext, Has.Count.EqualTo(0)); - Assert.IsNull(textSegments[0].PreviousSegment); - Assert.IsNull(textSegments[0].NextSegment); + Assert.That(textSegments[0].PreviousSegment, Is.Null); + Assert.That(textSegments[0].NextSegment, Is.Null); } [Test] @@ -557,10 +557,10 @@ public void CreateTextSegmentsWithPrecedingMarkers() Assert.That(textSegments[0].Text, Is.EqualTo("test segment")); Assert.That(textSegments[0].ImmediatePrecedingMarker, Is.EqualTo(UsfmMarkerType.Paragraph)); Assert.That( - textSegments[0].MarkersInPrecedingContext.SequenceEqual([UsfmMarkerType.Verse, UsfmMarkerType.Paragraph,]) + textSegments[0].MarkersInPrecedingContext.SequenceEqual([UsfmMarkerType.Verse, UsfmMarkerType.Paragraph]) ); - Assert.IsNull(textSegments[0].PreviousSegment); - Assert.IsNull(textSegments[0].NextSegment); + Assert.That(textSegments[0].PreviousSegment, Is.Null); + Assert.That(textSegments[0].NextSegment, Is.Null); } [Test] @@ -589,17 +589,17 @@ public void CreateTextSegmentsWithMultipleTextTokens() Assert.That(textSegments[0].Text, Is.EqualTo("test segment1")); Assert.That(textSegments[0].ImmediatePrecedingMarker, Is.EqualTo(UsfmMarkerType.Paragraph)); Assert.That( - textSegments[0].MarkersInPrecedingContext.SequenceEqual([UsfmMarkerType.Verse, UsfmMarkerType.Paragraph,]) + textSegments[0].MarkersInPrecedingContext.SequenceEqual([UsfmMarkerType.Verse, UsfmMarkerType.Paragraph]) ); - Assert.IsNull(textSegments[0].PreviousSegment); + Assert.That(textSegments[0].PreviousSegment, Is.Null); Assert.That(textSegments[0].NextSegment, Is.EqualTo(textSegments[1])); Assert.That(textSegments[1].Text, Is.EqualTo("test segment2")); Assert.That(textSegments[1].ImmediatePrecedingMarker, Is.EqualTo(UsfmMarkerType.Character)); Assert.That( - textSegments[1].MarkersInPrecedingContext.SequenceEqual([UsfmMarkerType.Verse, UsfmMarkerType.Character,]) + textSegments[1].MarkersInPrecedingContext.SequenceEqual([UsfmMarkerType.Verse, UsfmMarkerType.Character]) ); Assert.That(textSegments[1].PreviousSegment, Is.EqualTo(textSegments[0])); - Assert.IsNull(textSegments[1].NextSegment); + Assert.That(textSegments[1].NextSegment, Is.Null); } [Test] @@ -612,7 +612,7 @@ public void CreateTextSegment() var usfmToken = new UsfmToken("test segment"); TextSegment segment = quoteConventionChanger.InternalCreateTextSegment(usfmToken); - Assert.IsNotNull(segment); + Assert.That(segment, Is.Not.Null); Assert.That(segment.Text, Is.EqualTo("test segment")); Assert.That(segment.ImmediatePrecedingMarker, Is.EqualTo(UsfmMarkerType.NoMarker)); Assert.That(segment.MarkersInPrecedingContext, Has.Count.EqualTo(0)); @@ -630,17 +630,17 @@ public void SetPreviousAndNextForSegments() [ new TextSegment.Builder().SetText("segment 1 text").Build(), new TextSegment.Builder().SetText("segment 2 text").Build(), - new TextSegment.Builder().SetText("segment 3 text").Build() + new TextSegment.Builder().SetText("segment 3 text").Build(), ]; quoteConventionChanger.InternalSetPreviousAndNextForSegments(segments); - Assert.IsNull(segments[0].PreviousSegment); + Assert.That(segments[0].PreviousSegment, Is.Null); Assert.That(segments[0].NextSegment, Is.EqualTo(segments[1])); Assert.That(segments[1].PreviousSegment, Is.EqualTo(segments[0])); Assert.That(segments[1].NextSegment, Is.EqualTo(segments[2])); Assert.That(segments[2].PreviousSegment, Is.EqualTo(segments[1])); - Assert.IsNull(segments[2].NextSegment); + Assert.That(segments[2].NextSegment, Is.Null); } [Test] @@ -686,7 +686,7 @@ public void UpdateQuotationMarks() textSegment: multiCharacterTextSegment, startIndex: 27, endIndex: 29 - ) + ), ]; multiCharToSingleCharQuoteConventionChanger.UpdateQuotationMarks(multiCharacterQuotationMarks); @@ -745,7 +745,7 @@ public void UpdateQuotationMarks() textSegment: singleCharacterTextSegment, startIndex: 26, endIndex: 27 - ) + ), ]; singleCharToMultiCharQuoteConventionChanger.UpdateQuotationMarks(singleCharacterQuotationMarks); @@ -862,12 +862,12 @@ private static MockQuoteConventionChangingUsfmUpdateBlockHandler CreateQuoteConv QuoteConvention sourceQuoteConvention = QuoteConventions.Standard.GetQuoteConventionByName( sourceQuoteConventionName ); - Assert.IsNotNull(sourceQuoteConvention); + Assert.That(sourceQuoteConvention, Is.Not.Null); QuoteConvention targetQuoteConvention = QuoteConventions.Standard.GetQuoteConventionByName( targetQuoteConventionName ); - Assert.IsNotNull(targetQuoteConvention); + Assert.That(targetQuoteConvention, Is.Not.Null); return new MockQuoteConventionChangingUsfmUpdateBlockHandler( sourceQuoteConvention, diff --git a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuoteConventionSetTests.cs b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuoteConventionSetTests.cs index 25afafbb5..c774f3ce9 100644 --- a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuoteConventionSetTests.cs +++ b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuoteConventionSetTests.cs @@ -24,9 +24,10 @@ public void QuoteRegexes() Is.EqualTo(new Regex(@"", RegexOptions.Compiled).ToString()) ); - var quoteConventionSetWithEmptyConventions = new QuoteConventionSet( - [new QuoteConvention("empty convention 1", []), new QuoteConvention("empty convention 2", [])] - ); + var quoteConventionSetWithEmptyConventions = new QuoteConventionSet([ + new QuoteConvention("empty convention 1", []), + new QuoteConvention("empty convention 2", []), + ]); Assert.That( quoteConventionSetWithEmptyConventions.OpeningQuotationMarkRegex.ToString(), Is.EqualTo(new Regex(@"", RegexOptions.Compiled).ToString()) @@ -40,19 +41,17 @@ public void QuoteRegexes() Is.EqualTo(new Regex(@"", RegexOptions.Compiled).ToString()) ); - var standardEnglishQuoteConventionSet = new QuoteConventionSet( - [ - new QuoteConvention( - "standard_english", - [ - new SingleLevelQuoteConvention("\u201c", "\u201d"), - new SingleLevelQuoteConvention("\u2018", "\u2019"), - new SingleLevelQuoteConvention("\u201c", "\u201d"), - new SingleLevelQuoteConvention("\u2018", "\u2019"), - ] - ) - ] - ); + var standardEnglishQuoteConventionSet = new QuoteConventionSet([ + new QuoteConvention( + "standard_english", + [ + new SingleLevelQuoteConvention("\u201c", "\u201d"), + new SingleLevelQuoteConvention("\u2018", "\u2019"), + new SingleLevelQuoteConvention("\u201c", "\u201d"), + new SingleLevelQuoteConvention("\u2018", "\u2019"), + ] + ), + ]); Assert.That( standardEnglishQuoteConventionSet.OpeningQuotationMarkRegex.ToString(), Is.EqualTo(new Regex(@"[‘“]", RegexOptions.Compiled).ToString()) @@ -66,18 +65,16 @@ public void QuoteRegexes() Is.EqualTo(new Regex(@"[‘’“”]", RegexOptions.Compiled).ToString()) ); - var westernEuropeanQuoteConventionSet = new QuoteConventionSet( - [ - new QuoteConvention( - "western_european", - [ - new SingleLevelQuoteConvention("\u00ab", "\u00bb"), - new SingleLevelQuoteConvention("\u201c", "\u201d"), - new SingleLevelQuoteConvention("\u2018", "\u2019"), - ] - ), - ] - ); + var westernEuropeanQuoteConventionSet = new QuoteConventionSet([ + new QuoteConvention( + "western_european", + [ + new SingleLevelQuoteConvention("\u00ab", "\u00bb"), + new SingleLevelQuoteConvention("\u201c", "\u201d"), + new SingleLevelQuoteConvention("\u2018", "\u2019"), + ] + ), + ]); Assert.That( westernEuropeanQuoteConventionSet.OpeningQuotationMarkRegex.ToString(), Is.EqualTo(new Regex(@"[‘“«]", RegexOptions.Compiled).ToString()) @@ -91,37 +88,35 @@ public void QuoteRegexes() Is.EqualTo(new Regex(@"[‘’“”«»]", RegexOptions.Compiled).ToString()) ); - var multipleQuoteConventionSet = new QuoteConventionSet( - [ - new QuoteConvention( - "standard_english", - [ - new SingleLevelQuoteConvention("\u201c", "\u201d"), - new SingleLevelQuoteConvention("\u2018", "\u2019"), - new SingleLevelQuoteConvention("\u201c", "\u201d"), - new SingleLevelQuoteConvention("\u2018", "\u2019"), - ] - ), - new QuoteConvention( - "typewriter_french", - [ - new SingleLevelQuoteConvention("<<", ">>"), - new SingleLevelQuoteConvention("<", ">"), - new SingleLevelQuoteConvention("<<", ">>"), - new SingleLevelQuoteConvention("<", ">"), - ] - ), - new QuoteConvention( - "standard_french", - [ - new SingleLevelQuoteConvention("\u00ab", "\u00bb"), - new SingleLevelQuoteConvention("\u2039", "\u203a"), - new SingleLevelQuoteConvention("\u00ab", "\u00bb"), - new SingleLevelQuoteConvention("\u2039", "\u203a"), - ] - ), - ] - ); + var multipleQuoteConventionSet = new QuoteConventionSet([ + new QuoteConvention( + "standard_english", + [ + new SingleLevelQuoteConvention("\u201c", "\u201d"), + new SingleLevelQuoteConvention("\u2018", "\u2019"), + new SingleLevelQuoteConvention("\u201c", "\u201d"), + new SingleLevelQuoteConvention("\u2018", "\u2019"), + ] + ), + new QuoteConvention( + "typewriter_french", + [ + new SingleLevelQuoteConvention("<<", ">>"), + new SingleLevelQuoteConvention("<", ">"), + new SingleLevelQuoteConvention("<<", ">>"), + new SingleLevelQuoteConvention("<", ">"), + ] + ), + new QuoteConvention( + "standard_french", + [ + new SingleLevelQuoteConvention("\u00ab", "\u00bb"), + new SingleLevelQuoteConvention("\u2039", "\u203a"), + new SingleLevelQuoteConvention("\u00ab", "\u00bb"), + new SingleLevelQuoteConvention("\u2039", "\u203a"), + ] + ), + ]); Assert.That( multipleQuoteConventionSet.OpeningQuotationMarkRegex.ToString(), Is.EqualTo(new Regex(@"[‘‹“«<<<]", RegexOptions.Compiled).ToString()) @@ -143,25 +138,24 @@ public void QuotationMarkPairMap() Assert.That(emptyQuoteConventionSet.OpeningMarksByClosingMark, Has.Count.EqualTo(0)); Assert.That(emptyQuoteConventionSet.ClosingMarksByOpeningMark, Has.Count.EqualTo(0)); - var quoteConventionSetWithEmptyConventions = new QuoteConventionSet( - [new QuoteConvention("empty convention 1", []), new QuoteConvention("empty convention 2", [])] - ); + var quoteConventionSetWithEmptyConventions = new QuoteConventionSet([ + new QuoteConvention("empty convention 1", []), + new QuoteConvention("empty convention 2", []), + ]); Assert.That(quoteConventionSetWithEmptyConventions.OpeningMarksByClosingMark, Has.Count.EqualTo(0)); Assert.That(quoteConventionSetWithEmptyConventions.ClosingMarksByOpeningMark, Has.Count.EqualTo(0)); - var standardEnglishQuoteConventionSet = new QuoteConventionSet( - [ - new QuoteConvention( - "standard_english", - [ - new SingleLevelQuoteConvention("\u201c", "\u201d"), - new SingleLevelQuoteConvention("\u2018", "\u2019"), - new SingleLevelQuoteConvention("\u201c", "\u201d"), - new SingleLevelQuoteConvention("\u2018", "\u2019"), - ] - ) - ] - ); + var standardEnglishQuoteConventionSet = new QuoteConventionSet([ + new QuoteConvention( + "standard_english", + [ + new SingleLevelQuoteConvention("\u201c", "\u201d"), + new SingleLevelQuoteConvention("\u2018", "\u2019"), + new SingleLevelQuoteConvention("\u201c", "\u201d"), + new SingleLevelQuoteConvention("\u2018", "\u2019"), + ] + ), + ]); Assert.That( standardEnglishQuoteConventionSet .OpeningMarksByClosingMark.OrderBy(kvp => kvp.Key) @@ -179,18 +173,16 @@ public void QuotationMarkPairMap() ) ); - var westernEuropeanQuoteConventionSet = new QuoteConventionSet( - [ - new QuoteConvention( - "western_european", - [ - new SingleLevelQuoteConvention("\u00ab", "\u00bb"), - new SingleLevelQuoteConvention("\u201c", "\u201d"), - new SingleLevelQuoteConvention("\u2018", "\u2019"), - ] - ), - ] - ); + var westernEuropeanQuoteConventionSet = new QuoteConventionSet([ + new QuoteConvention( + "western_european", + [ + new SingleLevelQuoteConvention("\u00ab", "\u00bb"), + new SingleLevelQuoteConvention("\u201c", "\u201d"), + new SingleLevelQuoteConvention("\u2018", "\u2019"), + ] + ), + ]); Assert.That( westernEuropeanQuoteConventionSet .OpeningMarksByClosingMark.OrderBy(kvp => kvp.Key) @@ -199,7 +191,7 @@ public void QuotationMarkPairMap() { { "’", ["‘"] }, { "”", ["“"] }, - { "»", ["«"] } + { "»", ["«"] }, }.OrderBy(kvp => kvp.Key), new QuotationMarkPairMapEqualityComparer() ) @@ -212,43 +204,41 @@ public void QuotationMarkPairMap() { { "‘", ["’"] }, { "“", ["”"] }, - { "«", ["»"] } + { "«", ["»"] }, }.OrderBy(kvp => kvp.Key), new QuotationMarkPairMapEqualityComparer() ) ); - var multipleQuoteConventionSet = new QuoteConventionSet( - [ - new QuoteConvention( - "standard_english", - [ - new SingleLevelQuoteConvention("\u201c", "\u201d"), - new SingleLevelQuoteConvention("\u2018", "\u2019"), - new SingleLevelQuoteConvention("\u201c", "\u201d"), - new SingleLevelQuoteConvention("\u2018", "\u2019"), - ] - ), - new QuoteConvention( - "central_european", - [ - new SingleLevelQuoteConvention("\u201e", "\u201c"), - new SingleLevelQuoteConvention("\u201a", "\u2018"), - new SingleLevelQuoteConvention("\u201e", "\u201c"), - new SingleLevelQuoteConvention("\u201a", "\u2018"), - ] - ), - new QuoteConvention( - "standard_swedish", - [ - new SingleLevelQuoteConvention("\u201d", "\u201d"), - new SingleLevelQuoteConvention("\u2019", "\u2019"), - new SingleLevelQuoteConvention("\u201d", "\u201d"), - new SingleLevelQuoteConvention("\u2019", "\u2019"), - ] - ), - ] - ); + var multipleQuoteConventionSet = new QuoteConventionSet([ + new QuoteConvention( + "standard_english", + [ + new SingleLevelQuoteConvention("\u201c", "\u201d"), + new SingleLevelQuoteConvention("\u2018", "\u2019"), + new SingleLevelQuoteConvention("\u201c", "\u201d"), + new SingleLevelQuoteConvention("\u2018", "\u2019"), + ] + ), + new QuoteConvention( + "central_european", + [ + new SingleLevelQuoteConvention("\u201e", "\u201c"), + new SingleLevelQuoteConvention("\u201a", "\u2018"), + new SingleLevelQuoteConvention("\u201e", "\u201c"), + new SingleLevelQuoteConvention("\u201a", "\u2018"), + ] + ), + new QuoteConvention( + "standard_swedish", + [ + new SingleLevelQuoteConvention("\u201d", "\u201d"), + new SingleLevelQuoteConvention("\u2019", "\u2019"), + new SingleLevelQuoteConvention("\u201d", "\u201d"), + new SingleLevelQuoteConvention("\u2019", "\u2019"), + ] + ), + ]); Assert.That( multipleQuoteConventionSet .ClosingMarksByOpeningMark.OrderBy(kvp => kvp.Key) @@ -313,9 +303,11 @@ public void GetQuoteConventionByName() new SingleLevelQuoteConvention("\u2019", "\u2019"), ] ); - var multipleQuoteConventionSet = new QuoteConventionSet( - [standardEnglishQuoteConvention, centralEuropeanQuoteConvention, standardSwedishQuoteConvention] - ); + var multipleQuoteConventionSet = new QuoteConventionSet([ + standardEnglishQuoteConvention, + centralEuropeanQuoteConvention, + standardSwedishQuoteConvention, + ]); Assert.That( multipleQuoteConventionSet.GetQuoteConventionByName("standard_english"), @@ -329,7 +321,7 @@ public void GetQuoteConventionByName() multipleQuoteConventionSet.GetQuoteConventionByName("standard_swedish"), Is.EqualTo(standardSwedishQuoteConvention) ); - Assert.IsNull(multipleQuoteConventionSet.GetQuoteConventionByName("undefined convention")); + Assert.That(multipleQuoteConventionSet.GetQuoteConventionByName("undefined convention"), Is.Null); } [Test] @@ -395,9 +387,11 @@ public void GetPossibleOpeningQuotationMarks() var standardSwedishQuoteConventionSet = new QuoteConventionSet([standardSwedishQuoteConvention]); Assert.That(standardSwedishQuoteConventionSet.GetPossibleOpeningQuotationMarks().SequenceEqual(["’", "”"])); - var multipleQuoteConventionSet = new QuoteConventionSet( - [standardEnglishQuoteConvention, centralEuropeanQuoteConvention, standardSwedishQuoteConvention] - ); + var multipleQuoteConventionSet = new QuoteConventionSet([ + standardEnglishQuoteConvention, + centralEuropeanQuoteConvention, + standardSwedishQuoteConvention, + ]); Assert.That( multipleQuoteConventionSet.GetPossibleOpeningQuotationMarks().SequenceEqual(["‘", "’", "‚", "“", "”", "„"]) ); @@ -444,9 +438,11 @@ public void GetPossibleClosingQuotationMarks() var standardSwedishQuoteConventionSet = new QuoteConventionSet([standardSwedishQuoteConvention]); Assert.That(standardSwedishQuoteConventionSet.GetPossibleClosingQuotationMarks().SequenceEqual(["’", "”"])); - var multipleQuoteConventionSet = new QuoteConventionSet( - [standardEnglishQuoteConvention, centralEuropeanQuoteConvention, standardSwedishQuoteConvention] - ); + var multipleQuoteConventionSet = new QuoteConventionSet([ + standardEnglishQuoteConvention, + centralEuropeanQuoteConvention, + standardSwedishQuoteConvention, + ]); Assert.That(multipleQuoteConventionSet.GetPossibleClosingQuotationMarks().SequenceEqual(["‘", "’", "“", "”"])); } @@ -494,52 +490,50 @@ public void IsOpeningQuotationMark() ); var standardEnglishQuoteConventionSet = new QuoteConventionSet([standardEnglishQuoteConvention]); - Assert.IsTrue(standardEnglishQuoteConventionSet.IsValidOpeningQuotationMark("‘")); - Assert.IsTrue(standardEnglishQuoteConventionSet.IsValidOpeningQuotationMark("“")); - Assert.IsFalse(standardEnglishQuoteConventionSet.IsValidOpeningQuotationMark("”")); - Assert.IsFalse(standardEnglishQuoteConventionSet.IsValidOpeningQuotationMark("’")); - Assert.IsFalse(standardEnglishQuoteConventionSet.IsValidOpeningQuotationMark("")); - Assert.IsFalse(standardEnglishQuoteConventionSet.IsValidOpeningQuotationMark("‘“")); + Assert.That(standardEnglishQuoteConventionSet.IsValidOpeningQuotationMark("‘"), Is.True); + Assert.That(standardEnglishQuoteConventionSet.IsValidOpeningQuotationMark("“"), Is.True); + Assert.That(standardEnglishQuoteConventionSet.IsValidOpeningQuotationMark("”"), Is.False); + Assert.That(standardEnglishQuoteConventionSet.IsValidOpeningQuotationMark("’"), Is.False); + Assert.That(standardEnglishQuoteConventionSet.IsValidOpeningQuotationMark(""), Is.False); + Assert.That(standardEnglishQuoteConventionSet.IsValidOpeningQuotationMark("‘“"), Is.False); var centralEuropeanQuoteConventionSet = new QuoteConventionSet([centralEuropeanQuoteConvention]); - Assert.IsTrue(centralEuropeanQuoteConventionSet.IsValidOpeningQuotationMark("‚")); - Assert.IsTrue(centralEuropeanQuoteConventionSet.IsValidOpeningQuotationMark("„")); - Assert.IsFalse(centralEuropeanQuoteConventionSet.IsValidOpeningQuotationMark("‘")); - Assert.IsFalse(centralEuropeanQuoteConventionSet.IsValidOpeningQuotationMark("“")); + Assert.That(centralEuropeanQuoteConventionSet.IsValidOpeningQuotationMark("‚"), Is.True); + Assert.That(centralEuropeanQuoteConventionSet.IsValidOpeningQuotationMark("„"), Is.True); + Assert.That(centralEuropeanQuoteConventionSet.IsValidOpeningQuotationMark("‘"), Is.False); + Assert.That(centralEuropeanQuoteConventionSet.IsValidOpeningQuotationMark("“"), Is.False); var standardSwedishQuoteConventionSet = new QuoteConventionSet([standardSwedishQuoteConvention]); - Assert.IsTrue(standardSwedishQuoteConventionSet.IsValidOpeningQuotationMark("’")); - Assert.IsTrue(standardSwedishQuoteConventionSet.IsValidOpeningQuotationMark("”")); + Assert.That(standardSwedishQuoteConventionSet.IsValidOpeningQuotationMark("’"), Is.True); + Assert.That(standardSwedishQuoteConventionSet.IsValidOpeningQuotationMark("”"), Is.True); var standardFrenchQuoteConventionSet = new QuoteConventionSet([standardFrenchQuoteConvention]); - Assert.IsTrue(standardFrenchQuoteConventionSet.IsValidOpeningQuotationMark("«")); - Assert.IsTrue(standardFrenchQuoteConventionSet.IsValidOpeningQuotationMark("‹")); - Assert.IsFalse(standardFrenchQuoteConventionSet.IsValidOpeningQuotationMark("»")); - Assert.IsFalse(standardFrenchQuoteConventionSet.IsValidOpeningQuotationMark("›")); - - var multipleQuoteConventionSet = new QuoteConventionSet( - [ - standardEnglishQuoteConvention, - centralEuropeanQuoteConvention, - standardSwedishQuoteConvention, - standardFrenchQuoteConvention, - ] - ); + Assert.That(standardFrenchQuoteConventionSet.IsValidOpeningQuotationMark("«"), Is.True); + Assert.That(standardFrenchQuoteConventionSet.IsValidOpeningQuotationMark("‹"), Is.True); + Assert.That(standardFrenchQuoteConventionSet.IsValidOpeningQuotationMark("»"), Is.False); + Assert.That(standardFrenchQuoteConventionSet.IsValidOpeningQuotationMark("›"), Is.False); + + var multipleQuoteConventionSet = new QuoteConventionSet([ + standardEnglishQuoteConvention, + centralEuropeanQuoteConvention, + standardSwedishQuoteConvention, + standardFrenchQuoteConvention, + ]); Assert.That( multipleQuoteConventionSet .GetPossibleOpeningQuotationMarks() .SequenceEqual(["‘", "’", "‚", "‹", "“", "”", "„", "«"]) ); - Assert.IsTrue(multipleQuoteConventionSet.IsValidOpeningQuotationMark("‘")); - Assert.IsTrue(multipleQuoteConventionSet.IsValidOpeningQuotationMark("’")); - Assert.IsTrue(multipleQuoteConventionSet.IsValidOpeningQuotationMark("‚")); - Assert.IsTrue(multipleQuoteConventionSet.IsValidOpeningQuotationMark("“")); - Assert.IsTrue(multipleQuoteConventionSet.IsValidOpeningQuotationMark("”")); - Assert.IsTrue(multipleQuoteConventionSet.IsValidOpeningQuotationMark("„")); - Assert.IsTrue(multipleQuoteConventionSet.IsValidOpeningQuotationMark("«")); - Assert.IsTrue(multipleQuoteConventionSet.IsValidOpeningQuotationMark("‹")); - Assert.IsFalse(multipleQuoteConventionSet.IsValidOpeningQuotationMark("»")); - Assert.IsFalse(multipleQuoteConventionSet.IsValidOpeningQuotationMark("›")); + Assert.That(multipleQuoteConventionSet.IsValidOpeningQuotationMark("‘"), Is.True); + Assert.That(multipleQuoteConventionSet.IsValidOpeningQuotationMark("’"), Is.True); + Assert.That(multipleQuoteConventionSet.IsValidOpeningQuotationMark("‚"), Is.True); + Assert.That(multipleQuoteConventionSet.IsValidOpeningQuotationMark("“"), Is.True); + Assert.That(multipleQuoteConventionSet.IsValidOpeningQuotationMark("”"), Is.True); + Assert.That(multipleQuoteConventionSet.IsValidOpeningQuotationMark("„"), Is.True); + Assert.That(multipleQuoteConventionSet.IsValidOpeningQuotationMark("«"), Is.True); + Assert.That(multipleQuoteConventionSet.IsValidOpeningQuotationMark("‹"), Is.True); + Assert.That(multipleQuoteConventionSet.IsValidOpeningQuotationMark("»"), Is.False); + Assert.That(multipleQuoteConventionSet.IsValidOpeningQuotationMark("›"), Is.False); } [Test] @@ -586,48 +580,46 @@ public void IsClosingQuotationMark() ); var standardEnglishQuoteConventionSet = new QuoteConventionSet([standardEnglishQuoteConvention]); - Assert.IsTrue(standardEnglishQuoteConventionSet.IsValidClosingQuotationMark("”")); - Assert.IsTrue(standardEnglishQuoteConventionSet.IsValidClosingQuotationMark("’")); - Assert.IsFalse(standardEnglishQuoteConventionSet.IsValidClosingQuotationMark("‘")); - Assert.IsFalse(standardEnglishQuoteConventionSet.IsValidClosingQuotationMark("“")); - Assert.IsFalse(standardEnglishQuoteConventionSet.IsValidClosingQuotationMark("")); - Assert.IsFalse(standardEnglishQuoteConventionSet.IsValidClosingQuotationMark("”’")); + Assert.That(standardEnglishQuoteConventionSet.IsValidClosingQuotationMark("”"), Is.True); + Assert.That(standardEnglishQuoteConventionSet.IsValidClosingQuotationMark("’"), Is.True); + Assert.That(standardEnglishQuoteConventionSet.IsValidClosingQuotationMark("‘"), Is.False); + Assert.That(standardEnglishQuoteConventionSet.IsValidClosingQuotationMark("“"), Is.False); + Assert.That(standardEnglishQuoteConventionSet.IsValidClosingQuotationMark(""), Is.False); + Assert.That(standardEnglishQuoteConventionSet.IsValidClosingQuotationMark("”’"), Is.False); var centralEuropeanQuoteConventionSet = new QuoteConventionSet([centralEuropeanQuoteConvention]); - Assert.IsTrue(centralEuropeanQuoteConventionSet.IsValidClosingQuotationMark("‘")); - Assert.IsTrue(centralEuropeanQuoteConventionSet.IsValidClosingQuotationMark("“")); - Assert.IsFalse(centralEuropeanQuoteConventionSet.IsValidClosingQuotationMark("„")); - Assert.IsFalse(centralEuropeanQuoteConventionSet.IsValidClosingQuotationMark("‚")); + Assert.That(centralEuropeanQuoteConventionSet.IsValidClosingQuotationMark("‘"), Is.True); + Assert.That(centralEuropeanQuoteConventionSet.IsValidClosingQuotationMark("“"), Is.True); + Assert.That(centralEuropeanQuoteConventionSet.IsValidClosingQuotationMark("„"), Is.False); + Assert.That(centralEuropeanQuoteConventionSet.IsValidClosingQuotationMark("‚"), Is.False); var standardSwedishQuoteConventionSet = new QuoteConventionSet([standardSwedishQuoteConvention]); - Assert.IsTrue(standardSwedishQuoteConventionSet.IsValidClosingQuotationMark("’")); - Assert.IsTrue(standardSwedishQuoteConventionSet.IsValidClosingQuotationMark("”")); + Assert.That(standardSwedishQuoteConventionSet.IsValidClosingQuotationMark("’"), Is.True); + Assert.That(standardSwedishQuoteConventionSet.IsValidClosingQuotationMark("”"), Is.True); var standardFrenchQuoteConventionSet = new QuoteConventionSet([standardFrenchQuoteConvention]); - Assert.IsTrue(standardFrenchQuoteConventionSet.IsValidClosingQuotationMark("»")); - Assert.IsTrue(standardFrenchQuoteConventionSet.IsValidClosingQuotationMark("›")); - Assert.IsFalse(standardFrenchQuoteConventionSet.IsValidClosingQuotationMark("«")); - Assert.IsFalse(standardFrenchQuoteConventionSet.IsValidClosingQuotationMark("‹")); - - var multipleQuoteConventionSet = new QuoteConventionSet( - [ - standardEnglishQuoteConvention, - centralEuropeanQuoteConvention, - standardSwedishQuoteConvention, - standardFrenchQuoteConvention, - ] - ); + Assert.That(standardFrenchQuoteConventionSet.IsValidClosingQuotationMark("»"), Is.True); + Assert.That(standardFrenchQuoteConventionSet.IsValidClosingQuotationMark("›"), Is.True); + Assert.That(standardFrenchQuoteConventionSet.IsValidClosingQuotationMark("«"), Is.False); + Assert.That(standardFrenchQuoteConventionSet.IsValidClosingQuotationMark("‹"), Is.False); + + var multipleQuoteConventionSet = new QuoteConventionSet([ + standardEnglishQuoteConvention, + centralEuropeanQuoteConvention, + standardSwedishQuoteConvention, + standardFrenchQuoteConvention, + ]); Assert.That( multipleQuoteConventionSet.GetPossibleClosingQuotationMarks().SequenceEqual(["‘", "’", "›", "“", "”", "»"]) ); - Assert.IsTrue(multipleQuoteConventionSet.IsValidClosingQuotationMark("‘")); - Assert.IsTrue(multipleQuoteConventionSet.IsValidClosingQuotationMark("’")); - Assert.IsTrue(multipleQuoteConventionSet.IsValidClosingQuotationMark("“")); - Assert.IsTrue(multipleQuoteConventionSet.IsValidClosingQuotationMark("”")); - Assert.IsTrue(multipleQuoteConventionSet.IsValidClosingQuotationMark("»")); - Assert.IsTrue(multipleQuoteConventionSet.IsValidClosingQuotationMark("›")); - Assert.IsFalse(multipleQuoteConventionSet.IsValidClosingQuotationMark("«")); - Assert.IsFalse(multipleQuoteConventionSet.IsValidClosingQuotationMark("‹")); + Assert.That(multipleQuoteConventionSet.IsValidClosingQuotationMark("‘"), Is.True); + Assert.That(multipleQuoteConventionSet.IsValidClosingQuotationMark("’"), Is.True); + Assert.That(multipleQuoteConventionSet.IsValidClosingQuotationMark("“"), Is.True); + Assert.That(multipleQuoteConventionSet.IsValidClosingQuotationMark("”"), Is.True); + Assert.That(multipleQuoteConventionSet.IsValidClosingQuotationMark("»"), Is.True); + Assert.That(multipleQuoteConventionSet.IsValidClosingQuotationMark("›"), Is.True); + Assert.That(multipleQuoteConventionSet.IsValidClosingQuotationMark("«"), Is.False); + Assert.That(multipleQuoteConventionSet.IsValidClosingQuotationMark("‹"), Is.False); } [Test] @@ -674,55 +666,53 @@ public void AreMarksAValidPair() ); var standardEnglishQuoteConventionSet = new QuoteConventionSet([standardEnglishQuoteConvention]); - Assert.IsTrue(standardEnglishQuoteConventionSet.MarksAreAValidPair("“", "”")); - Assert.IsFalse(standardEnglishQuoteConventionSet.MarksAreAValidPair("”", "“")); - Assert.IsTrue(standardEnglishQuoteConventionSet.MarksAreAValidPair("‘", "’")); - Assert.IsFalse(standardEnglishQuoteConventionSet.MarksAreAValidPair("’", "‘")); - Assert.IsFalse(standardEnglishQuoteConventionSet.MarksAreAValidPair("‘", "”")); - Assert.IsFalse(standardEnglishQuoteConventionSet.MarksAreAValidPair("‘", "”")); - Assert.IsFalse(standardEnglishQuoteConventionSet.MarksAreAValidPair("‘", "")); - Assert.IsFalse(standardEnglishQuoteConventionSet.MarksAreAValidPair("", "")); + Assert.That(standardEnglishQuoteConventionSet.MarksAreAValidPair("“", "”"), Is.True); + Assert.That(standardEnglishQuoteConventionSet.MarksAreAValidPair("”", "“"), Is.False); + Assert.That(standardEnglishQuoteConventionSet.MarksAreAValidPair("‘", "’"), Is.True); + Assert.That(standardEnglishQuoteConventionSet.MarksAreAValidPair("’", "‘"), Is.False); + Assert.That(standardEnglishQuoteConventionSet.MarksAreAValidPair("‘", "”"), Is.False); + Assert.That(standardEnglishQuoteConventionSet.MarksAreAValidPair("‘", "”"), Is.False); + Assert.That(standardEnglishQuoteConventionSet.MarksAreAValidPair("‘", ""), Is.False); + Assert.That(standardEnglishQuoteConventionSet.MarksAreAValidPair("", ""), Is.False); var centralEuropeanQuoteConventionSet = new QuoteConventionSet([centralEuropeanQuoteConvention]); - Assert.IsTrue(centralEuropeanQuoteConventionSet.MarksAreAValidPair("„", "“")); - Assert.IsTrue(centralEuropeanQuoteConventionSet.MarksAreAValidPair("‚", "‘")); - Assert.IsFalse(centralEuropeanQuoteConventionSet.MarksAreAValidPair("“", "„")); - Assert.IsFalse(centralEuropeanQuoteConventionSet.MarksAreAValidPair("’", "‚")); - Assert.IsFalse(centralEuropeanQuoteConventionSet.MarksAreAValidPair("‚", "“")); - Assert.IsFalse(centralEuropeanQuoteConventionSet.MarksAreAValidPair("‚", "’")); + Assert.That(centralEuropeanQuoteConventionSet.MarksAreAValidPair("„", "“"), Is.True); + Assert.That(centralEuropeanQuoteConventionSet.MarksAreAValidPair("‚", "‘"), Is.True); + Assert.That(centralEuropeanQuoteConventionSet.MarksAreAValidPair("“", "„"), Is.False); + Assert.That(centralEuropeanQuoteConventionSet.MarksAreAValidPair("’", "‚"), Is.False); + Assert.That(centralEuropeanQuoteConventionSet.MarksAreAValidPair("‚", "“"), Is.False); + Assert.That(centralEuropeanQuoteConventionSet.MarksAreAValidPair("‚", "’"), Is.False); var standardSwedishQuoteConventionSet = new QuoteConventionSet([standardSwedishQuoteConvention]); - Assert.IsTrue(standardSwedishQuoteConventionSet.MarksAreAValidPair("”", "”")); - Assert.IsTrue(standardSwedishQuoteConventionSet.MarksAreAValidPair("’", "’")); - Assert.IsFalse(standardSwedishQuoteConventionSet.MarksAreAValidPair("”", "’")); - Assert.IsFalse(standardSwedishQuoteConventionSet.MarksAreAValidPair("’", "”")); + Assert.That(standardSwedishQuoteConventionSet.MarksAreAValidPair("”", "”"), Is.True); + Assert.That(standardSwedishQuoteConventionSet.MarksAreAValidPair("’", "’"), Is.True); + Assert.That(standardSwedishQuoteConventionSet.MarksAreAValidPair("”", "’"), Is.False); + Assert.That(standardSwedishQuoteConventionSet.MarksAreAValidPair("’", "”"), Is.False); var standardFrenchQuoteConventionSet = new QuoteConventionSet([standardFrenchQuoteConvention]); - Assert.IsTrue(standardFrenchQuoteConventionSet.MarksAreAValidPair("«", "»")); - Assert.IsTrue(standardFrenchQuoteConventionSet.MarksAreAValidPair("‹", "›")); - Assert.IsFalse(standardFrenchQuoteConventionSet.MarksAreAValidPair("«", "›")); - Assert.IsFalse(standardFrenchQuoteConventionSet.MarksAreAValidPair("‹", "»")); - - var multipleQuoteConventionSet = new QuoteConventionSet( - [ - standardEnglishQuoteConvention, - centralEuropeanQuoteConvention, - standardSwedishQuoteConvention, - standardFrenchQuoteConvention, - ] - ); - Assert.IsTrue(multipleQuoteConventionSet.MarksAreAValidPair("“", "”")); - Assert.IsTrue(multipleQuoteConventionSet.MarksAreAValidPair("‘", "’")); - Assert.IsTrue(multipleQuoteConventionSet.MarksAreAValidPair("„", "“")); - Assert.IsTrue(multipleQuoteConventionSet.MarksAreAValidPair("‚", "‘")); - Assert.IsTrue(multipleQuoteConventionSet.MarksAreAValidPair("”", "”")); - Assert.IsTrue(multipleQuoteConventionSet.MarksAreAValidPair("’", "’")); - Assert.IsTrue(multipleQuoteConventionSet.MarksAreAValidPair("«", "»")); - Assert.IsTrue(multipleQuoteConventionSet.MarksAreAValidPair("‹", "›")); - Assert.IsFalse(multipleQuoteConventionSet.MarksAreAValidPair("‹", "»")); - Assert.IsFalse(multipleQuoteConventionSet.MarksAreAValidPair("‹", "”")); - Assert.IsFalse(multipleQuoteConventionSet.MarksAreAValidPair("„", "”")); - Assert.IsFalse(multipleQuoteConventionSet.MarksAreAValidPair("’", "‘")); + Assert.That(standardFrenchQuoteConventionSet.MarksAreAValidPair("«", "»"), Is.True); + Assert.That(standardFrenchQuoteConventionSet.MarksAreAValidPair("‹", "›"), Is.True); + Assert.That(standardFrenchQuoteConventionSet.MarksAreAValidPair("«", "›"), Is.False); + Assert.That(standardFrenchQuoteConventionSet.MarksAreAValidPair("‹", "»"), Is.False); + + var multipleQuoteConventionSet = new QuoteConventionSet([ + standardEnglishQuoteConvention, + centralEuropeanQuoteConvention, + standardSwedishQuoteConvention, + standardFrenchQuoteConvention, + ]); + Assert.That(multipleQuoteConventionSet.MarksAreAValidPair("“", "”"), Is.True); + Assert.That(multipleQuoteConventionSet.MarksAreAValidPair("‘", "’"), Is.True); + Assert.That(multipleQuoteConventionSet.MarksAreAValidPair("„", "“"), Is.True); + Assert.That(multipleQuoteConventionSet.MarksAreAValidPair("‚", "‘"), Is.True); + Assert.That(multipleQuoteConventionSet.MarksAreAValidPair("”", "”"), Is.True); + Assert.That(multipleQuoteConventionSet.MarksAreAValidPair("’", "’"), Is.True); + Assert.That(multipleQuoteConventionSet.MarksAreAValidPair("«", "»"), Is.True); + Assert.That(multipleQuoteConventionSet.MarksAreAValidPair("‹", "›"), Is.True); + Assert.That(multipleQuoteConventionSet.MarksAreAValidPair("‹", "»"), Is.False); + Assert.That(multipleQuoteConventionSet.MarksAreAValidPair("‹", "”"), Is.False); + Assert.That(multipleQuoteConventionSet.MarksAreAValidPair("„", "”"), Is.False); + Assert.That(multipleQuoteConventionSet.MarksAreAValidPair("’", "‘"), Is.False); } [Test] @@ -779,54 +769,52 @@ public void IsQuotationMarkDirectionAmbiguous() ); var standardEnglishQuoteConventionSet = new QuoteConventionSet([standardEnglishQuoteConvention]); - Assert.IsFalse(standardEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("“")); - Assert.IsFalse(standardEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("”")); - Assert.IsFalse(standardEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("‘")); - Assert.IsFalse(standardEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("’")); - Assert.IsFalse(standardEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("\"")); + Assert.That(standardEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("“"), Is.False); + Assert.That(standardEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("”"), Is.False); + Assert.That(standardEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("‘"), Is.False); + Assert.That(standardEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("’"), Is.False); + Assert.That(standardEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("\""), Is.False); var typewriterEnglishQuoteConventionSet = new QuoteConventionSet([typewriterEnglishQuoteConvention]); - Assert.IsTrue(typewriterEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("\"")); - Assert.IsTrue(typewriterEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("'")); - Assert.IsFalse(typewriterEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("‘")); - Assert.IsFalse(typewriterEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("’")); - Assert.IsFalse(typewriterEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("«")); + Assert.That(typewriterEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("\""), Is.True); + Assert.That(typewriterEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("'"), Is.True); + Assert.That(typewriterEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("‘"), Is.False); + Assert.That(typewriterEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("’"), Is.False); + Assert.That(typewriterEnglishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("«"), Is.False); var centralEuropeanQuoteConventionSet = new QuoteConventionSet([centralEuropeanQuoteConvention]); - Assert.IsFalse(centralEuropeanQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("“")); - Assert.IsFalse(centralEuropeanQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("„")); - Assert.IsFalse(centralEuropeanQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("‘")); - Assert.IsFalse(centralEuropeanQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("‚")); + Assert.That(centralEuropeanQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("“"), Is.False); + Assert.That(centralEuropeanQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("„"), Is.False); + Assert.That(centralEuropeanQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("‘"), Is.False); + Assert.That(centralEuropeanQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("‚"), Is.False); var standardSwedishQuoteConventionSet = new QuoteConventionSet([standardSwedishQuoteConvention]); - Assert.IsTrue(standardSwedishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("”")); - Assert.IsTrue(standardSwedishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("’")); + Assert.That(standardSwedishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("”"), Is.True); + Assert.That(standardSwedishQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("’"), Is.True); var easternEuropeanQuoteConventionSet = new QuoteConventionSet([easternEuropeanQuoteConvention]); - Assert.IsFalse(easternEuropeanQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("”")); - Assert.IsFalse(easternEuropeanQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("„")); - Assert.IsFalse(easternEuropeanQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("’")); - Assert.IsFalse(easternEuropeanQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("‚")); - - var multipleQuoteConventionSet = new QuoteConventionSet( - [ - standardEnglishQuoteConvention, - typewriterEnglishQuoteConvention, - centralEuropeanQuoteConvention, - standardSwedishQuoteConvention, - easternEuropeanQuoteConvention, - ] - ); - Assert.IsTrue(multipleQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("\"")); - Assert.IsTrue(multipleQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("'")); - Assert.IsTrue(multipleQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("”")); - Assert.IsTrue(multipleQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("’")); - Assert.IsFalse(multipleQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("„")); - Assert.IsFalse(multipleQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("‚")); + Assert.That(easternEuropeanQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("”"), Is.False); + Assert.That(easternEuropeanQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("„"), Is.False); + Assert.That(easternEuropeanQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("’"), Is.False); + Assert.That(easternEuropeanQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("‚"), Is.False); + + var multipleQuoteConventionSet = new QuoteConventionSet([ + standardEnglishQuoteConvention, + typewriterEnglishQuoteConvention, + centralEuropeanQuoteConvention, + standardSwedishQuoteConvention, + easternEuropeanQuoteConvention, + ]); + Assert.That(multipleQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("\""), Is.True); + Assert.That(multipleQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("'"), Is.True); + Assert.That(multipleQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("”"), Is.True); + Assert.That(multipleQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("’"), Is.True); + Assert.That(multipleQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("„"), Is.False); + Assert.That(multipleQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("‚"), Is.False); // these are unambiguous because they are never the opening and closing in the same convention - Assert.IsFalse(multipleQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("“")); - Assert.IsFalse(multipleQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("‘")); + Assert.That(multipleQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("“"), Is.False); + Assert.That(multipleQuoteConventionSet.IsQuotationMarkDirectionAmbiguous("‘"), Is.False); } [Test] @@ -894,14 +882,12 @@ public void GetPossiblePairedQuotationMarks() Assert.That(easternEuropeanQuoteConventionSet.GetPossiblePairedQuotationMarks("‚").SequenceEqual(["’"])); Assert.That(easternEuropeanQuoteConventionSet.GetPossiblePairedQuotationMarks("’").SequenceEqual(["‚"])); - var multipleQuoteConventionSet = new QuoteConventionSet( - [ - standardEnglishQuoteConvention, - centralEuropeanQuoteConvention, - standardSwedishQuoteConvention, - easternEuropeanQuoteConvention, - ] - ); + var multipleQuoteConventionSet = new QuoteConventionSet([ + standardEnglishQuoteConvention, + centralEuropeanQuoteConvention, + standardSwedishQuoteConvention, + easternEuropeanQuoteConvention, + ]); Assert.That(multipleQuoteConventionSet.GetPossiblePairedQuotationMarks("“").SequenceEqual(["”", "„"])); Assert.That(multipleQuoteConventionSet.GetPossiblePairedQuotationMarks("”").SequenceEqual(["”", "“", "„"])); Assert.That(multipleQuoteConventionSet.GetPossiblePairedQuotationMarks("‘").SequenceEqual(["’", "‚"])); @@ -1050,9 +1036,9 @@ public void GetPossibleDepths() Has.Count.EqualTo(0) ); - var normalizedWesternEuropeanQuoteConventionSet = new QuoteConventionSet( - [normalizedWesternEuropeanQuoteConvention] - ); + var normalizedWesternEuropeanQuoteConventionSet = new QuoteConventionSet([ + normalizedWesternEuropeanQuoteConvention, + ]); Assert.That( normalizedWesternEuropeanQuoteConventionSet .GetPossibleDepths("\"", QuotationMarkDirection.Opening) @@ -1082,9 +1068,11 @@ public void GetPossibleDepths() Has.Count.EqualTo(0) ); - var multipleQuoteConventionSet = new QuoteConventionSet( - [standardEnglishQuoteConvention, britishEnglishQuoteConvention, normalizedWesternEuropeanQuoteConvention,] - ); + var multipleQuoteConventionSet = new QuoteConventionSet([ + standardEnglishQuoteConvention, + britishEnglishQuoteConvention, + normalizedWesternEuropeanQuoteConvention, + ]); Assert.That( multipleQuoteConventionSet .GetPossibleDepths("\u201c", QuotationMarkDirection.Opening) @@ -1161,125 +1149,165 @@ public void DoesMetadataMatchQuotationMark() ); var standardEnglishQuoteConventionSet = new QuoteConventionSet([standardEnglishQuoteConvention]); - Assert.IsTrue( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201c", 1, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201c", 1, QuotationMarkDirection.Opening), + Is.True ); - Assert.IsTrue( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201c", 3, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201c", 3, QuotationMarkDirection.Opening), + Is.True ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201c", 2, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201c", 2, QuotationMarkDirection.Opening), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201c", 4, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201c", 4, QuotationMarkDirection.Opening), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201c", 1, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201c", 1, QuotationMarkDirection.Closing), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201c", 2, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201c", 2, QuotationMarkDirection.Closing), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201c", 3, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201c", 3, QuotationMarkDirection.Closing), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201c", 4, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201c", 4, QuotationMarkDirection.Closing), + Is.False ); - Assert.IsTrue( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201d", 1, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201d", 1, QuotationMarkDirection.Closing), + Is.True ); - Assert.IsTrue( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201d", 3, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201d", 3, QuotationMarkDirection.Closing), + Is.True ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201d", 2, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201d", 2, QuotationMarkDirection.Closing), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201d", 4, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201d", 4, QuotationMarkDirection.Closing), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201d", 1, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201d", 1, QuotationMarkDirection.Opening), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201d", 2, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201d", 2, QuotationMarkDirection.Opening), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201d", 3, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201d", 3, QuotationMarkDirection.Opening), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201d", 4, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201d", 4, QuotationMarkDirection.Opening), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2018", 1, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2018", 1, QuotationMarkDirection.Opening), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2018", 3, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2018", 3, QuotationMarkDirection.Opening), + Is.False ); - Assert.IsTrue( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2018", 2, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2018", 2, QuotationMarkDirection.Opening), + Is.True ); - Assert.IsTrue( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2018", 4, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2018", 4, QuotationMarkDirection.Opening), + Is.True ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2018", 1, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2018", 1, QuotationMarkDirection.Closing), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2018", 2, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2018", 2, QuotationMarkDirection.Closing), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2018", 3, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2018", 3, QuotationMarkDirection.Closing), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2018", 4, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2018", 4, QuotationMarkDirection.Closing), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2019", 1, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2019", 1, QuotationMarkDirection.Closing), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2019", 3, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2019", 3, QuotationMarkDirection.Closing), + Is.False ); - Assert.IsTrue( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2019", 2, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2019", 2, QuotationMarkDirection.Closing), + Is.True ); - Assert.IsTrue( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2019", 4, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2019", 4, QuotationMarkDirection.Closing), + Is.True ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2019", 1, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2019", 1, QuotationMarkDirection.Opening), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2019", 2, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2019", 2, QuotationMarkDirection.Opening), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2019", 3, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2019", 3, QuotationMarkDirection.Opening), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2019", 4, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u2019", 4, QuotationMarkDirection.Opening), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201e", 1, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201e", 1, QuotationMarkDirection.Opening), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201e", 1, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201e", 1, QuotationMarkDirection.Closing), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201e", 2, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201e", 2, QuotationMarkDirection.Opening), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201e", 2, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201e", 2, QuotationMarkDirection.Closing), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201e", 3, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201e", 3, QuotationMarkDirection.Opening), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201e", 3, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201e", 3, QuotationMarkDirection.Closing), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201e", 4, QuotationMarkDirection.Opening) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201e", 4, QuotationMarkDirection.Opening), + Is.False ); - Assert.IsFalse( - standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201e", 4, QuotationMarkDirection.Closing) + Assert.That( + standardEnglishQuoteConventionSet.MetadataMatchesQuotationMark("\u201e", 4, QuotationMarkDirection.Closing), + Is.False ); } @@ -1385,14 +1413,12 @@ public void FilterToCompatibleQuoteConventions() Has.Count.EqualTo(0) ); - var multipleQuoteConventionSet = new QuoteConventionSet( - [ - standardEnglishQuoteConvention, - standardFrenchQuoteConvention, - westernEuropeanQuoteConvention, - standardSwedishQuoteConvention, - ] - ); + var multipleQuoteConventionSet = new QuoteConventionSet([ + standardEnglishQuoteConvention, + standardFrenchQuoteConvention, + westernEuropeanQuoteConvention, + standardSwedishQuoteConvention, + ]); Assert.That( multipleQuoteConventionSet .FilterToCompatibleQuoteConventions(["\u201c"], ["\u201d"]) @@ -1473,182 +1499,179 @@ public void FindMostSimilarConvention() ] ); - var allThreeQuoteConventionSet = new QuoteConventionSet( - [standardEnglishQuoteConvention, standardFrenchQuoteConvention, westernEuropeanQuoteConvention,] - ); - var twoFrenchQuoteConventionSet = new QuoteConventionSet( - [westernEuropeanQuoteConvention, standardFrenchQuoteConvention] - ); + var allThreeQuoteConventionSet = new QuoteConventionSet([ + standardEnglishQuoteConvention, + standardFrenchQuoteConvention, + westernEuropeanQuoteConvention, + ]); + var twoFrenchQuoteConventionSet = new QuoteConventionSet([ + westernEuropeanQuoteConvention, + standardFrenchQuoteConvention, + ]); var multipleEnglishQuotesTabulator = new QuotationMarkTabulator(); - multipleEnglishQuotesTabulator.Tabulate( - [ - new QuotationMarkMetadata( - "\u201c", - 1, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 0, - 1 - ), - new QuotationMarkMetadata( - "\u2018", - 2, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 5, - 6 - ), - new QuotationMarkMetadata( - "\u2019", - 2, - QuotationMarkDirection.Closing, - new TextSegment.Builder().Build(), - 13, - 14 - ), - new QuotationMarkMetadata( - "\u201d", - 1, - QuotationMarkDirection.Closing, - new TextSegment.Builder().Build(), - 14, - 15 - ), - new QuotationMarkMetadata( - "\u201c", - 1, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 28, - 29 - ), - new QuotationMarkMetadata( - "\u201d", - 1, - QuotationMarkDirection.Closing, - new TextSegment.Builder().Build(), - 42, - 43 - ), - ] - ); + multipleEnglishQuotesTabulator.Tabulate([ + new QuotationMarkMetadata( + "\u201c", + 1, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 0, + 1 + ), + new QuotationMarkMetadata( + "\u2018", + 2, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 5, + 6 + ), + new QuotationMarkMetadata( + "\u2019", + 2, + QuotationMarkDirection.Closing, + new TextSegment.Builder().Build(), + 13, + 14 + ), + new QuotationMarkMetadata( + "\u201d", + 1, + QuotationMarkDirection.Closing, + new TextSegment.Builder().Build(), + 14, + 15 + ), + new QuotationMarkMetadata( + "\u201c", + 1, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 28, + 29 + ), + new QuotationMarkMetadata( + "\u201d", + 1, + QuotationMarkDirection.Closing, + new TextSegment.Builder().Build(), + 42, + 43 + ), + ]); Assert.That( allThreeQuoteConventionSet.FindMostSimilarConvention(multipleEnglishQuotesTabulator), Is.EqualTo((standardEnglishQuoteConvention, 1.0)) ); var multipleWesternEuropeanQuotesTabulator = new QuotationMarkTabulator(); - multipleWesternEuropeanQuotesTabulator.Tabulate( - [ - new QuotationMarkMetadata( - "\u00ab", - 1, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 0, - 1 - ), - new QuotationMarkMetadata( - "\u201c", - 2, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 5, - 6 - ), - new QuotationMarkMetadata( - "\u201d", - 2, - QuotationMarkDirection.Closing, - new TextSegment.Builder().Build(), - 13, - 14 - ), - new QuotationMarkMetadata( - "\u00bb", - 1, - QuotationMarkDirection.Closing, - new TextSegment.Builder().Build(), - 14, - 15 - ), - new QuotationMarkMetadata( - "\u00ab", - 1, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 28, - 29 - ), - new QuotationMarkMetadata( - "\u00bb", - 1, - QuotationMarkDirection.Closing, - new TextSegment.Builder().Build(), - 42, - 43 - ), - ] - ); + multipleWesternEuropeanQuotesTabulator.Tabulate([ + new QuotationMarkMetadata( + "\u00ab", + 1, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 0, + 1 + ), + new QuotationMarkMetadata( + "\u201c", + 2, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 5, + 6 + ), + new QuotationMarkMetadata( + "\u201d", + 2, + QuotationMarkDirection.Closing, + new TextSegment.Builder().Build(), + 13, + 14 + ), + new QuotationMarkMetadata( + "\u00bb", + 1, + QuotationMarkDirection.Closing, + new TextSegment.Builder().Build(), + 14, + 15 + ), + new QuotationMarkMetadata( + "\u00ab", + 1, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 28, + 29 + ), + new QuotationMarkMetadata( + "\u00bb", + 1, + QuotationMarkDirection.Closing, + new TextSegment.Builder().Build(), + 42, + 43 + ), + ]); Assert.That( allThreeQuoteConventionSet.FindMostSimilarConvention(multipleWesternEuropeanQuotesTabulator), Is.EqualTo((westernEuropeanQuoteConvention, 1.0)) ); var multipleFrenchQuotesTabulator = new QuotationMarkTabulator(); - multipleFrenchQuotesTabulator.Tabulate( - [ - new QuotationMarkMetadata( - "\u00ab", - 1, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 0, - 1 - ), - new QuotationMarkMetadata( - "\u2039", - 2, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 5, - 6 - ), - new QuotationMarkMetadata( - "\u203a", - 2, - QuotationMarkDirection.Closing, - new TextSegment.Builder().Build(), - 13, - 14 - ), - new QuotationMarkMetadata( - "\u00bb", - 1, - QuotationMarkDirection.Closing, - new TextSegment.Builder().Build(), - 14, - 15 - ), - new QuotationMarkMetadata( - "\u00ab", - 1, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 28, - 29 - ), - new QuotationMarkMetadata( - "\u00bb", - 1, - QuotationMarkDirection.Closing, - new TextSegment.Builder().Build(), - 42, - 43 - ), - ] - ); + multipleFrenchQuotesTabulator.Tabulate([ + new QuotationMarkMetadata( + "\u00ab", + 1, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 0, + 1 + ), + new QuotationMarkMetadata( + "\u2039", + 2, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 5, + 6 + ), + new QuotationMarkMetadata( + "\u203a", + 2, + QuotationMarkDirection.Closing, + new TextSegment.Builder().Build(), + 13, + 14 + ), + new QuotationMarkMetadata( + "\u00bb", + 1, + QuotationMarkDirection.Closing, + new TextSegment.Builder().Build(), + 14, + 15 + ), + new QuotationMarkMetadata( + "\u00ab", + 1, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 28, + 29 + ), + new QuotationMarkMetadata( + "\u00bb", + 1, + QuotationMarkDirection.Closing, + new TextSegment.Builder().Build(), + 42, + 43 + ), + ]); Assert.That( allThreeQuoteConventionSet.FindMostSimilarConvention(multipleFrenchQuotesTabulator), Is.EqualTo((standardFrenchQuoteConvention, 1.0)) @@ -1659,58 +1682,56 @@ public void FindMostSimilarConvention() ); var noisyMultipleEnglishQuotesTabulator = new QuotationMarkTabulator(); - noisyMultipleEnglishQuotesTabulator.Tabulate( - [ - new QuotationMarkMetadata( - "\u201c", - 1, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 0, - 1 - ), - new QuotationMarkMetadata( - "\u201c", - 2, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 5, - 6 - ), - new QuotationMarkMetadata( - "\u2019", - 2, - QuotationMarkDirection.Closing, - new TextSegment.Builder().Build(), - 13, - 14 - ), - new QuotationMarkMetadata( - "\u201d", - 1, - QuotationMarkDirection.Closing, - new TextSegment.Builder().Build(), - 14, - 15 - ), - new QuotationMarkMetadata( - "\u201c", - 1, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 28, - 29 - ), - new QuotationMarkMetadata( - "\u201d", - 1, - QuotationMarkDirection.Closing, - new TextSegment.Builder().Build(), - 42, - 43 - ), - ] - ); + noisyMultipleEnglishQuotesTabulator.Tabulate([ + new QuotationMarkMetadata( + "\u201c", + 1, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 0, + 1 + ), + new QuotationMarkMetadata( + "\u201c", + 2, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 5, + 6 + ), + new QuotationMarkMetadata( + "\u2019", + 2, + QuotationMarkDirection.Closing, + new TextSegment.Builder().Build(), + 13, + 14 + ), + new QuotationMarkMetadata( + "\u201d", + 1, + QuotationMarkDirection.Closing, + new TextSegment.Builder().Build(), + 14, + 15 + ), + new QuotationMarkMetadata( + "\u201c", + 1, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 28, + 29 + ), + new QuotationMarkMetadata( + "\u201d", + 1, + QuotationMarkDirection.Closing, + new TextSegment.Builder().Build(), + 42, + 43 + ), + ]); (QuoteConvention convention, double similarity) = allThreeQuoteConventionSet.FindMostSimilarConvention( noisyMultipleEnglishQuotesTabulator ); @@ -1723,74 +1744,72 @@ public void FindMostSimilarConvention() Assert.That(similarity, Is.EqualTo(0)); var noisyMultipleFrenchQuotesTabulator = new QuotationMarkTabulator(); - noisyMultipleFrenchQuotesTabulator.Tabulate( - [ - new QuotationMarkMetadata( - "\u00ab", - 1, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 0, - 1 - ), - new QuotationMarkMetadata( - "\u2039", - 2, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 5, - 6 - ), - new QuotationMarkMetadata( - "\u203a", - 2, - QuotationMarkDirection.Closing, - new TextSegment.Builder().Build(), - 13, - 14 - ), - new QuotationMarkMetadata( - "\u2039", - 2, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 5, - 6 - ), - new QuotationMarkMetadata( - "\u2019", - 2, - QuotationMarkDirection.Closing, - new TextSegment.Builder().Build(), - 13, - 14 - ), - new QuotationMarkMetadata( - "\u00bb", - 1, - QuotationMarkDirection.Closing, - new TextSegment.Builder().Build(), - 14, - 15 - ), - new QuotationMarkMetadata( - "\u00ab", - 1, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 28, - 29 - ), - new QuotationMarkMetadata( - "\u00bb", - 1, - QuotationMarkDirection.Closing, - new TextSegment.Builder().Build(), - 42, - 43 - ), - ] - ); + noisyMultipleFrenchQuotesTabulator.Tabulate([ + new QuotationMarkMetadata( + "\u00ab", + 1, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 0, + 1 + ), + new QuotationMarkMetadata( + "\u2039", + 2, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 5, + 6 + ), + new QuotationMarkMetadata( + "\u203a", + 2, + QuotationMarkDirection.Closing, + new TextSegment.Builder().Build(), + 13, + 14 + ), + new QuotationMarkMetadata( + "\u2039", + 2, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 5, + 6 + ), + new QuotationMarkMetadata( + "\u2019", + 2, + QuotationMarkDirection.Closing, + new TextSegment.Builder().Build(), + 13, + 14 + ), + new QuotationMarkMetadata( + "\u00bb", + 1, + QuotationMarkDirection.Closing, + new TextSegment.Builder().Build(), + 14, + 15 + ), + new QuotationMarkMetadata( + "\u00ab", + 1, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 28, + 29 + ), + new QuotationMarkMetadata( + "\u00bb", + 1, + QuotationMarkDirection.Closing, + new TextSegment.Builder().Build(), + 42, + 43 + ), + ]); (convention, similarity) = allThreeQuoteConventionSet.FindMostSimilarConvention( noisyMultipleFrenchQuotesTabulator ); @@ -1798,86 +1817,80 @@ public void FindMostSimilarConvention() Assert.That(similarity, Is.EqualTo(0.875).Within(1e-9)); var tooDeepEnglishQuotesTabulator = new QuotationMarkTabulator(); - tooDeepEnglishQuotesTabulator.Tabulate( - [ - new QuotationMarkMetadata( - "\u201c", - 1, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 0, - 1 - ), - new QuotationMarkMetadata( - "\u2018", - 2, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 5, - 6 - ), - new QuotationMarkMetadata( - "\u201c", - 3, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 13, - 14 - ), - new QuotationMarkMetadata( - "\u2018", - 4, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 15, - 16 - ), - new QuotationMarkMetadata( - "\u201c", - 5, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 17, - 18 - ), - ] - ); + tooDeepEnglishQuotesTabulator.Tabulate([ + new QuotationMarkMetadata( + "\u201c", + 1, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 0, + 1 + ), + new QuotationMarkMetadata( + "\u2018", + 2, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 5, + 6 + ), + new QuotationMarkMetadata( + "\u201c", + 3, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 13, + 14 + ), + new QuotationMarkMetadata( + "\u2018", + 4, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 15, + 16 + ), + new QuotationMarkMetadata( + "\u201c", + 5, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 17, + 18 + ), + ]); (convention, similarity) = allThreeQuoteConventionSet.FindMostSimilarConvention(tooDeepEnglishQuotesTabulator); Assert.That(convention, Is.EqualTo(standardEnglishQuoteConvention)); Assert.That(similarity, Is.EqualTo(0.8).Within(1e-9)); // in case of ties, the earlier convention in the list should be returned var unknownQuoteTabulator = new QuotationMarkTabulator(); - unknownQuoteTabulator.Tabulate( - [ - new QuotationMarkMetadata( - "\u201a", - 1, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 0, - 1 - ) - ] - ); + unknownQuoteTabulator.Tabulate([ + new QuotationMarkMetadata( + "\u201a", + 1, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 0, + 1 + ), + ]); Assert.That( allThreeQuoteConventionSet.FindMostSimilarConvention(unknownQuoteTabulator), Is.EqualTo((standardEnglishQuoteConvention, 0.0)) ); var singleFrenchOpeningQuoteTabulator = new QuotationMarkTabulator(); - singleFrenchOpeningQuoteTabulator.Tabulate( - [ - new QuotationMarkMetadata( - "\u00ab", - 1, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 0, - 1 - ) - ] - ); + singleFrenchOpeningQuoteTabulator.Tabulate([ + new QuotationMarkMetadata( + "\u00ab", + 1, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 0, + 1 + ), + ]); Assert.That( allThreeQuoteConventionSet.FindMostSimilarConvention(singleFrenchOpeningQuoteTabulator), Is.EqualTo((standardFrenchQuoteConvention, 1.0)) @@ -1889,18 +1902,16 @@ public void FindMostSimilarConvention() // Default values should be returned when the QuoteConventionSet is empty var singleEnglishOpeningQuoteTabulator = new QuotationMarkTabulator(); - singleEnglishOpeningQuoteTabulator.Tabulate( - [ - new QuotationMarkMetadata( - "\u201c", - 1, - QuotationMarkDirection.Opening, - new TextSegment.Builder().Build(), - 0, - 1 - ) - ] - ); + singleEnglishOpeningQuoteTabulator.Tabulate([ + new QuotationMarkMetadata( + "\u201c", + 1, + QuotationMarkDirection.Opening, + new TextSegment.Builder().Build(), + 0, + 1 + ), + ]); var emptyQuoteConventionSet = new QuoteConventionSet([]); Assert.That( emptyQuoteConventionSet.FindMostSimilarConvention(singleEnglishOpeningQuoteTabulator), diff --git a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuoteConventionTests.cs b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuoteConventionTests.cs index 0275abfa7..e9d622c44 100644 --- a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuoteConventionTests.cs +++ b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuoteConventionTests.cs @@ -110,7 +110,7 @@ [new SingleLevelQuoteConvention("\u201c", "\u201d")] var twoLevelQuoteConvention = new QuoteConvention( "two_level_quote_convention", - [new SingleLevelQuoteConvention("\u201c", "\u201d"), new SingleLevelQuoteConvention("\u2018", "\u2019"),] + [new SingleLevelQuoteConvention("\u201c", "\u201d"), new SingleLevelQuoteConvention("\u2018", "\u2019")] ); Assert.That(twoLevelQuoteConvention.NumLevels, Is.EqualTo(2)); @@ -184,37 +184,37 @@ public void GetExpectedQuotationMark() public void IncludesOpeningQuotationMark() { var emptyQuoteConvention = new QuoteConvention("empty quote convention", []); - Assert.IsFalse(emptyQuoteConvention.IncludesOpeningQuotationMark("\u201c")); + Assert.That(emptyQuoteConvention.IncludesOpeningQuotationMark("\u201c"), Is.False); var positiveQuoteConvention1 = new QuoteConvention( "positive quote convention 1", [new SingleLevelQuoteConvention("\u201c", "\u201d")] ); - Assert.IsTrue(positiveQuoteConvention1.IncludesOpeningQuotationMark("\u201c")); + Assert.That(positiveQuoteConvention1.IncludesOpeningQuotationMark("\u201c"), Is.True); var negativeQuoteConvention1 = new QuoteConvention( "negative quote convention 1", [new SingleLevelQuoteConvention("\u2018", "\u2019")] ); - Assert.IsFalse(negativeQuoteConvention1.IncludesOpeningQuotationMark("\u201c")); + Assert.That(negativeQuoteConvention1.IncludesOpeningQuotationMark("\u201c"), Is.False); var negativeQuoteConvention2 = new QuoteConvention( "negative quote convention 2", [new SingleLevelQuoteConvention("\u201d", "\u201c")] ); - Assert.IsFalse(negativeQuoteConvention2.IncludesOpeningQuotationMark("\u201c")); + Assert.That(negativeQuoteConvention2.IncludesOpeningQuotationMark("\u201c"), Is.False); var positiveQuoteConvention2 = new QuoteConvention( "positive quote convention 2", [new SingleLevelQuoteConvention("\u201c", "\u201d"), new SingleLevelQuoteConvention("\u2018", "\u2019")] ); - Assert.IsTrue(positiveQuoteConvention2.IncludesOpeningQuotationMark("\u201c")); + Assert.That(positiveQuoteConvention2.IncludesOpeningQuotationMark("\u201c"), Is.True); var positiveQuoteConvention3 = new QuoteConvention( "positive quote convention 3", [new SingleLevelQuoteConvention("\u2018", "\u2019"), new SingleLevelQuoteConvention("\u201c", "\u201d")] ); - Assert.IsTrue(positiveQuoteConvention3.IncludesOpeningQuotationMark("\u201c")); + Assert.That(positiveQuoteConvention3.IncludesOpeningQuotationMark("\u201c"), Is.True); var negativeQuoteConvention3 = new QuoteConvention( "negative quote convention 3", @@ -224,44 +224,44 @@ [new SingleLevelQuoteConvention("\u201d", "\u201c")] new SingleLevelQuoteConvention("\u00ab", "\u00bb"), ] ); - Assert.IsFalse(negativeQuoteConvention3.IncludesOpeningQuotationMark("\u201c")); + Assert.That(negativeQuoteConvention3.IncludesOpeningQuotationMark("\u201c"), Is.False); } [Test] public void IncludesClosingQuotationMark() { var emptyQuoteConvention = new QuoteConvention("empty quote convention", []); - Assert.IsFalse(emptyQuoteConvention.IncludesClosingQuotationMark("\u201d")); + Assert.That(emptyQuoteConvention.IncludesClosingQuotationMark("\u201d"), Is.False); var positiveQuoteConvention1 = new QuoteConvention( "positive quote convention 1", [new SingleLevelQuoteConvention("\u201c", "\u201d")] ); - Assert.IsTrue(positiveQuoteConvention1.IncludesClosingQuotationMark("\u201d")); + Assert.That(positiveQuoteConvention1.IncludesClosingQuotationMark("\u201d"), Is.True); var negativeQuoteConvention1 = new QuoteConvention( "negative quote convention 1", [new SingleLevelQuoteConvention("\u2018", "\u2019")] ); - Assert.IsFalse(negativeQuoteConvention1.IncludesClosingQuotationMark("\u201d")); + Assert.That(negativeQuoteConvention1.IncludesClosingQuotationMark("\u201d"), Is.False); var negativeQuoteConvention2 = new QuoteConvention( "negative quote convention 2", [new SingleLevelQuoteConvention("\u201d", "\u201c")] ); - Assert.IsFalse(negativeQuoteConvention2.IncludesClosingQuotationMark("\u201d")); + Assert.That(negativeQuoteConvention2.IncludesClosingQuotationMark("\u201d"), Is.False); var positiveQuoteConvention2 = new QuoteConvention( "positive quote convention 2", [new SingleLevelQuoteConvention("\u201c", "\u201d"), new SingleLevelQuoteConvention("\u2018", "\u2019")] ); - Assert.IsTrue(positiveQuoteConvention2.IncludesClosingQuotationMark("\u201d")); + Assert.That(positiveQuoteConvention2.IncludesClosingQuotationMark("\u201d"), Is.True); var positiveQuoteConvention3 = new QuoteConvention( "positive quote convention 3", [new SingleLevelQuoteConvention("\u2018", "\u2019"), new SingleLevelQuoteConvention("\u201c", "\u201d")] ); - Assert.IsTrue(positiveQuoteConvention3.IncludesClosingQuotationMark("\u201d")); + Assert.That(positiveQuoteConvention3.IncludesClosingQuotationMark("\u201d"), Is.True); var negativeQuoteConvention3 = new QuoteConvention( "negative quote convention 3", @@ -271,7 +271,7 @@ [new SingleLevelQuoteConvention("\u201d", "\u201c")] new SingleLevelQuoteConvention("\u00ab", "\u00bb"), ] ); - Assert.IsFalse(negativeQuoteConvention3.IncludesClosingQuotationMark("\u201d")); + Assert.That(negativeQuoteConvention3.IncludesClosingQuotationMark("\u201d"), Is.False); } [Test] @@ -309,29 +309,33 @@ public void IsCompatibleWithObservedQuotationMarks() new SingleLevelQuoteConvention("\u00ab", "\u00bb"), ] ); - Assert.IsTrue( - quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u201c", "\u2018"], ["\u201d", "\u2019"]) + Assert.That( + quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u201c", "\u2018"], ["\u201d", "\u2019"]), + Is.True ); - Assert.IsTrue( - quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u201c", "\u00ab"], ["\u201d", "\u00bb"]) + Assert.That( + quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u201c", "\u00ab"], ["\u201d", "\u00bb"]), + Is.True ); - Assert.IsTrue(quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u201c"], ["\u201d", "\u2019"])); - Assert.IsTrue(quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u201c"], ["\u201d"])); - Assert.IsTrue( - quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u201c", "\u00ab"], ["\u201d", "\u2019"]) + Assert.That(quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u201c"], ["\u201d", "\u2019"]), Is.True); + Assert.That(quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u201c"], ["\u201d"]), Is.True); + Assert.That( + quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u201c", "\u00ab"], ["\u201d", "\u2019"]), + Is.True ); - Assert.IsFalse(quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u201d", "\u2019"], ["\u201c"])); + Assert.That(quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u201d", "\u2019"], ["\u201c"]), Is.False); - Assert.IsFalse(quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u201c", "\u201e"], ["\u201d"])); + Assert.That(quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u201c", "\u201e"], ["\u201d"]), Is.False); - Assert.IsFalse( - quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u201c", "\u2018"], ["\u201d", "\u201f"]) + Assert.That( + quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u201c", "\u2018"], ["\u201d", "\u201f"]), + Is.False ); // must have observed the first_level quotes - Assert.IsFalse(quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u2018"], ["\u201d"])); - Assert.IsFalse(quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u201c", "\u2018"], ["\u00ab"])); + Assert.That(quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u2018"], ["\u201d"]), Is.False); + Assert.That(quoteConvention.IsCompatibleWithObservedQuotationMarks(["\u201c", "\u2018"], ["\u00ab"]), Is.False); } [Test] @@ -396,9 +400,10 @@ public void Normalize() QuoteConvention normalizedHybridBritishTypewriterEnglishQuoteConvention = ( hybridBritishTypewriterEnglishQuoteConvention.Normalize() ); - Assert.IsTrue( + Assert.That( normalizedHybridBritishTypewriterEnglishQuoteConvention.Name - == "hybrid_british_typewriter_english_quote_convention_normalized" + == "hybrid_british_typewriter_english_quote_convention_normalized", + Is.True ); Assert.That(normalizedHybridBritishTypewriterEnglishQuoteConvention.NumLevels, Is.EqualTo(3)); Assert.That( diff --git a/tests/SIL.Machine.Tests/PunctuationAnalysis/TextSegmentTests.cs b/tests/SIL.Machine.Tests/PunctuationAnalysis/TextSegmentTests.cs index 5eb7a8ec2..a2051c931 100644 --- a/tests/SIL.Machine.Tests/PunctuationAnalysis/TextSegmentTests.cs +++ b/tests/SIL.Machine.Tests/PunctuationAnalysis/TextSegmentTests.cs @@ -13,13 +13,13 @@ public void BuilderInitialization() TextSegment textSegment = builder.Build(); Assert.That(textSegment.Text, Is.EqualTo("")); - Assert.IsNull(textSegment.PreviousSegment); - Assert.IsNull(textSegment.NextSegment); - Assert.IsTrue(textSegment.ImmediatePrecedingMarker is UsfmMarkerType.NoMarker); + Assert.That(textSegment.PreviousSegment, Is.Null); + Assert.That(textSegment.NextSegment, Is.Null); + Assert.That(textSegment.ImmediatePrecedingMarker is UsfmMarkerType.NoMarker, Is.True); Assert.That(textSegment.MarkersInPrecedingContext, Has.Count.EqualTo(0)); Assert.That(textSegment.IndexInVerse, Is.EqualTo(0)); Assert.That(textSegment.NumSegmentsInVerse, Is.EqualTo(0)); - Assert.IsNull(textSegment.UsfmToken); + Assert.That(textSegment.UsfmToken, Is.Null); } [Test] @@ -41,8 +41,8 @@ public void BuilderSetPreviousSegment() TextSegment textSegment = builder.Build(); Assert.That(textSegment.PreviousSegment, Is.EqualTo(previousSegment)); - Assert.IsNull(textSegment.NextSegment); - Assert.IsTrue(textSegment.ImmediatePrecedingMarker is UsfmMarkerType.NoMarker); + Assert.That(textSegment.NextSegment, Is.Null); + Assert.That(textSegment.ImmediatePrecedingMarker is UsfmMarkerType.NoMarker, Is.True); Assert.That(textSegment.MarkersInPrecedingContext, Has.Count.EqualTo(0)); Assert.That(textSegment.IndexInVerse, Is.EqualTo(0)); Assert.That(textSegment.NumSegmentsInVerse, Is.EqualTo(0)); @@ -55,20 +55,20 @@ public void BuilderAddPrecedingMarker() builder.AddPrecedingMarker(UsfmMarkerType.Chapter); TextSegment textSegment = builder.Build(); - Assert.IsTrue(textSegment.ImmediatePrecedingMarker is UsfmMarkerType.Chapter); + Assert.That(textSegment.ImmediatePrecedingMarker is UsfmMarkerType.Chapter, Is.True); Assert.That(textSegment.MarkersInPrecedingContext.SequenceEqual([UsfmMarkerType.Chapter])); - Assert.IsNull(textSegment.PreviousSegment); - Assert.IsNull(textSegment.NextSegment); + Assert.That(textSegment.PreviousSegment, Is.Null); + Assert.That(textSegment.NextSegment, Is.Null); builder.AddPrecedingMarker(UsfmMarkerType.Verse); textSegment = builder.Build(); Assert.That(textSegment.ImmediatePrecedingMarker, Is.EqualTo(UsfmMarkerType.Verse)); Assert.That( - textSegment.MarkersInPrecedingContext.SequenceEqual([UsfmMarkerType.Chapter, UsfmMarkerType.Verse,]) + textSegment.MarkersInPrecedingContext.SequenceEqual([UsfmMarkerType.Chapter, UsfmMarkerType.Verse]) ); - Assert.IsNull(textSegment.PreviousSegment); - Assert.IsNull(textSegment.NextSegment); + Assert.That(textSegment.PreviousSegment, Is.Null); + Assert.That(textSegment.NextSegment, Is.Null); } [Test] @@ -78,12 +78,12 @@ public void BuilderSetUsfmToken() builder.SetUsfmToken(new UsfmToken("USFM token text")); TextSegment textSegment = builder.Build(); - Assert.IsNotNull(textSegment.UsfmToken); + Assert.That(textSegment.UsfmToken, Is.Not.Null); Assert.That(textSegment.UsfmToken.Type, Is.EqualTo(UsfmTokenType.Text)); Assert.That(textSegment.UsfmToken.Text, Is.EqualTo("USFM token text")); Assert.That(textSegment.Text, Is.EqualTo("")); - Assert.IsNull(textSegment.PreviousSegment); - Assert.IsNull(textSegment.NextSegment); + Assert.That(textSegment.PreviousSegment, Is.Null); + Assert.That(textSegment.NextSegment, Is.Null); } [Test] @@ -140,8 +140,8 @@ public void Equals() ); Assert.That(segmentWithUsfmToken, Is.EqualTo(segmentWithSameUsfmToken)); - Assert.IsTrue(segmentWithUsfmToken != segmentWithDifferentUsfmToken); - Assert.IsTrue(basicSegment != segmentWithUsfmToken); + Assert.That(segmentWithUsfmToken != segmentWithDifferentUsfmToken, Is.True); + Assert.That(basicSegment != segmentWithUsfmToken, Is.True); // attributes that are not used in equality checks TextSegment segmentWithNumVerses = new TextSegment.Builder().SetText("text1").Build(); @@ -223,17 +223,17 @@ public void SubstringAfter() public void IsMarkerInPrecedingContext() { TextSegment noPrecedingMarkerSegment = new TextSegment.Builder().SetText("example text").Build(); - Assert.IsFalse(noPrecedingMarkerSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Chapter)); - Assert.IsFalse(noPrecedingMarkerSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Verse)); - Assert.IsFalse(noPrecedingMarkerSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Character)); + Assert.That(noPrecedingMarkerSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Chapter), Is.False); + Assert.That(noPrecedingMarkerSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Verse), Is.False); + Assert.That(noPrecedingMarkerSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Character), Is.False); TextSegment onePrecedingMarkerTextSegment = ( new TextSegment.Builder().SetText("example text").AddPrecedingMarker(UsfmMarkerType.Character).Build() ); - Assert.IsTrue(onePrecedingMarkerTextSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Character)); - Assert.IsFalse(onePrecedingMarkerTextSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Verse)); - Assert.IsFalse(onePrecedingMarkerTextSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Chapter)); + Assert.That(onePrecedingMarkerTextSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Character), Is.True); + Assert.That(onePrecedingMarkerTextSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Verse), Is.False); + Assert.That(onePrecedingMarkerTextSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Chapter), Is.False); TextSegment twoPrecedingMarkersTextSegment = ( new TextSegment.Builder() @@ -242,9 +242,9 @@ public void IsMarkerInPrecedingContext() .AddPrecedingMarker(UsfmMarkerType.Verse) .Build() ); - Assert.IsTrue(twoPrecedingMarkersTextSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Chapter)); - Assert.IsTrue(twoPrecedingMarkersTextSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Verse)); - Assert.IsFalse(twoPrecedingMarkersTextSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Character)); + Assert.That(twoPrecedingMarkersTextSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Chapter), Is.True); + Assert.That(twoPrecedingMarkersTextSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Verse), Is.True); + Assert.That(twoPrecedingMarkersTextSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Character), Is.False); TextSegment threePrecedingMarkersTextSegment = ( new TextSegment.Builder() @@ -254,9 +254,9 @@ public void IsMarkerInPrecedingContext() .AddPrecedingMarker(UsfmMarkerType.Character) .Build() ); - Assert.IsTrue(threePrecedingMarkersTextSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Chapter)); - Assert.IsTrue(threePrecedingMarkersTextSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Verse)); - Assert.IsTrue(threePrecedingMarkersTextSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Character)); + Assert.That(threePrecedingMarkersTextSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Chapter), Is.True); + Assert.That(threePrecedingMarkersTextSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Verse), Is.True); + Assert.That(threePrecedingMarkersTextSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Character), Is.True); } [Test] @@ -264,10 +264,10 @@ public void IsFirstSegmentInVerse() { TextSegment textSegment = new TextSegment.Builder().SetText("example text").Build(); textSegment.IndexInVerse = 0; - Assert.IsTrue(textSegment.IsFirstSegmentInVerse()); + Assert.That(textSegment.IsFirstSegmentInVerse(), Is.True); textSegment.IndexInVerse = 1; - Assert.IsFalse(textSegment.IsFirstSegmentInVerse()); + Assert.That(textSegment.IsFirstSegmentInVerse(), Is.False); } [Test] @@ -276,14 +276,14 @@ public void IsLastSegmentInVerse() TextSegment textSegment = new TextSegment.Builder().SetText("example text").Build(); textSegment.IndexInVerse = 0; textSegment.NumSegmentsInVerse = 1; - Assert.IsTrue(textSegment.IsLastSegmentInVerse()); + Assert.That(textSegment.IsLastSegmentInVerse(), Is.True); textSegment.IndexInVerse = 0; textSegment.NumSegmentsInVerse = 2; - Assert.IsFalse(textSegment.IsLastSegmentInVerse()); + Assert.That(textSegment.IsLastSegmentInVerse(), Is.False); textSegment.IndexInVerse = 1; - Assert.IsTrue(textSegment.IsLastSegmentInVerse()); + Assert.That(textSegment.IsLastSegmentInVerse(), Is.True); } [Test] diff --git a/tests/SIL.Machine.Tests/PunctuationAnalysis/UsfmStructureExtractorTests.cs b/tests/SIL.Machine.Tests/PunctuationAnalysis/UsfmStructureExtractorTests.cs index 77871027c..c2a9be25a 100644 --- a/tests/SIL.Machine.Tests/PunctuationAnalysis/UsfmStructureExtractorTests.cs +++ b/tests/SIL.Machine.Tests/PunctuationAnalysis/UsfmStructureExtractorTests.cs @@ -51,19 +51,15 @@ public void GetChaptersFilterByChapter() List expectedChapters = [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("test2") - .AddPrecedingMarker(UsfmMarkerType.Chapter) - .AddPrecedingMarker(UsfmMarkerType.Verse) - .Build() - ] - ) - ] - ) + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("test2") + .AddPrecedingMarker(UsfmMarkerType.Chapter) + .AddPrecedingMarker(UsfmMarkerType.Verse) + .Build(), + ]), + ]), ]; List actualChapters = usfmStructureExtractor.GetChapters( new Dictionary> { { 40, [2] } } @@ -83,25 +79,21 @@ public void ChapterAndVerseMarkers() List expectedChapters = [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("test") - .AddPrecedingMarker(UsfmMarkerType.Chapter) - .AddPrecedingMarker(UsfmMarkerType.Verse) - .Build() - ] - ) - ] - ) + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("test") + .AddPrecedingMarker(UsfmMarkerType.Chapter) + .AddPrecedingMarker(UsfmMarkerType.Verse) + .Build(), + ]), + ]), ]; List actualChapters = usfmStructureExtractor.GetChapters(); AssertChapterEqual(expectedChapters, actualChapters); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].NextSegment); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment, Is.Null); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].NextSegment, Is.Null); } [Test] @@ -115,26 +107,22 @@ public void StartParagraphMarker() List expectedChapters = [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("test") - .AddPrecedingMarker(UsfmMarkerType.Chapter) - .AddPrecedingMarker(UsfmMarkerType.Verse) - .AddPrecedingMarker(UsfmMarkerType.Paragraph) - .Build() - ] - ) - ] - ) + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("test") + .AddPrecedingMarker(UsfmMarkerType.Chapter) + .AddPrecedingMarker(UsfmMarkerType.Verse) + .AddPrecedingMarker(UsfmMarkerType.Paragraph) + .Build(), + ]), + ]), ]; List actualChapters = usfmStructureExtractor.GetChapters(); AssertChapterEqual(expectedChapters, actualChapters); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].NextSegment); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment, Is.Null); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].NextSegment, Is.Null); } [Test] @@ -148,26 +136,22 @@ public void StartCharacterMarker() List expectedChapters = [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("test") - .AddPrecedingMarker(UsfmMarkerType.Chapter) - .AddPrecedingMarker(UsfmMarkerType.Verse) - .AddPrecedingMarker(UsfmMarkerType.Character) - .Build() - ] - ) - ] - ) + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("test") + .AddPrecedingMarker(UsfmMarkerType.Chapter) + .AddPrecedingMarker(UsfmMarkerType.Verse) + .AddPrecedingMarker(UsfmMarkerType.Character) + .Build(), + ]), + ]), ]; List actualChapters = usfmStructureExtractor.GetChapters(); AssertChapterEqual(expectedChapters, actualChapters); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].NextSegment); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment, Is.Null); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].NextSegment, Is.Null); } [Test] @@ -181,26 +165,22 @@ public void EndCharacterMarker() List expectedChapters = [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("test") - .AddPrecedingMarker(UsfmMarkerType.Chapter) - .AddPrecedingMarker(UsfmMarkerType.Verse) - .AddPrecedingMarker(UsfmMarkerType.Character) - .Build() - ] - ) - ] - ) + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("test") + .AddPrecedingMarker(UsfmMarkerType.Chapter) + .AddPrecedingMarker(UsfmMarkerType.Verse) + .AddPrecedingMarker(UsfmMarkerType.Character) + .Build(), + ]), + ]), ]; List actualChapters = usfmStructureExtractor.GetChapters(); AssertChapterEqual(expectedChapters, actualChapters); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].NextSegment); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment, Is.Null); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].NextSegment, Is.Null); } [Test] @@ -214,26 +194,22 @@ public void EndNoteMarker() List expectedChapters = [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("test") - .AddPrecedingMarker(UsfmMarkerType.Chapter) - .AddPrecedingMarker(UsfmMarkerType.Verse) - .AddPrecedingMarker(UsfmMarkerType.Embed) - .Build() - ] - ) - ] - ) + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("test") + .AddPrecedingMarker(UsfmMarkerType.Chapter) + .AddPrecedingMarker(UsfmMarkerType.Verse) + .AddPrecedingMarker(UsfmMarkerType.Embed) + .Build(), + ]), + ]), ]; List actualChapters = usfmStructureExtractor.GetChapters(); AssertChapterEqual(expectedChapters, actualChapters); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].NextSegment); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment, Is.Null); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].NextSegment, Is.Null); } [Test] @@ -247,26 +223,22 @@ public void EndTableMarker() List expectedChapters = [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("test") - .AddPrecedingMarker(UsfmMarkerType.Chapter) - .AddPrecedingMarker(UsfmMarkerType.Verse) - .AddPrecedingMarker(UsfmMarkerType.Embed) - .Build() - ] - ) - ] - ) + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("test") + .AddPrecedingMarker(UsfmMarkerType.Chapter) + .AddPrecedingMarker(UsfmMarkerType.Verse) + .AddPrecedingMarker(UsfmMarkerType.Embed) + .Build(), + ]), + ]), ]; List actualChapters = usfmStructureExtractor.GetChapters(); AssertChapterEqual(expectedChapters, actualChapters); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].NextSegment); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment, Is.Null); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].NextSegment, Is.Null); } [Test] @@ -280,26 +252,22 @@ public void RefMarker() List expectedChapters = [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("test") - .AddPrecedingMarker(UsfmMarkerType.Chapter) - .AddPrecedingMarker(UsfmMarkerType.Verse) - .AddPrecedingMarker(UsfmMarkerType.Embed) - .Build() - ] - ) - ] - ) + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("test") + .AddPrecedingMarker(UsfmMarkerType.Chapter) + .AddPrecedingMarker(UsfmMarkerType.Verse) + .AddPrecedingMarker(UsfmMarkerType.Embed) + .Build(), + ]), + ]), ]; List actualChapters = usfmStructureExtractor.GetChapters(); AssertChapterEqual(expectedChapters, actualChapters); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].NextSegment); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment, Is.Null); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].NextSegment, Is.Null); } [Test] @@ -313,26 +281,22 @@ public void SidebarMarker() List expectedChapters = [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("test") - .AddPrecedingMarker(UsfmMarkerType.Chapter) - .AddPrecedingMarker(UsfmMarkerType.Verse) - .AddPrecedingMarker(UsfmMarkerType.Embed) - .Build() - ] - ) - ] - ) + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("test") + .AddPrecedingMarker(UsfmMarkerType.Chapter) + .AddPrecedingMarker(UsfmMarkerType.Verse) + .AddPrecedingMarker(UsfmMarkerType.Embed) + .Build(), + ]), + ]), ]; List actualChapters = usfmStructureExtractor.GetChapters(); AssertChapterEqual(expectedChapters, actualChapters); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].NextSegment); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment, Is.Null); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].NextSegment, Is.Null); } [Test] @@ -347,36 +311,30 @@ public void MultipleVerses() List expectedChapters = [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("test") - .AddPrecedingMarker(UsfmMarkerType.Chapter) - .AddPrecedingMarker(UsfmMarkerType.Verse) - .Build() - ] - ), - new Verse( - [ - new TextSegment.Builder() - .SetText("test2") - .AddPrecedingMarker(UsfmMarkerType.Chapter) - .AddPrecedingMarker(UsfmMarkerType.Verse) - .Build() - ] - ), - ] - ) + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("test") + .AddPrecedingMarker(UsfmMarkerType.Chapter) + .AddPrecedingMarker(UsfmMarkerType.Verse) + .Build(), + ]), + new Verse([ + new TextSegment.Builder() + .SetText("test2") + .AddPrecedingMarker(UsfmMarkerType.Chapter) + .AddPrecedingMarker(UsfmMarkerType.Verse) + .Build(), + ]), + ]), ]; List actualChapters = usfmStructureExtractor.GetChapters(); AssertChapterEqual(expectedChapters, actualChapters); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].NextSegment); - Assert.IsNull(actualChapters[0].Verses[1].TextSegments[0].PreviousSegment); - Assert.IsNull(actualChapters[0].Verses[1].TextSegments[0].NextSegment); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment, Is.Null); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].NextSegment, Is.Null); + Assert.That(actualChapters[0].Verses[1].TextSegments[0].PreviousSegment, Is.Null); + Assert.That(actualChapters[0].Verses[1].TextSegments[0].NextSegment, Is.Null); } [Test] @@ -392,40 +350,32 @@ public void MultipleChapters() List expectedChapters = [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("test") - .AddPrecedingMarker(UsfmMarkerType.Chapter) - .AddPrecedingMarker(UsfmMarkerType.Verse) - .Build() - ] - ), - ] - ), - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("test2") - .AddPrecedingMarker(UsfmMarkerType.Chapter) - .AddPrecedingMarker(UsfmMarkerType.Verse) - .Build() - ] - ), - ] - ), + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("test") + .AddPrecedingMarker(UsfmMarkerType.Chapter) + .AddPrecedingMarker(UsfmMarkerType.Verse) + .Build(), + ]), + ]), + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("test2") + .AddPrecedingMarker(UsfmMarkerType.Chapter) + .AddPrecedingMarker(UsfmMarkerType.Verse) + .Build(), + ]), + ]), ]; List actualChapters = usfmStructureExtractor.GetChapters(); AssertChapterEqual(expectedChapters, actualChapters); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment); - Assert.IsNull(actualChapters[0].Verses[0].TextSegments[0].NextSegment); - Assert.IsNull(actualChapters[1].Verses[0].TextSegments[0].PreviousSegment); - Assert.IsNull(actualChapters[1].Verses[0].TextSegments[0].NextSegment); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].PreviousSegment, Is.Null); + Assert.That(actualChapters[0].Verses[0].TextSegments[0].NextSegment, Is.Null); + Assert.That(actualChapters[1].Verses[0].TextSegments[0].PreviousSegment, Is.Null); + Assert.That(actualChapters[1].Verses[0].TextSegments[0].NextSegment, Is.Null); } [Test] @@ -440,25 +390,21 @@ public void CharacterMarkerInText() List expectedChapters = [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("test") - .AddPrecedingMarker(UsfmMarkerType.Chapter) - .AddPrecedingMarker(UsfmMarkerType.Verse) - .Build(), - new TextSegment.Builder() - .SetText("test2") - .AddPrecedingMarker(UsfmMarkerType.Chapter) - .AddPrecedingMarker(UsfmMarkerType.Verse) - .AddPrecedingMarker(UsfmMarkerType.Character) - .Build(), - ] - ), - ] - ) + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("test") + .AddPrecedingMarker(UsfmMarkerType.Chapter) + .AddPrecedingMarker(UsfmMarkerType.Verse) + .Build(), + new TextSegment.Builder() + .SetText("test2") + .AddPrecedingMarker(UsfmMarkerType.Chapter) + .AddPrecedingMarker(UsfmMarkerType.Verse) + .AddPrecedingMarker(UsfmMarkerType.Character) + .Build(), + ]), + ]), ]; List actualChapters = usfmStructureExtractor.GetChapters(); @@ -487,25 +433,21 @@ public void EmptyText() List expectedChapters = [ - new Chapter( - [ - new Verse( - [ - new TextSegment.Builder() - .SetText("test") - .AddPrecedingMarker(UsfmMarkerType.Chapter) - .AddPrecedingMarker(UsfmMarkerType.Verse) - .Build(), - new TextSegment.Builder() - .SetText("test2") - .AddPrecedingMarker(UsfmMarkerType.Chapter) - .AddPrecedingMarker(UsfmMarkerType.Verse) - .AddPrecedingMarker(UsfmMarkerType.Character) - .Build(), - ] - ), - ] - ) + new Chapter([ + new Verse([ + new TextSegment.Builder() + .SetText("test") + .AddPrecedingMarker(UsfmMarkerType.Chapter) + .AddPrecedingMarker(UsfmMarkerType.Verse) + .Build(), + new TextSegment.Builder() + .SetText("test2") + .AddPrecedingMarker(UsfmMarkerType.Chapter) + .AddPrecedingMarker(UsfmMarkerType.Verse) + .AddPrecedingMarker(UsfmMarkerType.Character) + .Build(), + ]), + ]), ]; List actualChapters = usfmStructureExtractor.GetChapters(); diff --git a/tests/SIL.Machine.Tests/Rules/RuleTests.cs b/tests/SIL.Machine.Tests/Rules/RuleTests.cs index 554cbed92..5e11eed36 100644 --- a/tests/SIL.Machine.Tests/Rules/RuleTests.cs +++ b/tests/SIL.Machine.Tests/Rules/RuleTests.cs @@ -60,7 +60,7 @@ public void Apply() var rule = new PatternRule(ruleSpec); AnnotatedStringData inputWord = CreateStringData("fazk"); - Assert.IsTrue(rule.Apply(inputWord).Any()); + Assert.That(rule.Apply(inputWord).Any(), Is.True); } [Test] @@ -141,6 +141,6 @@ public void Batch() var rule = new PatternRule(batchSpec); AnnotatedStringData inputWord = CreateStringData("fazk"); inputWord.Annotations.Add(inputWord.Range, FeatureStruct.New(WordFeatSys).Symbol(Word).Symbol("noun").Value); - Assert.IsTrue(rule.Apply(inputWord).Any()); + Assert.That(rule.Apply(inputWord).Any(), Is.True); } } diff --git a/tests/SIL.Machine.Tests/SIL.Machine.Tests.csproj b/tests/SIL.Machine.Tests/SIL.Machine.Tests.csproj index f15d01838..077595ce4 100644 --- a/tests/SIL.Machine.Tests/SIL.Machine.Tests.csproj +++ b/tests/SIL.Machine.Tests/SIL.Machine.Tests.csproj @@ -1,7 +1,7 @@  - net8.0 + net10.0 SIL.Machine enable enable @@ -13,30 +13,30 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/tests/SIL.Machine.Tests/Scripture/ScriptureRangeParserTests.cs b/tests/SIL.Machine.Tests/Scripture/ScriptureRangeParserTests.cs index 13da8cabb..eaabf8c47 100644 --- a/tests/SIL.Machine.Tests/Scripture/ScriptureRangeParserTests.cs +++ b/tests/SIL.Machine.Tests/Scripture/ScriptureRangeParserTests.cs @@ -70,7 +70,7 @@ public static IEnumerable GetCases() { "MAT", new List() { 1, 2, 3 } - } + }, }, false ); @@ -81,7 +81,7 @@ public static IEnumerable GetCases() { "MAT", new List() { 1, 2, 3 } - } + }, }, false ); @@ -91,7 +91,7 @@ public static IEnumerable GetCases() { { "MAT", new List() }, { "MRK", new List() }, - { "LUK", new List() } + { "LUK", new List() }, }, false ); @@ -101,7 +101,7 @@ public static IEnumerable GetCases() { { "MAT", new List() }, { "MRK", new List() }, - { "LUK", new List() } + { "LUK", new List() }, }, false ); @@ -115,7 +115,7 @@ public static IEnumerable GetCases() new List() { 1, 3, 4, 5, 8 } }, { "2JN", new List() }, - { "3JN", new List() } + { "3JN", new List() }, }, false ); @@ -136,7 +136,7 @@ public static IEnumerable GetCases() "ACT", new List() { 1, 2, 3 } }, - { "ROM", new List() } + { "ROM", new List() }, }, false ); diff --git a/tests/SIL.Machine.Tests/SequenceAlignment/MultipleAlignmentAlgorithmTests.cs b/tests/SIL.Machine.Tests/SequenceAlignment/MultipleAlignmentAlgorithmTests.cs index e6216233d..ec3718b7a 100644 --- a/tests/SIL.Machine.Tests/SequenceAlignment/MultipleAlignmentAlgorithmTests.cs +++ b/tests/SIL.Machine.Tests/SequenceAlignment/MultipleAlignmentAlgorithmTests.cs @@ -11,7 +11,7 @@ public void AlignMoreThanTwoSequences() var scorer = new StringScorer(); var msa = new MultipleAlignmentAlgorithm(scorer, new[] { "car", "bar", "carp" }, GetChars) { - UseInputOrder = true + UseInputOrder = true, }; msa.Compute(); Alignment alignment = msa.GetAlignment(); @@ -20,7 +20,7 @@ public void AlignMoreThanTwoSequences() msa = new MultipleAlignmentAlgorithm(scorer, new[] { "car", "bar", "star" }, GetChars) { - UseInputOrder = true + UseInputOrder = true, }; msa.Compute(); alignment = msa.GetAlignment(); @@ -29,7 +29,7 @@ public void AlignMoreThanTwoSequences() msa = new MultipleAlignmentAlgorithm(scorer, new[] { "car", "bar", "stare" }, GetChars) { - UseInputOrder = true + UseInputOrder = true, }; msa.Compute(); alignment = msa.GetAlignment(); @@ -38,7 +38,7 @@ public void AlignMoreThanTwoSequences() msa = new MultipleAlignmentAlgorithm(scorer, new[] { "scar", "car", "bar", "stare" }, GetChars) { - UseInputOrder = true + UseInputOrder = true, }; msa.Compute(); alignment = msa.GetAlignment(); @@ -54,7 +54,7 @@ public void AlignMoreThanTwoSequences() GetChars ) { - UseInputOrder = true + UseInputOrder = true, }; msa.Compute(); alignment = msa.GetAlignment(); @@ -70,7 +70,7 @@ public void AlignMoreThanTwoSequences() GetChars ) { - UseInputOrder = true + UseInputOrder = true, }; msa.Compute(); alignment = msa.GetAlignment(); @@ -114,7 +114,7 @@ public void AlignEmptySequence() var scorer = new StringScorer(); var msa = new MultipleAlignmentAlgorithm(scorer, new[] { "car", "", "bar" }, GetChars) { - UseInputOrder = true + UseInputOrder = true, }; msa.Compute(); Alignment alignment = msa.GetAlignment(); @@ -128,7 +128,7 @@ public void ZeroMaxScore() var scorer = new ZeroMaxScoreStringScorer(); var msa = new MultipleAlignmentAlgorithm(scorer, new[] { "car", "bar", "carp" }, GetChars) { - UseInputOrder = true + UseInputOrder = true, }; msa.Compute(); Alignment alignment = msa.GetAlignment(); diff --git a/tests/SIL.Machine.Tests/SequenceAlignment/PairwiseAlignmentAlgorithmTests.cs b/tests/SIL.Machine.Tests/SequenceAlignment/PairwiseAlignmentAlgorithmTests.cs index 68d229ac7..a36dc9160 100644 --- a/tests/SIL.Machine.Tests/SequenceAlignment/PairwiseAlignmentAlgorithmTests.cs +++ b/tests/SIL.Machine.Tests/SequenceAlignment/PairwiseAlignmentAlgorithmTests.cs @@ -50,7 +50,7 @@ public void LocalAlign() var scorer = new StringScorer(); var paa = new PairwiseAlignmentAlgorithm(scorer, "car", "bar", GetChars) { - Mode = AlignmentMode.Local + Mode = AlignmentMode.Local, }; paa.Compute(); Alignment[] alignments = paa.GetAlignments().ToArray(); @@ -63,7 +63,7 @@ public void LocalAlign() paa = new PairwiseAlignmentAlgorithm(scorer, "cart", "bar", GetChars) { - Mode = AlignmentMode.Local + Mode = AlignmentMode.Local, }; paa.Compute(); alignments = paa.GetAlignments().ToArray(); @@ -76,7 +76,7 @@ public void LocalAlign() paa = new PairwiseAlignmentAlgorithm(scorer, "cart", "art", GetChars) { - Mode = AlignmentMode.Local + Mode = AlignmentMode.Local, }; paa.Compute(); alignments = paa.GetAlignments().ToArray(); @@ -87,7 +87,7 @@ public void LocalAlign() paa = new PairwiseAlignmentAlgorithm(scorer, "start", "tan", GetChars) { - Mode = AlignmentMode.Local + Mode = AlignmentMode.Local, }; paa.Compute(); alignments = paa.GetAlignments().ToArray(); @@ -105,7 +105,7 @@ public void HalfLocalAlign() var scorer = new StringScorer(); var paa = new PairwiseAlignmentAlgorithm(scorer, "car", "bar", GetChars) { - Mode = AlignmentMode.HalfLocal + Mode = AlignmentMode.HalfLocal, }; paa.Compute(); Alignment[] alignments = paa.GetAlignments().ToArray(); @@ -116,7 +116,7 @@ public void HalfLocalAlign() paa = new PairwiseAlignmentAlgorithm(scorer, "cart", "bar", GetChars) { - Mode = AlignmentMode.HalfLocal + Mode = AlignmentMode.HalfLocal, }; paa.Compute(); alignments = paa.GetAlignments().ToArray(); @@ -127,7 +127,7 @@ public void HalfLocalAlign() paa = new PairwiseAlignmentAlgorithm(scorer, "cart", "art", GetChars) { - Mode = AlignmentMode.HalfLocal + Mode = AlignmentMode.HalfLocal, }; paa.Compute(); alignments = paa.GetAlignments().ToArray(); @@ -138,7 +138,7 @@ public void HalfLocalAlign() paa = new PairwiseAlignmentAlgorithm(scorer, "start", "tan", GetChars) { - Mode = AlignmentMode.HalfLocal + Mode = AlignmentMode.HalfLocal, }; paa.Compute(); alignments = paa.GetAlignments().ToArray(); @@ -156,7 +156,7 @@ public void SemiGlobalAlign() var scorer = new StringScorer(); var paa = new PairwiseAlignmentAlgorithm(scorer, "car", "bar", GetChars) { - Mode = AlignmentMode.SemiGlobal + Mode = AlignmentMode.SemiGlobal, }; paa.Compute(); Alignment[] alignments = paa.GetAlignments().ToArray(); @@ -167,7 +167,7 @@ public void SemiGlobalAlign() paa = new PairwiseAlignmentAlgorithm(scorer, "cart", "bar", GetChars) { - Mode = AlignmentMode.SemiGlobal + Mode = AlignmentMode.SemiGlobal, }; paa.Compute(); alignments = paa.GetAlignments().ToArray(); @@ -178,7 +178,7 @@ public void SemiGlobalAlign() paa = new PairwiseAlignmentAlgorithm(scorer, "cart", "art", GetChars) { - Mode = AlignmentMode.SemiGlobal + Mode = AlignmentMode.SemiGlobal, }; paa.Compute(); alignments = paa.GetAlignments().ToArray(); @@ -189,7 +189,7 @@ public void SemiGlobalAlign() paa = new PairwiseAlignmentAlgorithm(scorer, "start", "tan", GetChars) { - Mode = AlignmentMode.SemiGlobal + Mode = AlignmentMode.SemiGlobal, }; paa.Compute(); alignments = paa.GetAlignments().ToArray(); @@ -205,7 +205,7 @@ public void ExpansionCompressionAlign() var scorer = new StringScorer(); var paa = new PairwiseAlignmentAlgorithm(scorer, "car", "bar", GetChars) { - ExpansionCompressionEnabled = true + ExpansionCompressionEnabled = true, }; paa.Compute(); Alignment[] alignments = paa.GetAlignments().ToArray(); @@ -216,7 +216,7 @@ public void ExpansionCompressionAlign() paa = new PairwiseAlignmentAlgorithm(scorer, "cart", "bar", GetChars) { - ExpansionCompressionEnabled = true + ExpansionCompressionEnabled = true, }; paa.Compute(); alignments = paa.GetAlignments().ToArray(); @@ -227,7 +227,7 @@ public void ExpansionCompressionAlign() paa = new PairwiseAlignmentAlgorithm(scorer, "cart", "art", GetChars) { - ExpansionCompressionEnabled = true + ExpansionCompressionEnabled = true, }; paa.Compute(); alignments = paa.GetAlignments().ToArray(); @@ -238,7 +238,7 @@ public void ExpansionCompressionAlign() paa = new PairwiseAlignmentAlgorithm(scorer, "start", "tan", GetChars) { - ExpansionCompressionEnabled = true + ExpansionCompressionEnabled = true, }; paa.Compute(); alignments = paa.GetAlignments().ToArray(); @@ -256,7 +256,7 @@ public void ZeroMaxScore() var scorer = new ZeroMaxScoreStringScorer(); var paa = new PairwiseAlignmentAlgorithm(scorer, "car", "bar", GetChars) { - ExpansionCompressionEnabled = true + ExpansionCompressionEnabled = true, }; paa.Compute(); Alignment[] alignments = paa.GetAlignments().ToArray(); @@ -298,7 +298,7 @@ public void HalfLocalAlign_EmptySequence() var scorer = new StringScorer(); var paa = new PairwiseAlignmentAlgorithm(scorer, "", "", GetChars) { - Mode = AlignmentMode.HalfLocal + Mode = AlignmentMode.HalfLocal, }; paa.Compute(); Alignment[] alignments = paa.GetAlignments().ToArray(); @@ -314,7 +314,7 @@ public void SemiGlobalAlign_EmptySequence() var scorer = new StringScorer(); var paa = new PairwiseAlignmentAlgorithm(scorer, "", "", GetChars) { - Mode = AlignmentMode.SemiGlobal + Mode = AlignmentMode.SemiGlobal, }; paa.Compute(); Alignment[] alignments = paa.GetAlignments().ToArray(); diff --git a/tests/SIL.Machine.Tests/Tokenization/LatinWordTokenizerTests.cs b/tests/SIL.Machine.Tests/Tokenization/LatinWordTokenizerTests.cs index 1398a632f..37dda8e6b 100644 --- a/tests/SIL.Machine.Tests/Tokenization/LatinWordTokenizerTests.cs +++ b/tests/SIL.Machine.Tests/Tokenization/LatinWordTokenizerTests.cs @@ -158,7 +158,7 @@ public void Tokenize_Url() "in", "a", "sentence", - "." + ".", } ) ); diff --git a/tests/SIL.Machine.Tests/Translation/FuzzyEditDistanceWordAlignmentMethodTests.cs b/tests/SIL.Machine.Tests/Translation/FuzzyEditDistanceWordAlignmentMethodTests.cs index 88fc0a84b..00f055464 100644 --- a/tests/SIL.Machine.Tests/Translation/FuzzyEditDistanceWordAlignmentMethodTests.cs +++ b/tests/SIL.Machine.Tests/Translation/FuzzyEditDistanceWordAlignmentMethodTests.cs @@ -15,7 +15,7 @@ public void Align_LastSrcFirstTrg() if (srcIndex == -1 || trgIndex == -1) return 0.1; return srcSegment[srcIndex] == trgSegment[trgIndex] ? 0.9 : 0.1; - } + }, }; WordAlignmentMatrix matrix = method.Align("A B".Split(), "B C".Split()); diff --git a/tests/SIL.Machine.Tests/Translation/HybridTranslationEngineTests.cs b/tests/SIL.Machine.Tests/Translation/HybridTranslationEngineTests.cs index da9168924..205dcb29a 100644 --- a/tests/SIL.Machine.Tests/Translation/HybridTranslationEngineTests.cs +++ b/tests/SIL.Machine.Tests/Translation/HybridTranslationEngineTests.cs @@ -44,7 +44,7 @@ public TestEnvironment() new[] { new TestMorpheme("s1", "v", "walk", MorphemeType.Stem), - new TestMorpheme("s2", "v", "pst", MorphemeType.Affix) + new TestMorpheme("s2", "v", "pst", MorphemeType.Affix), }, 0, "v" @@ -52,7 +52,7 @@ public TestEnvironment() ); sourceAnalyzer.AddAnalyses( "mi", - new WordAnalysis(new[] { new TestMorpheme("s3", "adj", "my", MorphemeType.Stem), }, 0, "adj") + new WordAnalysis(new[] { new TestMorpheme("s3", "adj", "my", MorphemeType.Stem) }, 0, "adj") ); var targetGenerator = Substitute.For(); var targetMorphemes = new ReadOnlyObservableList( @@ -60,7 +60,7 @@ public TestEnvironment() { new TestMorpheme("e1", "v", "walk", MorphemeType.Stem), new TestMorpheme("e2", "v", "pst", MorphemeType.Affix), - new TestMorpheme("e3", "adj", "my", MorphemeType.Stem) + new TestMorpheme("e3", "adj", "my", MorphemeType.Stem), } ); targetGenerator.Morphemes.Returns(targetMorphemes); diff --git a/tests/SIL.Machine.Tests/Translation/InteractiveTranslatorTests.cs b/tests/SIL.Machine.Tests/Translation/InteractiveTranslatorTests.cs index c3fb6169a..856e2447c 100644 --- a/tests/SIL.Machine.Tests/Translation/InteractiveTranslatorTests.cs +++ b/tests/SIL.Machine.Tests/Translation/InteractiveTranslatorTests.cs @@ -475,7 +475,7 @@ public void UseSimpleWordGraph() { [0, 0] = true, [1, 1] = true, - [2, 2] = true + [2, 2] = true, }, Range.Create(0, 3), new[] { TranslationSources.Smt, TranslationSources.Smt, TranslationSources.Smt }, @@ -490,7 +490,7 @@ public void UseSimpleWordGraph() { [0, 0] = true, [1, 1] = true, - [2, 2] = true + [2, 2] = true, }, Range.Create(0, 3), new[] { TranslationSources.Smt, TranslationSources.Smt, TranslationSources.Smt }, diff --git a/tests/SIL.Machine.Tests/Translation/TransferEngineTests.cs b/tests/SIL.Machine.Tests/Translation/TransferEngineTests.cs index 1f0829255..551ce6ec9 100644 --- a/tests/SIL.Machine.Tests/Translation/TransferEngineTests.cs +++ b/tests/SIL.Machine.Tests/Translation/TransferEngineTests.cs @@ -18,7 +18,7 @@ public async Task TranslateAsync_CanTranslate_ReturnsCorrectTranslation() new[] { new TestMorpheme("s1", "v", "talk", MorphemeType.Stem), - new TestMorpheme("s2", "v", "pst", MorphemeType.Affix) + new TestMorpheme("s2", "v", "pst", MorphemeType.Affix), }, 0, "v" @@ -29,7 +29,7 @@ public async Task TranslateAsync_CanTranslate_ReturnsCorrectTranslation() new ObservableList { new TestMorpheme("e1", "v", "talk", MorphemeType.Stem), - new TestMorpheme("e2", "v", "pst", MorphemeType.Affix) + new TestMorpheme("e2", "v", "pst", MorphemeType.Affix), } ); targetGenerator.Morphemes.Returns(targetMorphemes); @@ -53,7 +53,7 @@ public async Task TranslateAsync_CannotAnalyze_ReturnsEmptyTranslation() new ObservableList { new TestMorpheme("e1", "v", "talk", MorphemeType.Stem), - new TestMorpheme("e2", "v", "pst", MorphemeType.Affix) + new TestMorpheme("e2", "v", "pst", MorphemeType.Affix), } ); targetGenerator.Morphemes.Returns(targetMorphemes); @@ -77,7 +77,7 @@ public async Task TranslateAsync_CannotGenerate_ReturnsEmptyTranslation() new[] { new TestMorpheme("s1", "v", "talk", MorphemeType.Stem), - new TestMorpheme("s2", "v", "pst", MorphemeType.Affix) + new TestMorpheme("s2", "v", "pst", MorphemeType.Affix), }, 0, "v" @@ -88,7 +88,7 @@ public async Task TranslateAsync_CannotGenerate_ReturnsEmptyTranslation() new ObservableList { new TestMorpheme("e1", "v", "talk", MorphemeType.Stem), - new TestMorpheme("e2", "v", "pst", MorphemeType.Affix) + new TestMorpheme("e2", "v", "pst", MorphemeType.Affix), } ); targetGenerator.Morphemes.Returns(targetMorphemes); @@ -109,7 +109,7 @@ public async Task TranslateAsync_CannotMapMorphemes_ReturnsEmptyTranslation() new[] { new TestMorpheme("s1", "v", "talk", MorphemeType.Stem), - new TestMorpheme("s2", "v", "pst", MorphemeType.Affix) + new TestMorpheme("s2", "v", "pst", MorphemeType.Affix), }, 0, "v" diff --git a/tests/SIL.Machine.Tests/Translation/TranslationExtensionsTests.cs b/tests/SIL.Machine.Tests/Translation/TranslationExtensionsTests.cs index 422628cc9..b881b134b 100644 --- a/tests/SIL.Machine.Tests/Translation/TranslationExtensionsTests.cs +++ b/tests/SIL.Machine.Tests/Translation/TranslationExtensionsTests.cs @@ -15,7 +15,7 @@ public void Align_ParallelTextRow() { SourceSegment = "maria no daba una bofetada a la bruja verde .".Split(), TargetSegment = "mary didn't slap the green witch .".Split(), - AlignedWordPairs = knownAlignment.ToAlignedWordPairs() + AlignedWordPairs = knownAlignment.ToAlignedWordPairs(), }; var estimatedAlignment = new WordAlignmentMatrix( diff --git a/tests/SIL.Machine.Tests/Translation/WordAlignmentMatrixTests.cs b/tests/SIL.Machine.Tests/Translation/WordAlignmentMatrixTests.cs index 18feefbb6..19b668ee6 100644 --- a/tests/SIL.Machine.Tests/Translation/WordAlignmentMatrixTests.cs +++ b/tests/SIL.Machine.Tests/Translation/WordAlignmentMatrixTests.cs @@ -16,7 +16,7 @@ public void IntersectWith() { [0, 0] = true, [2, 1] = true, - [3, 4] = true + [3, 4] = true, }; Assert.That(x.ValueEquals(expected), Is.True); } @@ -40,7 +40,7 @@ public void UnionWith() [4, 5] = true, [4, 6] = true, [5, 3] = true, - [6, 8] = true + [6, 8] = true, }; Assert.That(x.ValueEquals(expected), Is.True); } @@ -62,7 +62,7 @@ public void SymmetrizeWith() [3, 4] = true, [4, 5] = true, [4, 6] = true, - [6, 8] = true + [6, 8] = true, }; Assert.That(x.ValueEquals(expected), Is.True); } @@ -81,7 +81,7 @@ public void GrowSymmetrizeWith() [2, 1] = true, [3, 2] = true, [3, 3] = true, - [3, 4] = true + [3, 4] = true, }; Assert.That(x.ValueEquals(expected), Is.True); } @@ -102,7 +102,7 @@ public void GrowDiagSymmetrizeWith() [3, 3] = true, [3, 4] = true, [4, 5] = true, - [4, 6] = true + [4, 6] = true, }; Assert.That(x.ValueEquals(expected), Is.True); } @@ -125,7 +125,7 @@ public void GrowDiagFinalSymmetrizeWith() [4, 5] = true, [4, 6] = true, [5, 3] = true, - [6, 8] = true + [6, 8] = true, }; Assert.That(x.ValueEquals(expected), Is.True); } @@ -147,7 +147,7 @@ public void GrowDiagFinalAndSymmetrizeWith() [3, 4] = true, [4, 5] = true, [4, 6] = true, - [6, 8] = true + [6, 8] = true, }; Assert.That(x.ValueEquals(expected), Is.True); } @@ -159,7 +159,7 @@ public void Resize_Grow() { [0, 0] = true, [1, 1] = true, - [2, 2] = true + [2, 2] = true, }; matrix.Resize(4, 4); @@ -167,7 +167,7 @@ public void Resize_Grow() { [0, 0] = true, [1, 1] = true, - [2, 2] = true + [2, 2] = true, }; Assert.That(matrix.ValueEquals(expected), Is.True); } @@ -179,7 +179,7 @@ public void Resize_Shrink() { [0, 0] = true, [1, 1] = true, - [2, 2] = true + [2, 2] = true, }; matrix.Resize(2, 2); @@ -194,7 +194,7 @@ public void Resize_Grow_Shrink() { [0, 0] = true, [1, 1] = true, - [2, 2] = true + [2, 2] = true, }; matrix.Resize(2, 4); @@ -213,7 +213,7 @@ private static (WordAlignmentMatrix, WordAlignmentMatrix) CreateMatrices() [3, 3] = true, [3, 4] = true, [4, 5] = true, - [5, 3] = true + [5, 3] = true, }; var y = new WordAlignmentMatrix(7, 9) @@ -223,7 +223,7 @@ private static (WordAlignmentMatrix, WordAlignmentMatrix) CreateMatrices() [2, 1] = true, [3, 4] = true, [4, 6] = true, - [6, 8] = true + [6, 8] = true, }; return (x, y); diff --git a/tests/SIL.Machine.Tests/Translation/WordGraphTests.cs b/tests/SIL.Machine.Tests/Translation/WordGraphTests.cs index 9307d388f..d65feeeec 100644 --- a/tests/SIL.Machine.Tests/Translation/WordGraphTests.cs +++ b/tests/SIL.Machine.Tests/Translation/WordGraphTests.cs @@ -80,7 +80,7 @@ public void Optimize_RedundantArc() Range.Create(3, 5), GetSources(2, false), Enumerable.Repeat(1.0, 2) - ) + ), }; var wordGraph = new WordGraph(Array.Empty(), arcs, new[] { 4, 5 }, -191.0998f); @@ -180,7 +180,7 @@ public void Optimize_PartialPhraseOverlap() Range.Create(3, 5), GetSources(2, false), Enumerable.Repeat(1.0, 2) - ) + ), }; var wordGraph = new WordGraph(Array.Empty(), arcs, new[] { 4, 5 }, -191.0998f); @@ -274,7 +274,7 @@ public void Optimize_RedundantArcWithFinalState() Range.Create(3, 5), GetSources(2, false), Enumerable.Repeat(1.0, 2) - ) + ), }; var wordGraph = new WordGraph(Array.Empty(), arcs, new[] { 1, 4, 5 }, -191.0998f); @@ -395,7 +395,7 @@ public void Optimize_RedundantArcWithNonRedundantBranch() Range.Create(3, 5), GetSources(2, false), Enumerable.Repeat(1.0, 2) - ) + ), }; var wordGraph = new WordGraph(Array.Empty(), arcs, new[] { 4, 5 }, -191.0998f); diff --git a/tests/SIL.Machine.Tokenization.SentencePiece.Tests/SIL.Machine.Tokenization.SentencePiece.Tests.csproj b/tests/SIL.Machine.Tokenization.SentencePiece.Tests/SIL.Machine.Tokenization.SentencePiece.Tests.csproj index 4327dedc1..cd670c9d8 100644 --- a/tests/SIL.Machine.Tokenization.SentencePiece.Tests/SIL.Machine.Tokenization.SentencePiece.Tests.csproj +++ b/tests/SIL.Machine.Tokenization.SentencePiece.Tests/SIL.Machine.Tokenization.SentencePiece.Tests.csproj @@ -1,7 +1,7 @@ - net8.0 + net10.0 enable enable false @@ -13,21 +13,21 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/tests/SIL.Machine.Translation.Thot.Tests/SIL.Machine.Translation.Thot.Tests.csproj b/tests/SIL.Machine.Translation.Thot.Tests/SIL.Machine.Translation.Thot.Tests.csproj index 77697275f..d643139de 100644 --- a/tests/SIL.Machine.Translation.Thot.Tests/SIL.Machine.Translation.Thot.Tests.csproj +++ b/tests/SIL.Machine.Translation.Thot.Tests/SIL.Machine.Translation.Thot.Tests.csproj @@ -1,7 +1,7 @@  - net8.0 + net10.0 SIL.Machine.Translation.Thot enable enable @@ -13,26 +13,26 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/SIL.Machine.Translation.Thot.Tests/TestHelpers.cs b/tests/SIL.Machine.Translation.Thot.Tests/TestHelpers.cs index 4078fe3f6..34d1b8815 100644 --- a/tests/SIL.Machine.Translation.Thot.Tests/TestHelpers.cs +++ b/tests/SIL.Machine.Translation.Thot.Tests/TestHelpers.cs @@ -31,7 +31,7 @@ public static ParallelTextCorpus CreateTestParallelCorpus() Row(5, "ityay isyay orkingway ."), Row(6, "orkway-N ancay ebay ardhay !"), Row(7, "ayay esttay-N ancay ebay ardhay ."), - Row(8, "isthay isyay ayay ordway !") + Row(8, "isthay isyay ayay ordway !"), } ) ); @@ -48,7 +48,7 @@ public static ParallelTextCorpus CreateTestParallelCorpus() Row(5, "it is working ."), Row(6, "work N can be hard !"), Row(7, "a test N can be hard ."), - Row(8, "this is a word !") + Row(8, "this is a word !"), } ) ); diff --git a/tests/SIL.Machine.Translation.Thot.Tests/ThotFastAlignWordAlignmentModelTests.cs b/tests/SIL.Machine.Translation.Thot.Tests/ThotFastAlignWordAlignmentModelTests.cs index 9d427a9fb..e5ae41694 100644 --- a/tests/SIL.Machine.Translation.Thot.Tests/ThotFastAlignWordAlignmentModelTests.cs +++ b/tests/SIL.Machine.Translation.Thot.Tests/ThotFastAlignWordAlignmentModelTests.cs @@ -43,7 +43,7 @@ public void AlignBatch() ( "¿ me podrían dar la llave de la habitación dos cuatro cuatro , por favor ?", "could you give me the key to room number two four four , please ?" - ) + ), }; IReadOnlyList alignments = model.AlignBatch( batch @@ -59,7 +59,7 @@ public void AlignBatch() "1-0 3-1 3-2 3-3 4-4 6-5 7-9 8-6 8-8 9-7 10-10", "0-0 0-1 2-2 3-3 5-5 6-4 6-6 7-7", "3-1 4-0 5-2 5-3 6-4 7-5 8-6 8-7 10-11 10-12 11-8 12-9 13-10 15-14 15-15", - "0-0 0-1 1-3 3-2 4-4 5-5 5-6 7-8 8-7 9-9 11-10 11-11 13-12 14-13 15-14" + "0-0 0-1 1-3 3-2 4-4 5-5 5-6 7-8 8-7 9-9 11-10 11-11 13-12 14-13 15-14", } ) ); diff --git a/tests/SIL.Machine.Translation.Thot.Tests/ThotHmmWordAlignmentModelTests.cs b/tests/SIL.Machine.Translation.Thot.Tests/ThotHmmWordAlignmentModelTests.cs index 7aa25f94b..bfdf6c818 100644 --- a/tests/SIL.Machine.Translation.Thot.Tests/ThotHmmWordAlignmentModelTests.cs +++ b/tests/SIL.Machine.Translation.Thot.Tests/ThotHmmWordAlignmentModelTests.cs @@ -41,7 +41,7 @@ public void AlignBatch() ( "¿ me podrían dar la llave de la habitación dos cuatro cuatro , por favor ?", "could you give me the key to room number two four four , please ?" - ) + ), }; IReadOnlyList alignments = model.AlignBatch( batch @@ -57,7 +57,7 @@ public void AlignBatch() "2-0 3-1 3-2 3-3 4-4 6-5 7-9 8-6 9-7 9-8 10-10", "0-0 0-1 0-2 3-3 5-5 6-4 6-6 7-7", "0-13 0-14 3-15 4-0 5-1 5-2 5-3 6-4 7-5 8-6 9-7 11-8 12-9 13-10 14-11 14-12", - "2-0 2-1 3-2 3-3 4-4 5-5 6-6 8-7 9-8 9-9 10-10 11-11 13-12 14-13 15-14" + "2-0 2-1 3-2 3-3 4-4 5-5 6-6 8-7 9-8 9-9 10-10 11-11 13-12 14-13 15-14", } ) ); @@ -265,8 +265,8 @@ public async Task CreateTrainer() { Ibm1IterationCount = 2, HmmIterationCount = 2, - HmmP0 = 0.1 - } + HmmP0 = 0.1, + }, }; ITrainer trainer = model.CreateTrainer(TestHelpers.CreateTestParallelCorpus()); await trainer.TrainAsync(); diff --git a/tests/SIL.Machine.Translation.Thot.Tests/ThotIbm4WordAlignmentModelTests.cs b/tests/SIL.Machine.Translation.Thot.Tests/ThotIbm4WordAlignmentModelTests.cs index 51521463b..f38039dfd 100644 --- a/tests/SIL.Machine.Translation.Thot.Tests/ThotIbm4WordAlignmentModelTests.cs +++ b/tests/SIL.Machine.Translation.Thot.Tests/ThotIbm4WordAlignmentModelTests.cs @@ -44,7 +44,7 @@ public async Task CreateTrainer() { "oftenyay", "6" }, // adjectives { "ardhay", "7" }, - { "orkingway", "7" } + { "orkingway", "7" }, }, TargetWordClasses = new Dictionary { @@ -75,9 +75,9 @@ public async Task CreateTrainer() { "work", "8" }, // disambiguators { "N", "9" }, - { "V", "9" } - } - } + { "V", "9" }, + }, + }, }; ITrainer trainer = model.CreateTrainer(TestHelpers.CreateTestParallelCorpus()); await trainer.TrainAsync(); diff --git a/tests/SIL.Machine.Translation.Thot.Tests/ThotSmtModelTests.cs b/tests/SIL.Machine.Translation.Thot.Tests/ThotSmtModelTests.cs index d5f35c325..1ca2975ae 100644 --- a/tests/SIL.Machine.Translation.Thot.Tests/ThotSmtModelTests.cs +++ b/tests/SIL.Machine.Translation.Thot.Tests/ThotSmtModelTests.cs @@ -75,7 +75,7 @@ public async Task TranslateBatchAsync_Batch_Hmm() "por favor , despiértenos mañana a las siete y cuarto .", "voy a marcharme hoy por la tarde .", "por favor , ¿ les importaría bajar nuestro equipaje a la habitación número cero trece ?", - "¿ me podrían dar la llave de la habitación dos cuatro cuatro , por favor ?" + "¿ me podrían dar la llave de la habitación dos cuatro cuatro , por favor ?", }; using ThotSmtModel smtModel = CreateHmmModel(); @@ -89,7 +89,7 @@ public async Task TranslateBatchAsync_Batch_Hmm() "please wake us up tomorrow at a quarter past seven .", "i am leaving today in the afternoon .", "please would you mind sending down our luggage to room number oh thirteenth ?", - "could you give me the key to room number two four four , please ?" + "could you give me the key to room number two four four , please ?", } ) ); @@ -104,7 +104,7 @@ public void TranslateBatch_Batch_Hmm() "por favor , despiértenos mañana a las siete y cuarto .", "voy a marcharme hoy por la tarde .", "por favor , ¿ les importaría bajar nuestro equipaje a la habitación número cero trece ?", - "¿ me podrían dar la llave de la habitación dos cuatro cuatro , por favor ?" + "¿ me podrían dar la llave de la habitación dos cuatro cuatro , por favor ?", }; using ThotSmtModel smtModel = CreateHmmModel(); @@ -118,7 +118,7 @@ public void TranslateBatch_Batch_Hmm() "please wake us up tomorrow at a quarter past seven .", "i am leaving today in the afternoon .", "please would you mind sending down our luggage to room number oh thirteenth ?", - "could you give me the key to room number two four four , please ?" + "could you give me the key to room number two four four , please ?", } ) ); @@ -187,16 +187,15 @@ public async Task GetWordGraphAsync_EmptySegment_FastAlign() [Test] public void Constructor_ModelDoesNotExist() { - Assert.Throws( - () => - new ThotSmtModel( - ThotWordAlignmentModelType.Hmm, - new ThotSmtParameters - { - TranslationModelFileNamePrefix = "does-not-exist", - LanguageModelFileNamePrefix = "does-not-exist" - } - ) + Assert.Throws(() => + new ThotSmtModel( + ThotWordAlignmentModelType.Hmm, + new ThotSmtParameters + { + TranslationModelFileNamePrefix = "does-not-exist", + LanguageModelFileNamePrefix = "does-not-exist", + } + ) ); } @@ -210,16 +209,15 @@ public void Constructor_ModelCorrupted() string lmDir = Path.Combine(tempDir.Path, "lm"); Directory.CreateDirectory(lmDir); File.WriteAllText(Path.Combine(lmDir, "trg.lm"), "corrupted"); - Assert.Throws( - () => - new ThotSmtModel( - ThotWordAlignmentModelType.Hmm, - new ThotSmtParameters - { - TranslationModelFileNamePrefix = Path.Combine(tmDir, "src_trg"), - LanguageModelFileNamePrefix = Path.Combine(lmDir, "trg.lm") - } - ) + Assert.Throws(() => + new ThotSmtModel( + ThotWordAlignmentModelType.Hmm, + new ThotSmtParameters + { + TranslationModelFileNamePrefix = Path.Combine(tmDir, "src_trg"), + LanguageModelFileNamePrefix = Path.Combine(lmDir, "trg.lm"), + } + ) ); } diff --git a/tests/SIL.Machine.Translation.Thot.Tests/ThotSmtModelTrainerTests.cs b/tests/SIL.Machine.Translation.Thot.Tests/ThotSmtModelTrainerTests.cs index 37d1f1d18..c138a72a5 100644 --- a/tests/SIL.Machine.Translation.Thot.Tests/ThotSmtModelTrainerTests.cs +++ b/tests/SIL.Machine.Translation.Thot.Tests/ThotSmtModelTrainerTests.cs @@ -31,9 +31,9 @@ public async Task Train_NonEmptyCorpus() Row(7, "¿ Le importaría mostrarnos una habitación con televisión ?"), Row(8, "¿ Tiene teléfono ?"), Row(9, "Voy a marcharme el dos a las ocho de la noche ."), - Row(10, "¿ Cuánto cuesta una habitación individual por semana ?") + Row(10, "¿ Cuánto cuesta una habitación individual por semana ?"), } - ) + ), } ); @@ -57,9 +57,9 @@ public async Task Train_NonEmptyCorpus() Row(7, "Would you mind showing us a room with a tv ?"), Row(8, "Does it have a telephone ?"), Row(9, "I am leaving on the second at eight in the evening ."), - Row(10, "How much does a single room cost per week ?") + Row(10, "How much does a single room cost per week ?"), } - ) + ), } ); @@ -79,9 +79,9 @@ public async Task Train_NonEmptyCorpus() Alignment(7, new AlignedWordPair(5, 6)), Alignment(8), Alignment(9), - Alignment(10, new AlignedWordPair(4, 5)) + Alignment(10, new AlignedWordPair(4, 5)), } - ) + ), } ); @@ -90,14 +90,14 @@ public async Task Train_NonEmptyCorpus() var parameters = new ThotSmtParameters { TranslationModelFileNamePrefix = Path.Combine(tempDir.Path, "tm", "src_trg"), - LanguageModelFileNamePrefix = Path.Combine(tempDir.Path, "lm", "trg.lm") + LanguageModelFileNamePrefix = Path.Combine(tempDir.Path, "lm", "trg.lm"), }; using ( var trainer = new ThotSmtModelTrainer(ThotWordAlignmentModelType.Hmm, corpus, parameters) { LowercaseSource = true, - LowercaseTarget = true + LowercaseTarget = true, } ) { @@ -109,7 +109,7 @@ public async Task Train_NonEmptyCorpus() using var model = new ThotSmtModel(ThotWordAlignmentModelType.Hmm, parameters) { LowercaseSource = true, - LowercaseTarget = true + LowercaseTarget = true, }; TranslationResult result = await model.TranslateAsync("Una habitación individual por semana"); Assert.That(result.Translation, Is.EqualTo("a single room cost per week")); @@ -128,14 +128,14 @@ public async Task Train_EmptyCorpus() var parameters = new ThotSmtParameters { TranslationModelFileNamePrefix = Path.Combine(tempDir.Path, "tm", "src_trg"), - LanguageModelFileNamePrefix = Path.Combine(tempDir.Path, "lm", "trg.lm") + LanguageModelFileNamePrefix = Path.Combine(tempDir.Path, "lm", "trg.lm"), }; using ( var trainer = new ThotSmtModelTrainer(ThotWordAlignmentModelType.Hmm, corpus, parameters) { LowercaseSource = true, - LowercaseTarget = true + LowercaseTarget = true, } ) { @@ -147,7 +147,7 @@ public async Task Train_EmptyCorpus() using var model = new ThotSmtModel(ThotWordAlignmentModelType.Hmm, parameters) { LowercaseSource = true, - LowercaseTarget = true + LowercaseTarget = true, }; TranslationResult result = await model.TranslateAsync("Una habitación individual por semana"); Assert.That(result.Translation, Is.EqualTo("una habitación individual por semana"));