IpaGestureExperiment: make the target/variant candidate id injective

("a","b-c") and ("a-b","c") both joined to "a-b-c" before the map and wrote the
same files. Each part goes through StoreFileName.From first and the pair is
joined with '/', which no mapped part can contain.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Aqua 2026-11-07 09:54:00 +00:00
commit 4865830d82
2 changed files with 16 additions and 1 deletions

View file

@ -122,7 +122,7 @@ public static class IpaGestureExperiment
{
foreach (var variant in variantList)
{
var candidateId = StoreFileName.From($"{target.Id}-{variant.Id}");
var candidateId = StoreFileName.From($"{StoreFileName.From(target.Id)}/{StoreFileName.From(variant.Id)}");
var script = BuildCandidateScript(target, variant);
var scriptPath = Path.Combine(candidateDirectory, $"{candidateId}.aqua");
File.WriteAllText(scriptPath, script, Encoding.UTF8);

View file

@ -128,5 +128,20 @@ public sealed class StoreFileNameTests
Assert.Throws<ArgumentException>(() => IpaGestureExperiment.WriteRound(root, "..", [new IpaGestureExperimentTarget("a", "p", "voiceless_bilabial_plosive")], [new IpaGestureExperimentVariant("base")]));
}
[Fact]
public void IpaRoundJoinedTargetVariantIdsThatConcatenateEquallyKeepDistinctFiles()
{
var root = Path.Combine(Path.GetTempPath(), $"aquasynth-ipa-join-{Guid.NewGuid():N}");
var result = IpaGestureExperiment.WriteRound(
root,
"round-join",
[new IpaGestureExperimentTarget("a", "p", "voiceless_bilabial_plosive", .1f), new IpaGestureExperimentTarget("a-b", "m", "voiced_bilabial_nasal", .1f)],
[new IpaGestureExperimentVariant("b-c"), new IpaGestureExperimentVariant("c")]);
Assert.Equal(4, result.Candidates.Count);
Assert.Equal(4, result.Candidates.Select(c => c.Id).Distinct(StringComparer.OrdinalIgnoreCase).Count());
Assert.Equal(4, result.Candidates.Select(c => c.ScriptPath).Distinct(StringComparer.OrdinalIgnoreCase).Count());
}
private static string UriPath(string uri) => new Uri(uri).LocalPath;
}