Error - Don't keep
This commit is contained in:
@ -13,7 +13,6 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
protected readonly Dictionary<int, List<int>> _SkipCollection;
|
||||
protected readonly List<PersonContainer> _NotMappedPersonContainers;
|
||||
protected readonly Dictionary<long, PersonContainer> _PersonKeyToPersonContainer;
|
||||
protected Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)>? _PersonKeyToRanges;
|
||||
protected readonly Dictionary<int, Dictionary<int, PersonContainer[]>> _IdThenNormalizedRectangleToPersonContainers;
|
||||
|
||||
public Dictionary<int, int[]> KeyValuePairs => throw new NotImplementedException();
|
||||
@ -101,6 +100,37 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
return result;
|
||||
}
|
||||
|
||||
public void CreateTree(long ticks, string a2PeopleContentDirectory)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
string by;
|
||||
string directory;
|
||||
string[] segments;
|
||||
const int zero = 0;
|
||||
string personKeyFormatted;
|
||||
PersonBirthday personBirthday;
|
||||
string rootDirectory = Path.Combine(a2PeopleContentDirectory, $"{ticks}-Tree");
|
||||
foreach (KeyValuePair<long, PersonContainer> personKeyToPersonContainer in _PersonKeyToPersonContainer)
|
||||
{
|
||||
if (personKeyToPersonContainer.Value.Key is null || personKeyToPersonContainer.Value.Birthdays is null || !personKeyToPersonContainer.Value.Birthdays.Any())
|
||||
continue;
|
||||
if (personKeyToPersonContainer.Value.DisplayDirectoryName == _Configuration.MappingDefaultName)
|
||||
continue;
|
||||
personBirthday = personKeyToPersonContainer.Value.Birthdays[zero];
|
||||
personKeyFormatted = IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, personBirthday);
|
||||
by = IPersonBirthday.IsCounterPersonBirthday(personBirthday) ? _PropertyConfiguration.ResultAllInOne : "People";
|
||||
segments = personKeyToPersonContainer.Value.DisplayDirectoryName.Split(_Configuration.PersonCharacters.ToArray());
|
||||
if (segments.Length < 2)
|
||||
directory = Path.Combine(rootDirectory, $"000 {personKeyFormatted} {personKeyToPersonContainer.Value.DisplayDirectoryName}");
|
||||
else
|
||||
directory = Path.Combine(rootDirectory, $"{segments[1].PadLeft(3, '0')} {personKeyFormatted} {personKeyToPersonContainer.Value.DisplayDirectoryName}");
|
||||
if (Directory.Exists(directory))
|
||||
continue;
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
}
|
||||
}
|
||||
|
||||
private static Dictionary<int, List<long>> GetIdToPersonKeys(Dictionary<long, List<int>> keyValuePairs)
|
||||
{
|
||||
Dictionary<int, List<long>> results = new();
|
||||
@ -593,23 +623,6 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
Stateless.MapLogic.SaveMappingShortcuts(mappingDirectory);
|
||||
}
|
||||
|
||||
private List<(long, long, long, long)> GetPersonKeysRangesCollection(PersonContainer[] personContainers)
|
||||
{
|
||||
if (_PersonKeyToRanges is null)
|
||||
throw new NullReferenceException(nameof(_PersonKeyToRanges));
|
||||
List<(long, long, long, long)> results = new();
|
||||
(long, long, long, long) singleton;
|
||||
foreach (PersonContainer personContainer in personContainers)
|
||||
{
|
||||
if (personContainer.Key is null)
|
||||
continue;
|
||||
if (!_PersonKeyToRanges.TryGetValue(personContainer.Key.Value, out singleton))
|
||||
continue;
|
||||
results.Add(singleton);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public bool Used(FaceDistance faceDistanceEncoding)
|
||||
{
|
||||
bool result = false;
|
||||
@ -636,7 +649,6 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
FaceDistance faceDistanceLength;
|
||||
List<int>? normalizedRectangles;
|
||||
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
|
||||
List<(long lcl, long minimum, long maximum, long ucl)> personKeysRangesCollection;
|
||||
for (int j = 0; j < faceDistanceLengths.Count; j++)
|
||||
{
|
||||
if (faceDistanceEncoding.NormalizedRectangle is null)
|
||||
@ -655,16 +667,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
throw new NotSupportedException();
|
||||
if (faceDistanceLength.Length == 0)
|
||||
continue;
|
||||
if (!_IdThenNormalizedRectangleToPersonContainers.TryGetValue(faceDistanceLength.Id, out normalizedRectangleToPersonContainers))
|
||||
personKeysRangesCollection = new();
|
||||
else
|
||||
{
|
||||
if (!normalizedRectangleToPersonContainers.ContainsKey(faceDistanceLength.NormalizedRectangle.Value))
|
||||
personKeysRangesCollection = new();
|
||||
else
|
||||
personKeysRangesCollection = GetPersonKeysRangesCollection(normalizedRectangleToPersonContainers[faceDistanceLength.NormalizedRectangle.Value]);
|
||||
}
|
||||
sorting = ISorting.Get(_Configuration.FaceDistancePermyriad, _Configuration.RangeDistanceTolerance, faceDistanceEncoding, faceDistanceLength, personKeysRangesCollection);
|
||||
sorting = ISorting.Get(_Configuration.FaceDistancePermyriad, _Configuration.RangeDistanceTolerance, faceDistanceEncoding, faceDistanceLength);
|
||||
if (sorting.DistancePermyriad == 0)
|
||||
continue;
|
||||
if (sorting.Id == faceDistanceEncoding.Id)
|
||||
@ -787,15 +790,13 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
string by = nameof(Shared.Models.Stateless.IMapLogic.ManualCopy);
|
||||
Dictionary<int, PersonContainer[]>? normalizedRectangleToPeronContainerCollection;
|
||||
string successfull = $"_ {nameof(Shared.Models.Stateless.IMapLogic.ManualCopy).Humanize(LetterCasing.Title)} Successfull";
|
||||
foreach (KeyValuePair<long, PersonContainer> keyValuePair in _PersonKeyToPersonContainer)
|
||||
foreach (KeyValuePair<long, PersonContainer> personKeyToPersonContainer in _PersonKeyToPersonContainer)
|
||||
{
|
||||
if (keyValuePair.Value.Key is null || keyValuePair.Value.Birthdays is null || !keyValuePair.Value.Birthdays.Any())
|
||||
if (personKeyToPersonContainer.Value.Key is null || personKeyToPersonContainer.Value.Birthdays is null || !personKeyToPersonContainer.Value.Birthdays.Any())
|
||||
continue;
|
||||
personBirthday = keyValuePair.Value.Birthdays[zero];
|
||||
foreach (string personDisplayDirectoryAllFile in keyValuePair.Value.DisplayDirectoryAllFiles)
|
||||
personBirthday = personKeyToPersonContainer.Value.Birthdays[zero];
|
||||
foreach (string personDisplayDirectoryAllFile in personKeyToPersonContainer.Value.DisplayDirectoryAllFiles)
|
||||
{
|
||||
if (personDisplayDirectoryAllFile.Contains("-2318605"))
|
||||
continue;
|
||||
if (!personDisplayDirectoryAllFile.EndsWith(_Configuration.FacesFileNameExtension))
|
||||
continue;
|
||||
(id, normalizedRectangle) = IMapping.GetConverted(_Configuration.FacesFileNameExtension, personDisplayDirectoryAllFile);
|
||||
@ -807,9 +808,9 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
personDisplayFileName = Path.GetFileName(personDisplayDirectoryAllFile);
|
||||
personDisplayDirectory = Path.GetDirectoryName(personDisplayDirectoryAllFile);
|
||||
personKeyFormatted = IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, personBirthday);
|
||||
mappingSegmentB = Stateless.MapLogic.GetMappingSegmentB(_Ticks, personBirthday, keyValuePair.Value.ApproximateYears, fileInfo.CreationTime, isWrongYear: null);
|
||||
mappingSegmentB = Stateless.MapLogic.GetMappingSegmentB(_Ticks, personBirthday, personKeyToPersonContainer.Value.ApproximateYears, fileInfo.CreationTime, isWrongYear: null);
|
||||
directory = Path.Combine(_EDistanceContentTicksDirectory, by, personKeyFormatted, mappingSegmentB);
|
||||
personDirectory = Path.Combine(directory, keyValuePair.Value.DisplayDirectoryName, "lnk");
|
||||
personDirectory = Path.Combine(directory, personKeyToPersonContainer.Value.DisplayDirectoryName, "lnk");
|
||||
if (!idToNormalizedRectangleToMapping.TryGetValue(id.Value, out normalizedRectangleToMapping))
|
||||
continue;
|
||||
if (!normalizedRectangleToMapping.ContainsKey(normalizedRectangle.Value))
|
||||
@ -913,32 +914,6 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveNotMappedTicks()
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
int updated = 0;
|
||||
string directory;
|
||||
const int zero = 0;
|
||||
int totalNotMapped = 0;
|
||||
string personKeyFormatted;
|
||||
SaveContainer saveContainer;
|
||||
PersonBirthday personBirthday;
|
||||
List<SaveContainer> saveContainers = new();
|
||||
const string facePopulatedKey = nameof(Shared.Models.Stateless.IMapLogic.Sorting);
|
||||
foreach (PersonContainer personContainer in _NotMappedPersonContainers)
|
||||
{
|
||||
if (personContainer.Key is null || personContainer.Birthdays is null || !personContainer.Birthdays.Any())
|
||||
continue;
|
||||
personBirthday = personContainer.Birthdays[zero];
|
||||
personKeyFormatted = IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, personBirthday);
|
||||
directory = Path.Combine(_EDistanceContentTicksDirectory, $"{facePopulatedKey}NotMapped", personKeyFormatted, _Configuration.MappingDefaultName);
|
||||
saveContainer = new(directory);
|
||||
saveContainers.Add(saveContainer);
|
||||
}
|
||||
SaveContainers(totalNotMapped, updated, saveContainers);
|
||||
}
|
||||
|
||||
private (string, PersonBirthday?) GetPersonBirthday(string[] directoryNames)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
@ -1226,67 +1201,6 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
}
|
||||
}
|
||||
|
||||
private List<(string, FileHolder, string)> GetCollection(string dFacesContentDirectory, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
List<(string, FileHolder, string)> results = new();
|
||||
Mapping mapping;
|
||||
string checkFile;
|
||||
string directory;
|
||||
string? directoryName;
|
||||
string? facesDirectory;
|
||||
FileHolder faceFileHolder;
|
||||
List<int>? normalizedRectangles;
|
||||
string by = nameof(Shared.Models.Stateless.IMapLogic.CopyNotMappedFaces);
|
||||
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
|
||||
foreach (KeyValuePair<int, Dictionary<int, Mapping>> keyValuePair in idToNormalizedRectangleToMapping)
|
||||
{
|
||||
_ = _IdThenNormalizedRectangleToPersonContainers.TryGetValue(keyValuePair.Key, out normalizedRectangleToPersonContainers);
|
||||
foreach (KeyValuePair<int, Mapping> normalizedRectangleAndMapping in keyValuePair.Value)
|
||||
{
|
||||
mapping = normalizedRectangleAndMapping.Value;
|
||||
if (normalizedRectangleToPersonContainers is not null && normalizedRectangleToPersonContainers.ContainsKey(mapping.MappingFromLocation.NormalizedRectangle))
|
||||
continue;
|
||||
_ = _SkipCollection.TryGetValue(keyValuePair.Key, out normalizedRectangles);
|
||||
if (normalizedRectangles is not null && normalizedRectangles.Contains(mapping.MappingFromLocation.NormalizedRectangle))
|
||||
continue;
|
||||
directoryName = Path.GetDirectoryName(mapping.MappingFromItem.RelativePath);
|
||||
facesDirectory = GetFacesDirectory(dFacesContentDirectory, mapping.MappingFromItem);
|
||||
if (facesDirectory is null)
|
||||
continue;
|
||||
faceFileHolder = new(Path.Combine(facesDirectory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_Configuration.FacesFileNameExtension}"));
|
||||
if (directoryName is null || !faceFileHolder.Exists)
|
||||
continue;
|
||||
directory = Path.Combine(_EDistanceContentTicksDirectory, by, $"{mapping.MappingFromLocation.AreaPermille:0000}A{mapping.MappingFromItem.MinimumDateTime.ToString("yyyy")[..3]}#");
|
||||
checkFile = Path.Combine(directory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_Configuration.FacesFileNameExtension}");
|
||||
results.Add(new(directory, faceFileHolder, checkFile));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public void CopyNotMappedFaces(int[] rangeFaceAreaPermilleTolerance, string dFacesContentDirectory, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
List<(string Directory, FileHolder FaceFileHolder, string CheckFile)> collection = GetCollection(dFacesContentDirectory, idToNormalizedRectangleToMapping);
|
||||
string[] directories = (from l in collection select l.Directory).Distinct().ToArray();
|
||||
foreach (string directory in directories)
|
||||
{
|
||||
if (string.IsNullOrEmpty(directory))
|
||||
continue;
|
||||
if (!Directory.Exists(directory))
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
}
|
||||
foreach ((string directory, FileHolder faceFileHolder, string checkFile) in collection)
|
||||
{
|
||||
if (File.Exists(checkFile))
|
||||
continue;
|
||||
File.Copy(faceFileHolder.FullName, checkFile);
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<int, Dictionary<int, PersonContainer[]>> GetMissing(Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping)
|
||||
{
|
||||
Dictionary<int, Dictionary<int, PersonContainer[]>> results = new();
|
||||
@ -1299,13 +1213,6 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
public void UpdatedPersonKeyToRanges(Configuration configuration, long ticks, Mapping[] mappingCollection)
|
||||
{
|
||||
Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges = new();
|
||||
Stateless.MapLogic.SetPersonTicks(configuration, ticks, mappingCollection, personKeyToRanges, _IdThenNormalizedRectangleToPersonContainers);
|
||||
_PersonKeyToRanges = personKeyToRanges;
|
||||
}
|
||||
|
||||
public List<Face> GetFurtherFilterBySkipCollection(List<Face> distinctFilteredFaces)
|
||||
{
|
||||
List<Face> results = new();
|
||||
|
@ -209,9 +209,9 @@ internal abstract class MapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
internal static List<string> DeleteEmptyDirectoriesAndGetMappedFaceFiles(Configuration configuration, PersonContainer[] personContainers, long ticks, string? a2PeopleContentDirectory, string eDistanceContentDirectory)
|
||||
internal static List<(long, string)> DeleteEmptyDirectoriesAndGetMappedFaceFiles(Configuration configuration, PersonContainer[] personContainers, long ticks, string? a2PeopleContentDirectory, string eDistanceContentDirectory)
|
||||
{
|
||||
List<string> results = new();
|
||||
List<(long, string)> results = new();
|
||||
List<(long? PersonKey, string Line)> lines = new();
|
||||
_ = GetDistinctCollection(configuration, personContainers, new(), new());
|
||||
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
@ -230,13 +230,25 @@ internal abstract class MapLogic
|
||||
}
|
||||
ticksDirectories = Directory.GetDirectories(eDistanceContentDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
}
|
||||
long personKey;
|
||||
List<string> distinct = new();
|
||||
PersonBirthday? personBirthday;
|
||||
string message = $") {ticksDirectories.Length:000} collect from and clean ticks Director(ies) - A - {totalSeconds} total second(s)";
|
||||
List<string> personKeyFormattedCollection = GetPersonKeyFormattedCollection(configuration, personContainers, lines);
|
||||
if (!string.IsNullOrEmpty(a2PeopleContentDirectory))
|
||||
File.WriteAllLines(Path.Combine(a2PeopleContentDirectory, "People - C.tsv"), from l in lines select l.Line);
|
||||
List<(string, string[], string)> collection = DeleteEmptyDirectoriesAndGetCollection(configuration, personKeyFormattedCollection, ticksDirectories, message);
|
||||
foreach ((_, _, string mappedFaceFile) in collection)
|
||||
results.Add(mappedFaceFile);
|
||||
foreach ((string personKeyFormatted, _, string mappedFaceFile) in collection)
|
||||
{
|
||||
personBirthday = IPersonBirthday.GetPersonBirthday(configuration.PersonBirthdayFormat, personKeyFormatted);
|
||||
if (personBirthday is null)
|
||||
continue;
|
||||
if (distinct.Contains(mappedFaceFile))
|
||||
continue;
|
||||
distinct.Add(mappedFaceFile);
|
||||
personKey = personBirthday.Value.Ticks;
|
||||
results.Add(new(personKey, mappedFaceFile));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
@ -253,7 +265,7 @@ internal abstract class MapLogic
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
private static void SetKeyValuePairs(Configuration configuration, List<PersonContainer> personContainers, Dictionary<long, List<PersonContainer>> personKeyToPersonContainerCollection, Dictionary<string, PersonContainer> personKeyFormattedToPersonContainer, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedRectangleCollection, List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection, Dictionary<long, PersonContainer> personKeyToPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedRectangleToPersonContainers, List<(string[], PersonContainer)> possiblyNewPersonDisplayDirectoryNamesAndPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> incorrectIdThenNormalizedRectangleToPersonContainers)
|
||||
private static void SetKeyValuePairs(Configuration configuration, List<PersonContainer> personContainers, Dictionary<long, List<PersonContainer>> personKeyToPersonContainerCollection, Dictionary<string, PersonContainer> personKeyFormattedToPersonContainer, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedRectangleCollection, Dictionary<long, PersonContainer> personKeyToPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedRectangleToPersonContainers, List<(string[], PersonContainer)> possiblyNewPersonDisplayDirectoryNamesAndPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> incorrectIdThenNormalizedRectangleToPersonContainers)
|
||||
{
|
||||
PersonBirthday? personBirthday;
|
||||
PersonContainer[] distinctPersonContainers;
|
||||
@ -300,26 +312,6 @@ internal abstract class MapLogic
|
||||
idThenNormalizedRectangleToPersonContainers[keyValuePair.Key].Add(innerKeyValuePair.Key, distinctPersonContainers);
|
||||
}
|
||||
};
|
||||
if (incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection.Any())
|
||||
{
|
||||
PersonContainer personContainer;
|
||||
foreach ((string personKeyFormatted, int id, int normalizedRectangle) in incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection)
|
||||
{
|
||||
personBirthday = IPersonBirthday.GetPersonBirthday(configuration.PersonBirthdayFormat, personKeyFormatted);
|
||||
if (personBirthday is null)
|
||||
continue;
|
||||
if (!incorrectIdThenNormalizedRectangleToPersonContainerCollection.ContainsKey(id))
|
||||
incorrectIdThenNormalizedRectangleToPersonContainerCollection.Add(id, new());
|
||||
if (!personKeyFormattedToPersonContainer.ContainsKey(personKeyFormatted))
|
||||
{
|
||||
personContainer = new(configuration.PersonCharacters.ToArray(), personBirthday, configuration.MappingDefaultName);
|
||||
personKeyFormattedToPersonContainer.Add(personKeyFormatted, personContainer);
|
||||
}
|
||||
if (!incorrectIdThenNormalizedRectangleToPersonContainerCollection[id].ContainsKey(normalizedRectangle))
|
||||
incorrectIdThenNormalizedRectangleToPersonContainerCollection[id].Add(normalizedRectangle, new());
|
||||
incorrectIdThenNormalizedRectangleToPersonContainerCollection[id][normalizedRectangle].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
|
||||
}
|
||||
}
|
||||
foreach (KeyValuePair<int, Dictionary<int, List<PersonContainer>>> keyValuePair in incorrectIdThenNormalizedRectangleToPersonContainerCollection)
|
||||
{
|
||||
incorrectIdThenNormalizedRectangleToPersonContainers.Add(keyValuePair.Key, new());
|
||||
@ -356,7 +348,7 @@ internal abstract class MapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
private static (int, int) SetCollectionsAndGetUnableToConvertCount(Configuration configuration, long ticks, Dictionary<string, string> personKeyFormattedToNewestPersonKeyFormatted, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedRectangleCollection, List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection, List<(string, string[], string)> collection)
|
||||
private static (int, int) SetCollectionsAndGetUnableToConvertCount(Configuration configuration, long ticks, Dictionary<string, string> personKeyFormattedToNewestPersonKeyFormatted, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedRectangleCollection, List<(string, string[], string)> collection)
|
||||
{
|
||||
int result = 0;
|
||||
int? id;
|
||||
@ -389,10 +381,9 @@ internal abstract class MapLogic
|
||||
else
|
||||
newestPersonKeyFormatted = personKeyFormattedToNewestPersonKeyFormatted[personKeyFormatted];
|
||||
personDisplayDirectoryName = personDisplayDirectoryNames[^1];
|
||||
if (string.IsNullOrEmpty(personDisplayDirectoryName) || personDisplayDirectoryName[0] == '!')
|
||||
incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection.Add(new(newestPersonKeyFormatted, id.Value, normalizedRectangle.Value));
|
||||
else
|
||||
personKeyFormattedIdThenNormalizedRectangleCollection.Add(new(newestPersonKeyFormatted, personDisplayDirectoryNames, id.Value, normalizedRectangle.Value));
|
||||
if (string.IsNullOrEmpty(personDisplayDirectoryName))
|
||||
continue;
|
||||
personKeyFormattedIdThenNormalizedRectangleCollection.Add(new(newestPersonKeyFormatted, personDisplayDirectoryNames, id.Value, normalizedRectangle.Value));
|
||||
}
|
||||
if (duplicateMappedFaceFiles.Any())
|
||||
{
|
||||
@ -429,73 +420,6 @@ internal abstract class MapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
private static void SetPersonKeysRanges(Configuration configuration, long ticks, Dictionary<long, List<long>> personKeyToMinimumDateTimeTicks, Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges)
|
||||
{
|
||||
long lcl;
|
||||
long ucl;
|
||||
long maximum;
|
||||
long minimum;
|
||||
double average;
|
||||
long[] collection;
|
||||
double standardDeviation;
|
||||
List<double> sumCollection;
|
||||
foreach (KeyValuePair<long, List<long>> keyValuePair in personKeyToMinimumDateTimeTicks)
|
||||
{
|
||||
minimum = keyValuePair.Value.Min();
|
||||
if (keyValuePair.Value.Count < configuration.SortingMinimumToUseSigma)
|
||||
{
|
||||
maximum = keyValuePair.Value.Max();
|
||||
personKeyToRanges.Add(keyValuePair.Key, new(new DateTime(minimum).AddDays(-configuration.RangeDaysDeltaTolerance).Ticks, minimum, maximum, new DateTime(maximum).AddDays(configuration.RangeDaysDeltaTolerance).Ticks));
|
||||
}
|
||||
else
|
||||
{
|
||||
collection = (from l in keyValuePair.Value select l - minimum).ToArray();
|
||||
maximum = collection.Max() + minimum;
|
||||
sumCollection = GetSumCollection(collection);
|
||||
if (sumCollection.Count < 2)
|
||||
average = (sumCollection.Sum() / collection.Length) + minimum;
|
||||
else
|
||||
average = (sumCollection.Sum() / collection.Length) + minimum;
|
||||
standardDeviation = GetStandardDeviation(collection, average);
|
||||
ucl = (long)(average + (standardDeviation * Shared.Models.Stateless.IMapLogic.Sigma));
|
||||
lcl = (long)(average - (standardDeviation * Shared.Models.Stateless.IMapLogic.Sigma));
|
||||
if (lcl < 0)
|
||||
lcl = 0;
|
||||
if (ucl > 0)
|
||||
ucl = ticks;
|
||||
personKeyToRanges.Add(keyValuePair.Key, new(lcl, minimum, maximum, ucl));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static void SetPersonTicks(Configuration configuration, long ticks, Mapping[] mappingCollection, Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedRectangleToPersonContainers)
|
||||
{
|
||||
PersonContainer[]? personContainers;
|
||||
Dictionary<int, PersonContainer[]>? keyValuePairs;
|
||||
Dictionary<long, List<long>> personKeyToMinimumDateTimeTicks = new();
|
||||
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
string message = $") {mappingCollection.Length:000} Set Person Ticks - {totalSeconds} total second(s)";
|
||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||
using ProgressBar progressBar = new(mappingCollection.Length, message, options);
|
||||
foreach (Mapping mapping in mappingCollection)
|
||||
{
|
||||
progressBar.Tick();
|
||||
if (!idThenNormalizedRectangleToPersonContainers.TryGetValue(mapping.MappingFromItem.Id, out keyValuePairs))
|
||||
continue;
|
||||
if (!keyValuePairs.TryGetValue(mapping.MappingFromLocation.NormalizedRectangle, out personContainers))
|
||||
continue;
|
||||
foreach (PersonContainer personContainer in personContainers)
|
||||
{
|
||||
if (personContainer.Key is null)
|
||||
continue;
|
||||
if (!personKeyToMinimumDateTimeTicks.ContainsKey(personContainer.Key.Value))
|
||||
personKeyToMinimumDateTimeTicks.Add(personContainer.Key.Value, new());
|
||||
personKeyToMinimumDateTimeTicks[personContainer.Key.Value].Add(mapping.MappingFromItem.MinimumDateTime.Ticks);
|
||||
}
|
||||
}
|
||||
SetPersonKeysRanges(configuration, ticks, personKeyToMinimumDateTimeTicks, personKeyToRanges);
|
||||
}
|
||||
|
||||
private static List<PersonContainer> GetNotMappedPersonContainers(Configuration configuration, List<PersonContainer> personContainers, List<long> personKeys, long[] personKeyCollection)
|
||||
{
|
||||
List<PersonContainer> results = new();
|
||||
@ -592,7 +516,6 @@ internal abstract class MapLogic
|
||||
Dictionary<string, string> personKeyFormattedToNewestPersonKeyFormatted = new();
|
||||
Dictionary<string, PersonContainer> personKeyFormattedToPersonContainer = new();
|
||||
Dictionary<long, List<PersonContainer>> personKeyToPersonContainerCollection = new();
|
||||
List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection = new();
|
||||
List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedRectangleCollection = new();
|
||||
List<(string[], PersonContainer)> possiblyNewPersonDisplayDirectoryNamesAndPersonContainer = new();
|
||||
Dictionary<int, Dictionary<int, PersonContainer[]>> incorrectIdThenNormalizedRectangleToPersonContainers = new();
|
||||
@ -602,8 +525,8 @@ internal abstract class MapLogic
|
||||
string[] ticksDirectories = Directory.GetDirectories(eDistanceContentDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
message = $") {ticksDirectories.Length:000} compile from and clean ticks Director(ies) - B - {totalSeconds} total second(s)";
|
||||
List<(string, string[], string)> collection = DeleteEmptyDirectoriesAndGetCollection(configuration, personKeyFormattedCollection, ticksDirectories, message);
|
||||
(int unableToMatchCount, int duplicateCount) = SetCollectionsAndGetUnableToConvertCount(configuration, ticks, personKeyFormattedToNewestPersonKeyFormatted, personKeyFormattedIdThenNormalizedRectangleCollection, incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection, collection);
|
||||
SetKeyValuePairs(configuration, personContainers, personKeyToPersonContainerCollection, personKeyFormattedToPersonContainer, personKeyFormattedIdThenNormalizedRectangleCollection, incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection, personKeyToPersonContainer, idThenNormalizedRectangleToPersonContainers, possiblyNewPersonDisplayDirectoryNamesAndPersonContainer, incorrectIdThenNormalizedRectangleToPersonContainers);
|
||||
(int unableToMatchCount, int duplicateCount) = SetCollectionsAndGetUnableToConvertCount(configuration, ticks, personKeyFormattedToNewestPersonKeyFormatted, personKeyFormattedIdThenNormalizedRectangleCollection, collection);
|
||||
SetKeyValuePairs(configuration, personContainers, personKeyToPersonContainerCollection, personKeyFormattedToPersonContainer, personKeyFormattedIdThenNormalizedRectangleCollection, personKeyToPersonContainer, idThenNormalizedRectangleToPersonContainers, possiblyNewPersonDisplayDirectoryNamesAndPersonContainer, incorrectIdThenNormalizedRectangleToPersonContainers);
|
||||
totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
message = $") {collection.Count:000} message from ticks Director(ies) - D - {duplicateCount} Duplicate Count {unableToMatchCount} Unable To Match Count / {collection.Count} Collection - {totalSeconds} total second(s)";
|
||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||
@ -736,16 +659,22 @@ internal abstract class MapLogic
|
||||
}
|
||||
}
|
||||
|
||||
internal static List<string> GetDisplayDirectoryAllFiles(PersonContainer[] personContainers)
|
||||
internal static List<(long, string)> GetDisplayDirectoryAllFiles(PersonContainer[] personContainers)
|
||||
{
|
||||
List<string> results = new();
|
||||
List<(long, string)> results = new();
|
||||
List<string> distinct = new();
|
||||
foreach (PersonContainer personContainer in personContainers)
|
||||
{
|
||||
if (personContainer.Key is null)
|
||||
continue;
|
||||
foreach (string displayDirectoryAllFile in personContainer.DisplayDirectoryAllFiles)
|
||||
{
|
||||
if (displayDirectoryAllFile.EndsWith(".json"))
|
||||
continue;
|
||||
results.Add(displayDirectoryAllFile);
|
||||
if (distinct.Contains(displayDirectoryAllFile))
|
||||
continue;
|
||||
distinct.Add(displayDirectoryAllFile);
|
||||
results.Add(new(personContainer.Key.Value, displayDirectoryAllFile));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
|
@ -3,14 +3,14 @@ namespace View_by_Distance.Map.Models.Stateless.Methods;
|
||||
public interface IMapLogic
|
||||
{ // ...
|
||||
|
||||
List<string> TestStatic_GetDisplayDirectoryAllFiles(Shared.Models.PersonContainer[] personContainers) =>
|
||||
List<(long, string)> TestStatic_GetDisplayDirectoryAllFiles(Shared.Models.PersonContainer[] personContainers) =>
|
||||
GetDisplayDirectoryAllFiles(personContainers);
|
||||
static List<string> GetDisplayDirectoryAllFiles(Shared.Models.PersonContainer[] personContainers) =>
|
||||
static List<(long, string)> GetDisplayDirectoryAllFiles(Shared.Models.PersonContainer[] personContainers) =>
|
||||
MapLogic.GetDisplayDirectoryAllFiles(personContainers);
|
||||
|
||||
List<string> TestStatic_DeleteEmptyDirectoriesAndGetMappedFaceFiles(Configuration configuration, Shared.Models.PersonContainer[] personContainers, long ticks, string? a2PeopleContentDirectory, string eDistanceContentDirectory) =>
|
||||
List<(long, string)> TestStatic_DeleteEmptyDirectoriesAndGetMappedFaceFiles(Configuration configuration, Shared.Models.PersonContainer[] personContainers, long ticks, string? a2PeopleContentDirectory, string eDistanceContentDirectory) =>
|
||||
DeleteEmptyDirectoriesAndGetMappedFaceFiles(configuration, personContainers, ticks, a2PeopleContentDirectory, eDistanceContentDirectory);
|
||||
static List<string> DeleteEmptyDirectoriesAndGetMappedFaceFiles(Configuration configuration, Shared.Models.PersonContainer[] personContainers, long ticks, string? a2PeopleContentDirectory, string eDistanceContentDirectory) =>
|
||||
static List<(long, string)> DeleteEmptyDirectoriesAndGetMappedFaceFiles(Configuration configuration, Shared.Models.PersonContainer[] personContainers, long ticks, string? a2PeopleContentDirectory, string eDistanceContentDirectory) =>
|
||||
MapLogic.DeleteEmptyDirectoriesAndGetMappedFaceFiles(configuration, personContainers, ticks, a2PeopleContentDirectory, eDistanceContentDirectory);
|
||||
|
||||
}
|
Reference in New Issue
Block a user