Get Segments
This commit is contained in:
parent
b24d3b9c8d
commit
90244811ed
@ -115,13 +115,14 @@ public class MapLogic
|
|||||||
private List<(long, long, long, long)> GetPersonKeysRangesCollection(PersonContainer[] personContainers)
|
private List<(long, long, long, long)> GetPersonKeysRangesCollection(PersonContainer[] personContainers)
|
||||||
{
|
{
|
||||||
List<(long, long, long, long)> results = new();
|
List<(long, long, long, long)> results = new();
|
||||||
|
(long, long, long, long) singleton;
|
||||||
foreach (PersonContainer personContainer in personContainers)
|
foreach (PersonContainer personContainer in personContainers)
|
||||||
{
|
{
|
||||||
if (personContainer.Key is null)
|
if (personContainer.Key is null)
|
||||||
continue;
|
continue;
|
||||||
if (!_PersonKeyToRanges.ContainsKey(personContainer.Key.Value))
|
if (!_PersonKeyToRanges.TryGetValue(personContainer.Key.Value, out singleton))
|
||||||
continue;
|
continue;
|
||||||
results.Add(_PersonKeyToRanges[personContainer.Key.Value]);
|
results.Add(singleton);
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
@ -133,7 +134,8 @@ public class MapLogic
|
|||||||
List<Sorting> results = new();
|
List<Sorting> results = new();
|
||||||
Sorting sorting;
|
Sorting sorting;
|
||||||
FaceDistance faceDistanceLength;
|
FaceDistance faceDistanceLength;
|
||||||
Dictionary<int, PersonContainer[]> keyValuePairs;
|
List<int>? normalizedPixelPercentages;
|
||||||
|
Dictionary<int, PersonContainer[]>? keyValuePairs;
|
||||||
List<(long lcl, long minimum, long maximum, long ucl)> personKeysRangesCollection;
|
List<(long lcl, long minimum, long maximum, long ucl)> personKeysRangesCollection;
|
||||||
for (int j = 0; j < faceDistanceLengths.Count; j++)
|
for (int j = 0; j < faceDistanceLengths.Count; j++)
|
||||||
{
|
{
|
||||||
@ -144,20 +146,18 @@ public class MapLogic
|
|||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
if (faceDistanceLength.Length == 0)
|
if (faceDistanceLength.Length == 0)
|
||||||
continue;
|
continue;
|
||||||
if (_SkipCollection.ContainsKey(faceDistanceEncoding.Id))
|
if (_SkipCollection.TryGetValue(faceDistanceEncoding.Id, out normalizedPixelPercentages))
|
||||||
{
|
{
|
||||||
if (_SkipCollection[faceDistanceEncoding.Id].Contains(faceDistanceEncoding.NormalizedPixelPercentage.Value))
|
if (normalizedPixelPercentages.Contains(faceDistanceEncoding.NormalizedPixelPercentage.Value))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (_IdThenNormalizedPixelPercentageToPersonContainers.ContainsKey(faceDistanceEncoding.Id))
|
if (_IdThenNormalizedPixelPercentageToPersonContainers.TryGetValue(faceDistanceEncoding.Id, out keyValuePairs))
|
||||||
{
|
{
|
||||||
keyValuePairs = _IdThenNormalizedPixelPercentageToPersonContainers[faceDistanceEncoding.Id];
|
|
||||||
if (keyValuePairs.ContainsKey(faceDistanceEncoding.NormalizedPixelPercentage.Value))
|
if (keyValuePairs.ContainsKey(faceDistanceEncoding.NormalizedPixelPercentage.Value))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!_IdThenNormalizedPixelPercentageToPersonContainers.ContainsKey(faceDistanceLength.Id))
|
if (!_IdThenNormalizedPixelPercentageToPersonContainers.TryGetValue(faceDistanceLength.Id, out keyValuePairs))
|
||||||
continue;
|
continue;
|
||||||
keyValuePairs = _IdThenNormalizedPixelPercentageToPersonContainers[faceDistanceLength.Id];
|
|
||||||
if (!keyValuePairs.ContainsKey(faceDistanceLength.NormalizedPixelPercentage.Value))
|
if (!keyValuePairs.ContainsKey(faceDistanceLength.NormalizedPixelPercentage.Value))
|
||||||
continue;
|
continue;
|
||||||
personKeysRangesCollection = GetPersonKeysRangesCollection(keyValuePairs[faceDistanceLength.NormalizedPixelPercentage.Value]);
|
personKeysRangesCollection = GetPersonKeysRangesCollection(keyValuePairs[faceDistanceLength.NormalizedPixelPercentage.Value]);
|
||||||
@ -183,8 +183,8 @@ public class MapLogic
|
|||||||
string fullName;
|
string fullName;
|
||||||
string personKeyFormatted;
|
string personKeyFormatted;
|
||||||
PersonBirthday personBirthday;
|
PersonBirthday personBirthday;
|
||||||
PersonContainer personContainer;
|
|
||||||
WindowsShortcut windowsShortcut;
|
WindowsShortcut windowsShortcut;
|
||||||
|
PersonContainer? personContainer;
|
||||||
List<(Face, long?, (string, string, string, string))> collection = GetCollection(distinctFilteredFaces);
|
List<(Face, long?, (string, string, string, string))> collection = GetCollection(distinctFilteredFaces);
|
||||||
foreach ((Face face, long? personKey, (string directory, string copyDirectory, string copyFileName, string shortcutFileName)) in collection)
|
foreach ((Face face, long? personKey, (string directory, string copyDirectory, string copyFileName, string shortcutFileName)) in collection)
|
||||||
{
|
{
|
||||||
@ -205,9 +205,8 @@ public class MapLogic
|
|||||||
if (!Directory.Exists(directory))
|
if (!Directory.Exists(directory))
|
||||||
{
|
{
|
||||||
_ = Directory.CreateDirectory(directory);
|
_ = Directory.CreateDirectory(directory);
|
||||||
if (personKey is not null && _PersonKeyToPersonContainer.ContainsKey(personKey.Value))
|
if (personKey is not null && _PersonKeyToPersonContainer.TryGetValue(personKey.Value, out personContainer))
|
||||||
{
|
{
|
||||||
personContainer = _PersonKeyToPersonContainer[personKey.Value];
|
|
||||||
fullName = string.Concat(personContainer.DisplayDirectoryName, ".txt");
|
fullName = string.Concat(personContainer.DisplayDirectoryName, ".txt");
|
||||||
File.WriteAllText(Path.Combine(directory, fullName), string.Empty);
|
File.WriteAllText(Path.Combine(directory, fullName), string.Empty);
|
||||||
}
|
}
|
||||||
@ -270,23 +269,23 @@ public class MapLogic
|
|||||||
const int zero = 0;
|
const int zero = 0;
|
||||||
string mappingSegmentB;
|
string mappingSegmentB;
|
||||||
PersonBirthday personBirthday;
|
PersonBirthday personBirthday;
|
||||||
|
PersonContainer[]? collection;
|
||||||
int by = Stateless.IMapLogic.Mapping;
|
int by = Stateless.IMapLogic.Mapping;
|
||||||
List<PersonContainer> personContainers = new();
|
List<PersonContainer> personContainers = new();
|
||||||
Dictionary<int, PersonContainer[]> keyValuePairs;
|
Dictionary<int, PersonContainer[]>? keyValuePairs;
|
||||||
foreach (Face face in distinctFilteredFaces)
|
foreach (Face face in distinctFilteredFaces)
|
||||||
{
|
{
|
||||||
personContainers.Clear();
|
personContainers.Clear();
|
||||||
if (face.Mapping is null)
|
if (face.Mapping is null)
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
if (!_IdThenNormalizedPixelPercentageToPersonContainers.ContainsKey(face.Mapping.MappingFromItem.Id))
|
if (!_IdThenNormalizedPixelPercentageToPersonContainers.TryGetValue(face.Mapping.MappingFromItem.Id, out keyValuePairs))
|
||||||
result += 1;
|
result += 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
keyValuePairs = _IdThenNormalizedPixelPercentageToPersonContainers[face.Mapping.MappingFromItem.Id];
|
if (!keyValuePairs.TryGetValue(face.Mapping.MappingFromLocation.NormalizedPixelPercentage, out collection))
|
||||||
if (!keyValuePairs.ContainsKey(face.Mapping.MappingFromLocation.NormalizedPixelPercentage))
|
|
||||||
result += 1;
|
result += 1;
|
||||||
else
|
else
|
||||||
personContainers.AddRange(keyValuePairs[face.Mapping.MappingFromLocation.NormalizedPixelPercentage]);
|
personContainers.AddRange(collection);
|
||||||
}
|
}
|
||||||
foreach (PersonContainer personContainer in personContainers)
|
foreach (PersonContainer personContainer in personContainers)
|
||||||
{
|
{
|
||||||
@ -420,7 +419,7 @@ public class MapLogic
|
|||||||
PersonBirthday personBirthday;
|
PersonBirthday personBirthday;
|
||||||
DateTime dateTime = DateTime.Now;
|
DateTime dateTime = DateTime.Now;
|
||||||
PersonContainer[] personContainers;
|
PersonContainer[] personContainers;
|
||||||
Dictionary<int, PersonContainer[]> keyValuePairs;
|
Dictionary<int, PersonContainer[]>? keyValuePairs;
|
||||||
foreach (Face face in distinctFilteredFaces)
|
foreach (Face face in distinctFilteredFaces)
|
||||||
{
|
{
|
||||||
if (face.Mapping is null)
|
if (face.Mapping is null)
|
||||||
@ -430,14 +429,13 @@ public class MapLogic
|
|||||||
relativePath = Path.GetDirectoryName($"C:{face.RelativePath}");
|
relativePath = Path.GetDirectoryName($"C:{face.RelativePath}");
|
||||||
if (string.IsNullOrEmpty(relativePath) || relativePath.Length < 3)
|
if (string.IsNullOrEmpty(relativePath) || relativePath.Length < 3)
|
||||||
continue;
|
continue;
|
||||||
if (!_IdThenNormalizedPixelPercentageToPersonContainers.ContainsKey(face.Mapping.MappingFromItem.Id))
|
if (!_IdThenNormalizedPixelPercentageToPersonContainers.TryGetValue(face.Mapping.MappingFromItem.Id, out keyValuePairs))
|
||||||
{
|
{
|
||||||
personKey = null;
|
personKey = null;
|
||||||
directory = Path.Combine(_EDistanceContentTicksDirectory, $"Unnamed{relativePath[2..]}");
|
directory = Path.Combine(_EDistanceContentTicksDirectory, $"Unnamed{relativePath[2..]}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
keyValuePairs = _IdThenNormalizedPixelPercentageToPersonContainers[face.Mapping.MappingFromItem.Id];
|
|
||||||
if (!keyValuePairs.ContainsKey(face.Mapping.MappingFromLocation.NormalizedPixelPercentage))
|
if (!keyValuePairs.ContainsKey(face.Mapping.MappingFromLocation.NormalizedPixelPercentage))
|
||||||
continue;
|
continue;
|
||||||
personKey = null;
|
personKey = null;
|
||||||
@ -497,7 +495,7 @@ public class MapLogic
|
|||||||
PersonBirthday personBirthday;
|
PersonBirthday personBirthday;
|
||||||
PersonContainer[] personContainers;
|
PersonContainer[] personContainers;
|
||||||
const int by = Stateless.IMapLogic.Sorting;
|
const int by = Stateless.IMapLogic.Sorting;
|
||||||
Dictionary<int, PersonContainer[]> keyValuePairs;
|
Dictionary<int, PersonContainer[]>? keyValuePairs;
|
||||||
Dictionary<string, List<Mapping>> checkKeyValuePairs = new();
|
Dictionary<string, List<Mapping>> checkKeyValuePairs = new();
|
||||||
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - _Ticks).TotalSeconds);
|
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - _Ticks).TotalSeconds);
|
||||||
string message = $") {sortingContainers.Length:000} Update From Sorting Container(s) - {totalSeconds} total second(s)";
|
string message = $") {sortingContainers.Length:000} Update From Sorting Container(s) - {totalSeconds} total second(s)";
|
||||||
@ -510,14 +508,13 @@ public class MapLogic
|
|||||||
progressBar.Tick();
|
progressBar.Tick();
|
||||||
if (sortingContainer.Face.Mapping is null)
|
if (sortingContainer.Face.Mapping is null)
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
if (!_IdThenNormalizedPixelPercentageToPersonContainers.ContainsKey(sortingContainer.Sorting.Id))
|
if (!_IdThenNormalizedPixelPercentageToPersonContainers.TryGetValue(sortingContainer.Sorting.Id, out keyValuePairs))
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
if (!results.ContainsKey(sortingContainer.Face.Mapping.MappingFromItem.Id))
|
if (!results.ContainsKey(sortingContainer.Face.Mapping.MappingFromItem.Id))
|
||||||
results.Add(sortingContainer.Face.Mapping.MappingFromItem.Id, new());
|
results.Add(sortingContainer.Face.Mapping.MappingFromItem.Id, new());
|
||||||
hashSet = results[sortingContainer.Face.Mapping.MappingFromItem.Id];
|
hashSet = results[sortingContainer.Face.Mapping.MappingFromItem.Id];
|
||||||
if (hashSet.Contains(sortingContainer.Face.Mapping.MappingFromLocation.NormalizedPixelPercentage))
|
if (hashSet.Contains(sortingContainer.Face.Mapping.MappingFromLocation.NormalizedPixelPercentage))
|
||||||
continue;
|
continue;
|
||||||
keyValuePairs = _IdThenNormalizedPixelPercentageToPersonContainers[sortingContainer.Sorting.Id];
|
|
||||||
if (!keyValuePairs.ContainsKey(sortingContainer.Sorting.NormalizedPixelPercentage))
|
if (!keyValuePairs.ContainsKey(sortingContainer.Sorting.NormalizedPixelPercentage))
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
personContainers = keyValuePairs[sortingContainer.Sorting.NormalizedPixelPercentage];
|
personContainers = keyValuePairs[sortingContainer.Sorting.NormalizedPixelPercentage];
|
||||||
@ -553,7 +550,7 @@ public class MapLogic
|
|||||||
const int zero = 0;
|
const int zero = 0;
|
||||||
string mappingSegmentB;
|
string mappingSegmentB;
|
||||||
PersonBirthday personBirthday;
|
PersonBirthday personBirthday;
|
||||||
List<int> normalizedPixelPercentages;
|
List<int>? normalizedPixelPercentages;
|
||||||
int by = Stateless.IMapLogic.ForceSingleImage;
|
int by = Stateless.IMapLogic.ForceSingleImage;
|
||||||
string displayDirectoryName = _Configuration.MappingDefaultName;
|
string displayDirectoryName = _Configuration.MappingDefaultName;
|
||||||
Face[] orderedDistinctFilteredFaces = (from l in distinctFilteredFaces orderby l.Mapping is not null, l.Mapping?.MappingFromLocation.Confidence descending select l).ToArray();
|
Face[] orderedDistinctFilteredFaces = (from l in distinctFilteredFaces orderby l.Mapping is not null, l.Mapping?.MappingFromLocation.Confidence descending select l).ToArray();
|
||||||
@ -563,9 +560,8 @@ public class MapLogic
|
|||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
if (face.Mapping.MappingFromPerson.PersonBirthday is not null)
|
if (face.Mapping.MappingFromPerson.PersonBirthday is not null)
|
||||||
continue;
|
continue;
|
||||||
if (_SkipCollection.ContainsKey(face.Mapping.MappingFromItem.Id))
|
if (_SkipCollection.TryGetValue(face.Mapping.MappingFromItem.Id, out normalizedPixelPercentages))
|
||||||
{
|
{
|
||||||
normalizedPixelPercentages = _SkipCollection[face.Mapping.MappingFromItem.Id];
|
|
||||||
if (normalizedPixelPercentages.Contains(face.Mapping.MappingFromLocation.NormalizedPixelPercentage))
|
if (normalizedPixelPercentages.Contains(face.Mapping.MappingFromLocation.NormalizedPixelPercentage))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -724,8 +720,9 @@ public class MapLogic
|
|||||||
string? personDisplayDirectory;
|
string? personDisplayDirectory;
|
||||||
int? normalizedPixelPercentage;
|
int? normalizedPixelPercentage;
|
||||||
WindowsShortcut windowsShortcut;
|
WindowsShortcut windowsShortcut;
|
||||||
Dictionary<int, PersonContainer[]> keyValuePairs;
|
Dictionary<int, PersonContainer[]>? keyValuePairs;
|
||||||
string by = nameof(Stateless.IMapLogic.ManualCopy);
|
string by = nameof(Stateless.IMapLogic.ManualCopy);
|
||||||
|
Dictionary<int, Face>? normalizedPixelPercentageToFace;
|
||||||
string dFacesContentDirectory = Path.Combine(dResultsFullGroupDirectory, "()");
|
string dFacesContentDirectory = Path.Combine(dResultsFullGroupDirectory, "()");
|
||||||
string successfull = $"_ {nameof(Stateless.IMapLogic.ManualCopy).Humanize(LetterCasing.Title)} Successfull";
|
string successfull = $"_ {nameof(Stateless.IMapLogic.ManualCopy).Humanize(LetterCasing.Title)} Successfull";
|
||||||
Dictionary<int, Dictionary<int, Face>> idToNormalizedPixelPercentageToFace = GetKeyValuePairs(distinctFilteredFaces);
|
Dictionary<int, Dictionary<int, Face>> idToNormalizedPixelPercentageToFace = GetKeyValuePairs(distinctFilteredFaces);
|
||||||
@ -741,9 +738,8 @@ public class MapLogic
|
|||||||
(id, normalizedPixelPercentage, _) = IMapping.GetReversedDeterministicHashCodeKey(_Configuration.LocationDigits, _FacesFileNameExtension, personDisplayDirectoryAllFile);
|
(id, normalizedPixelPercentage, _) = IMapping.GetReversedDeterministicHashCodeKey(_Configuration.LocationDigits, _FacesFileNameExtension, personDisplayDirectoryAllFile);
|
||||||
if (id is null || normalizedPixelPercentage is null)
|
if (id is null || normalizedPixelPercentage is null)
|
||||||
continue;
|
continue;
|
||||||
if (_IdThenNormalizedPixelPercentageToPersonContainers.ContainsKey(id.Value))
|
if (_IdThenNormalizedPixelPercentageToPersonContainers.TryGetValue(id.Value, out keyValuePairs))
|
||||||
{
|
{
|
||||||
keyValuePairs = _IdThenNormalizedPixelPercentageToPersonContainers[id.Value];
|
|
||||||
if (keyValuePairs.ContainsKey(normalizedPixelPercentage.Value))
|
if (keyValuePairs.ContainsKey(normalizedPixelPercentage.Value))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -756,10 +752,10 @@ public class MapLogic
|
|||||||
mappingSegmentB = GetMappingSegmentB(_Ticks, personBirthday, keyValuePair.Value.ApproximateYears, fileInfo.CreationTime, isWrongYear: null);
|
mappingSegmentB = GetMappingSegmentB(_Ticks, personBirthday, keyValuePair.Value.ApproximateYears, fileInfo.CreationTime, isWrongYear: null);
|
||||||
directory = Path.Combine(_EDistanceContentTicksDirectory, by, personKeyFormatted, mappingSegmentB);
|
directory = Path.Combine(_EDistanceContentTicksDirectory, by, personKeyFormatted, mappingSegmentB);
|
||||||
personDirectory = Path.Combine(directory, keyValuePair.Value.DisplayDirectoryName, "lnk");
|
personDirectory = Path.Combine(directory, keyValuePair.Value.DisplayDirectoryName, "lnk");
|
||||||
if (!Directory.Exists(personDirectory))
|
if (!idToNormalizedPixelPercentageToFace.TryGetValue(id.Value, out normalizedPixelPercentageToFace))
|
||||||
_ = Directory.CreateDirectory(personDirectory);
|
continue;
|
||||||
if (!idToNormalizedPixelPercentageToFace.ContainsKey(id.Value))
|
if (!normalizedPixelPercentageToFace.ContainsKey(normalizedPixelPercentage.Value))
|
||||||
throw new NotSupportedException();
|
continue;
|
||||||
face = idToNormalizedPixelPercentageToFace[id.Value][normalizedPixelPercentage.Value];
|
face = idToNormalizedPixelPercentageToFace[id.Value][normalizedPixelPercentage.Value];
|
||||||
if (face.Mapping is null)
|
if (face.Mapping is null)
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
@ -772,6 +768,8 @@ public class MapLogic
|
|||||||
facesDirectory = Path.Combine($"{dFacesContentDirectory}{directoryName}", face.Mapping.MappingFromItem.ImageFileHolder.NameWithoutExtension);
|
facesDirectory = Path.Combine($"{dFacesContentDirectory}{directoryName}", face.Mapping.MappingFromItem.ImageFileHolder.NameWithoutExtension);
|
||||||
faceFileName = $"{face.Mapping.MappingFromLocation.DeterministicHashCodeKey}{face.Mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_FacesFileNameExtension}";
|
faceFileName = $"{face.Mapping.MappingFromLocation.DeterministicHashCodeKey}{face.Mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_FacesFileNameExtension}";
|
||||||
checkFile = Path.Combine(directory, fileInfo.Name);
|
checkFile = Path.Combine(directory, fileInfo.Name);
|
||||||
|
if (!Directory.Exists(personDirectory))
|
||||||
|
_ = Directory.CreateDirectory(personDirectory);
|
||||||
if (!File.Exists(checkFile))
|
if (!File.Exists(checkFile))
|
||||||
File.Copy(personDisplayDirectoryAllFile, checkFile);
|
File.Copy(personDisplayDirectoryAllFile, checkFile);
|
||||||
if (personDisplayDirectoryAllFile.Contains(successfull))
|
if (personDisplayDirectoryAllFile.Contains(successfull))
|
||||||
|
@ -345,12 +345,12 @@ internal abstract class MapLogic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string? GetCheckFile(string facesFileNameExtension, string file, int id, int normalizedPixelPercentage)
|
private static string? GetCheckFile(Configuration configuration, string facesFileNameExtension, string file, int id, int normalizedPixelPercentage)
|
||||||
{
|
{
|
||||||
string? result;
|
string? result;
|
||||||
string fileName = Path.GetFileName(file);
|
string fileName = Path.GetFileName(file);
|
||||||
string? directoryName = Path.GetDirectoryName(file);
|
string? directoryName = Path.GetDirectoryName(file);
|
||||||
(string? Id, string? NormalizedPixelPercentage, string? ExtensionLowered, bool? Check) segments = IMapping.GetSegments(facesFileNameExtension, fileName);
|
(string? Id, string? NormalizedPixelPercentage, string? ExtensionLowered, bool? Check) segments = IMapping.GetSegments(configuration.LocationDigits, facesFileNameExtension, fileName);
|
||||||
if (string.IsNullOrEmpty(directoryName) || string.IsNullOrEmpty(segments.Id) || string.IsNullOrEmpty(segments.NormalizedPixelPercentage) || string.IsNullOrEmpty(segments.ExtensionLowered))
|
if (string.IsNullOrEmpty(directoryName) || string.IsNullOrEmpty(segments.Id) || string.IsNullOrEmpty(segments.NormalizedPixelPercentage) || string.IsNullOrEmpty(segments.ExtensionLowered))
|
||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
@ -452,7 +452,7 @@ internal abstract class MapLogic
|
|||||||
result++;
|
result++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
checkFile = GetCheckFile(facesFileNameExtension, file, id.Value, normalizedPixelPercentage.Value);
|
checkFile = GetCheckFile(configuration, facesFileNameExtension, file, id.Value, normalizedPixelPercentage.Value);
|
||||||
if (string.IsNullOrEmpty(checkFile))
|
if (string.IsNullOrEmpty(checkFile))
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
if (faces is null)
|
if (faces is null)
|
||||||
@ -554,8 +554,8 @@ internal abstract class MapLogic
|
|||||||
|
|
||||||
private static void SetPersonTicks(long ticks, List<Face> distinctFilteredFaces, Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedPixelPercentageToPersonContainers)
|
private static void SetPersonTicks(long ticks, List<Face> distinctFilteredFaces, Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedPixelPercentageToPersonContainers)
|
||||||
{
|
{
|
||||||
PersonContainer[] personContainers;
|
PersonContainer[]? personContainers;
|
||||||
Dictionary<int, PersonContainer[]> keyValuePairs;
|
Dictionary<int, PersonContainer[]>? keyValuePairs;
|
||||||
Dictionary<long, List<long>> personTicks = new();
|
Dictionary<long, List<long>> personTicks = new();
|
||||||
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||||
string message = $") {distinctFilteredFaces.Count:000} Set Person Ticks - {totalSeconds} total second(s)";
|
string message = $") {distinctFilteredFaces.Count:000} Set Person Ticks - {totalSeconds} total second(s)";
|
||||||
@ -566,12 +566,10 @@ internal abstract class MapLogic
|
|||||||
progressBar.Tick();
|
progressBar.Tick();
|
||||||
if (face.Mapping is null)
|
if (face.Mapping is null)
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
if (!idThenNormalizedPixelPercentageToPersonContainers.ContainsKey(face.Mapping.MappingFromItem.Id))
|
if (!idThenNormalizedPixelPercentageToPersonContainers.TryGetValue(face.Mapping.MappingFromItem.Id, out keyValuePairs))
|
||||||
continue;
|
continue;
|
||||||
keyValuePairs = idThenNormalizedPixelPercentageToPersonContainers[face.Mapping.MappingFromItem.Id];
|
if (!keyValuePairs.TryGetValue(face.Mapping.MappingFromLocation.NormalizedPixelPercentage, out personContainers))
|
||||||
if (!keyValuePairs.ContainsKey(face.Mapping.MappingFromLocation.NormalizedPixelPercentage))
|
|
||||||
continue;
|
continue;
|
||||||
personContainers = keyValuePairs[face.Mapping.MappingFromLocation.NormalizedPixelPercentage];
|
|
||||||
foreach (PersonContainer personContainer in personContainers)
|
foreach (PersonContainer personContainer in personContainers)
|
||||||
{
|
{
|
||||||
if (personContainer.Key is null)
|
if (personContainer.Key is null)
|
||||||
@ -607,13 +605,14 @@ internal abstract class MapLogic
|
|||||||
|
|
||||||
private static void AppendToSkipCollection(Dictionary<int, List<int>> skipCollection, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedPixelPercentageToPersonContainers, Dictionary<int, Dictionary<int, PersonContainer[]>> incorrectIdThenNormalizedPixelPercentageToPersonContainers)
|
private static void AppendToSkipCollection(Dictionary<int, List<int>> skipCollection, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedPixelPercentageToPersonContainers, Dictionary<int, Dictionary<int, PersonContainer[]>> incorrectIdThenNormalizedPixelPercentageToPersonContainers)
|
||||||
{
|
{
|
||||||
|
Dictionary<int, PersonContainer[]>? keyValuePairs;
|
||||||
foreach (KeyValuePair<int, Dictionary<int, PersonContainer[]>> keyValuePair in incorrectIdThenNormalizedPixelPercentageToPersonContainers)
|
foreach (KeyValuePair<int, Dictionary<int, PersonContainer[]>> keyValuePair in incorrectIdThenNormalizedPixelPercentageToPersonContainers)
|
||||||
{
|
{
|
||||||
if (!skipCollection.ContainsKey(keyValuePair.Key))
|
if (!skipCollection.ContainsKey(keyValuePair.Key))
|
||||||
skipCollection.Add(keyValuePair.Key, new());
|
skipCollection.Add(keyValuePair.Key, new());
|
||||||
if (idThenNormalizedPixelPercentageToPersonContainers.ContainsKey(keyValuePair.Key))
|
if (idThenNormalizedPixelPercentageToPersonContainers.TryGetValue(keyValuePair.Key, out keyValuePairs))
|
||||||
{
|
{
|
||||||
if (idThenNormalizedPixelPercentageToPersonContainers[keyValuePair.Key].ContainsKey(keyValuePair.Value.ElementAt(0).Key))
|
if (keyValuePairs.ContainsKey(keyValuePair.Value.ElementAt(0).Key))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
skipCollection[keyValuePair.Key].AddRange(from l in keyValuePair.Value.Keys select l);
|
skipCollection[keyValuePair.Key].AddRange(from l in keyValuePair.Value.Keys select l);
|
||||||
@ -642,7 +641,7 @@ internal abstract class MapLogic
|
|||||||
{
|
{
|
||||||
int? approximateYears = null;
|
int? approximateYears = null;
|
||||||
PersonBirthday? personBirthday;
|
PersonBirthday? personBirthday;
|
||||||
PersonContainer personContainer;
|
PersonContainer? personContainer;
|
||||||
string displayDirectoryName = configuration.MappingDefaultName;
|
string displayDirectoryName = configuration.MappingDefaultName;
|
||||||
foreach (long personKey in personKeyCollection)
|
foreach (long personKey in personKeyCollection)
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@ public interface ILocation
|
|||||||
string TestStatic_GetRightPadded(int locationDigits, string value) =>
|
string TestStatic_GetRightPadded(int locationDigits, string value) =>
|
||||||
GetRightPadded(locationDigits, value);
|
GetRightPadded(locationDigits, value);
|
||||||
static string GetRightPadded(int locationDigits, string value) =>
|
static string GetRightPadded(int locationDigits, string value) =>
|
||||||
value.PadRight(locationDigits, '0');
|
value.Length == locationDigits ? value : value.Length > locationDigits ? value[..locationDigits] : value.PadRight(locationDigits, '0');
|
||||||
|
|
||||||
string TestStatic_GetRightPadded(int locationDigits, int value) =>
|
string TestStatic_GetRightPadded(int locationDigits, int value) =>
|
||||||
GetRightPadded(locationDigits, value);
|
GetRightPadded(locationDigits, value);
|
||||||
|
@ -6,10 +6,10 @@ public interface IMapping
|
|||||||
static string GetDeterministicHashCodeKey(int id, int normalizedPixelPercentage)
|
static string GetDeterministicHashCodeKey(int id, int normalizedPixelPercentage)
|
||||||
=> $"{id}.{normalizedPixelPercentage}";
|
=> $"{id}.{normalizedPixelPercentage}";
|
||||||
|
|
||||||
(string?, string?, string?, bool?) TestStatic_GetSegments(string facesFileNameExtension, string fileName)
|
(string?, string?, string?, bool?) TestStatic_GetSegments(int locationDigits, string facesFileNameExtension, string fileName)
|
||||||
=> GetSegments(facesFileNameExtension, fileName);
|
=> GetSegments(locationDigits, facesFileNameExtension, fileName);
|
||||||
static (string?, string?, string?, bool?) GetSegments(string facesFileNameExtension, string fileName)
|
static (string?, string?, string?, bool?) GetSegments(int locationDigits, string facesFileNameExtension, string fileName)
|
||||||
=> Mapping.GetSegments(facesFileNameExtension, fileName);
|
=> Mapping.GetSegments(locationDigits, facesFileNameExtension, fileName);
|
||||||
|
|
||||||
(int?, int?, List<Models.Face>?) TestStatic_GetReversedDeterministicHashCodeKey(int locationDigits, string facesFileNameExtension, string file) =>
|
(int?, int?, List<Models.Face>?) TestStatic_GetReversedDeterministicHashCodeKey(int locationDigits, string facesFileNameExtension, string file) =>
|
||||||
GetReversedDeterministicHashCodeKey(locationDigits, facesFileNameExtension, file);
|
GetReversedDeterministicHashCodeKey(locationDigits, facesFileNameExtension, file);
|
||||||
|
@ -18,7 +18,7 @@ internal abstract class Mapping
|
|||||||
int? id;
|
int? id;
|
||||||
List<Models.Face>? faces;
|
List<Models.Face>? faces;
|
||||||
int? normalizedPixelPercentage;
|
int? normalizedPixelPercentage;
|
||||||
(string? Id, string? NormalizedPixelPercentage, string? ExtensionLowered, bool? Check) segments = GetSegments(facesFileNameExtension, fileName);
|
(string? Id, string? NormalizedPixelPercentage, string? ExtensionLowered, bool? Check) segments = GetSegments(locationDigits, facesFileNameExtension, fileName);
|
||||||
if (string.IsNullOrEmpty(segments.Id) || string.IsNullOrEmpty(segments.NormalizedPixelPercentage) || string.IsNullOrEmpty(segments.ExtensionLowered) || segments.Check is null)
|
if (string.IsNullOrEmpty(segments.Id) || string.IsNullOrEmpty(segments.NormalizedPixelPercentage) || string.IsNullOrEmpty(segments.ExtensionLowered) || segments.Check is null)
|
||||||
{
|
{
|
||||||
id = null;
|
id = null;
|
||||||
@ -45,7 +45,7 @@ internal abstract class Mapping
|
|||||||
return new(id, normalizedPixelPercentage, faces);
|
return new(id, normalizedPixelPercentage, faces);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static (string?, string?, string?, bool?) GetSegments(string facesFileNameExtension, string fileName)
|
internal static (string?, string?, string?, bool?) GetSegments(int locationDigits, string facesFileNameExtension, string fileName)
|
||||||
{
|
{
|
||||||
string[] segments = fileName.Split('.');
|
string[] segments = fileName.Split('.');
|
||||||
string? id;
|
string? id;
|
||||||
@ -63,8 +63,8 @@ internal abstract class Mapping
|
|||||||
{
|
{
|
||||||
id = segments[0];
|
id = segments[0];
|
||||||
extensionLowered = $".{segments[2]}";
|
extensionLowered = $".{segments[2]}";
|
||||||
normalizedPixelPercentage = segments[1];
|
|
||||||
needsFacesFileNameExtension = segments.Length == 3;
|
needsFacesFileNameExtension = segments.Length == 3;
|
||||||
|
normalizedPixelPercentage = ILocation.GetRightPadded(locationDigits, segments[1]);
|
||||||
}
|
}
|
||||||
return new(id, normalizedPixelPercentage, extensionLowered, needsFacesFileNameExtension);
|
return new(id, normalizedPixelPercentage, extensionLowered, needsFacesFileNameExtension);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ internal abstract class PersonContainer
|
|||||||
if (personDisplayDirectoryAllFile.EndsWith(".lnk"))
|
if (personDisplayDirectoryAllFile.EndsWith(".lnk"))
|
||||||
continue;
|
continue;
|
||||||
(id, normalizedPixelPercentage, _) = IMapping.GetReversedDeterministicHashCodeKey(locationDigits, facesFileNameExtension, personDisplayDirectoryAllFile);
|
(id, normalizedPixelPercentage, _) = IMapping.GetReversedDeterministicHashCodeKey(locationDigits, facesFileNameExtension, personDisplayDirectoryAllFile);
|
||||||
if (id is not null && normalizedPixelPercentage is not null)
|
if (id is not null && normalizedPixelPercentage is not null && !personDisplayDirectoryAllFile.EndsWith(".json"))
|
||||||
continue;
|
continue;
|
||||||
checkDirectory = Path.GetDirectoryName(personDisplayDirectoryAllFile);
|
checkDirectory = Path.GetDirectoryName(personDisplayDirectoryAllFile);
|
||||||
if (string.IsNullOrEmpty(checkDirectory))
|
if (string.IsNullOrEmpty(checkDirectory))
|
||||||
|
@ -130,6 +130,15 @@ public class UnitTestCalculations
|
|||||||
Assert.IsTrue(successfull == "_ Manual Copy Successfull");
|
Assert.IsTrue(successfull == "_ Manual Copy Successfull");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestMethodDel()
|
||||||
|
{
|
||||||
|
string source = @"F:\Tmp\Phares\Compare\Images 2022-09-15 - 7390c13 - III - Results\E) Distance\2022-09-15\7680 x 4320\7680x4320 - Hog - Large\()\(637992984751968513)";
|
||||||
|
for (int i = 1; i < 11; i++)
|
||||||
|
_ = IPath.DeleteEmptyDirectories(source);
|
||||||
|
Assert.IsTrue(true);
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestMethodDirectory()
|
public void TestMethodDirectory()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user