Person Require People File
This commit is contained in:
@ -24,17 +24,17 @@ public class MapLogic
|
||||
private readonly long _Ticks;
|
||||
private const int _Mapping = 1;
|
||||
private const int _Sorting = 2;
|
||||
private Configuration? _Configuration;
|
||||
private readonly Serilog.ILogger? _Log;
|
||||
private const int _ForceSingleImage = 3;
|
||||
private readonly int _MaxDegreeOfParallelism;
|
||||
private readonly Configuration? _Configuration;
|
||||
private readonly string _FacesFilenameExtension;
|
||||
private readonly string _ResizeFilenameExtension;
|
||||
private readonly string _FacePartsFilenameExtension;
|
||||
private readonly string _FacesHiddenFilenameExtension;
|
||||
private readonly string _ZPropertyHolderContentTicksDirectory;
|
||||
private readonly string _EDistanceContentTicksDirectory;
|
||||
|
||||
public MapLogic(int maxDegreeOfParallelism, Property.Models.Configuration propertyConfiguration, string resizeFilenameExtension, string facesFilenameExtension, string facesHiddenFilenameExtension, string facePartsFilenameExtension, long ticks, Person[] people, string peopleDateGroupDirectory, string zResultsFullGroupDirectory, Configuration? configuration, List<Face> distinctFilteredFaces, Shared.Models.Methods.IFaceDistance? distance)
|
||||
public MapLogic(int maxDegreeOfParallelism, Property.Models.Configuration propertyConfiguration, Configuration? configuration, string resizeFilenameExtension, string facesFilenameExtension, string facesHiddenFilenameExtension, string facePartsFilenameExtension, long ticks, Person[] people, string a2PeopleDateGroupDirectory, string eResultsFullGroupDirectory, List<Face> distinctFilteredFaces, Shared.Models.Methods.IFaceDistance? distance)
|
||||
{
|
||||
_Ticks = ticks;
|
||||
_PersonKeysRanges = new();
|
||||
@ -55,30 +55,32 @@ public class MapLogic
|
||||
string[] files;
|
||||
string fullPath;
|
||||
const int zero = 0;
|
||||
List<long> notMappedTicks = new();
|
||||
List<double> skipCollection = new();
|
||||
Dictionary<int, int[]>? keyValuePairs;
|
||||
List<long> notMappedPersonKeys = new();
|
||||
List<KeyValuePair<int, int[]>>? collection;
|
||||
Dictionary<int, int[]> indicesFromNew = new();
|
||||
string a2PeopleContentDirectory = Path.Combine(a2PeopleDateGroupDirectory, "()");
|
||||
string eDistanceContentDirectory = Path.Combine(eResultsFullGroupDirectory, "()");
|
||||
Dictionary<long, (string, int?, PersonBirthday[], long)> peopleKeyValuePairs = new();
|
||||
string zPropertyHolderContentDirectory = Path.Combine(zResultsFullGroupDirectory, "()");
|
||||
string? rootDirectoryParent = Path.GetDirectoryName(propertyConfiguration.RootDirectory);
|
||||
string eDistanceContentTicksDirectory = Path.Combine(eDistanceContentDirectory, $"({ticks})");
|
||||
string a2PeopleContentKnownPeopleDirectory = Path.Combine(a2PeopleContentDirectory, "(KnownPeople)");
|
||||
Dictionary<int, Dictionary<int, PersonBirthday[]>> idThenNormalizedPixelPercentageKeyValuePairs = new();
|
||||
string zPropertyHolderContentTicksDirectory = Path.Combine(zPropertyHolderContentDirectory, $"({ticks})");
|
||||
string zPropertyHolderPeopleContentDirectory = Path.Combine(peopleDateGroupDirectory, "()", "(KnownPeople)");
|
||||
Dictionary<int, Dictionary<int, PersonBirthday[]>> incorrectIdThenNormalizedPixelPercentageKeyValuePairs = new();
|
||||
for (int i = 1; i < 5; i++)
|
||||
_ = IPath.DeleteEmptyDirectories(zPropertyHolderContentDirectory);
|
||||
_ = IPath.DeleteEmptyDirectories(zPropertyHolderContentDirectory);
|
||||
_ = IPath.DeleteEmptyDirectories(eDistanceContentDirectory);
|
||||
_ = IPath.DeleteEmptyDirectories(eDistanceContentDirectory);
|
||||
if (string.IsNullOrEmpty(rootDirectoryParent))
|
||||
throw new NullReferenceException(nameof(rootDirectoryParent));
|
||||
if (!Directory.Exists(zPropertyHolderContentDirectory))
|
||||
_ = Directory.CreateDirectory(zPropertyHolderContentDirectory);
|
||||
if (!Directory.Exists(zPropertyHolderPeopleContentDirectory))
|
||||
_ = Directory.CreateDirectory(zPropertyHolderPeopleContentDirectory);
|
||||
Stateless.ByRef.Set(propertyConfiguration, configuration, ticks, _ResizeFilenameExtension, people, zPropertyHolderContentDirectory, zPropertyHolderPeopleContentDirectory, distinctFilteredFaces, distance, skipCollection, peopleKeyValuePairs, notMappedTicks, idThenNormalizedPixelPercentageKeyValuePairs, incorrectIdThenNormalizedPixelPercentageKeyValuePairs);
|
||||
if (!Directory.Exists(zPropertyHolderContentTicksDirectory))
|
||||
_ = Directory.CreateDirectory(zPropertyHolderContentTicksDirectory);
|
||||
if (!Directory.Exists(eDistanceContentDirectory))
|
||||
_ = Directory.CreateDirectory(eDistanceContentDirectory);
|
||||
if (!Directory.Exists(a2PeopleContentKnownPeopleDirectory))
|
||||
_ = Directory.CreateDirectory(a2PeopleContentKnownPeopleDirectory);
|
||||
if (configuration is not null)
|
||||
Stateless.ByRef.Set(propertyConfiguration, configuration, ticks, _ResizeFilenameExtension, people, eDistanceContentDirectory, a2PeopleContentDirectory, distinctFilteredFaces, distance, skipCollection, peopleKeyValuePairs, notMappedPersonKeys, idThenNormalizedPixelPercentageKeyValuePairs, incorrectIdThenNormalizedPixelPercentageKeyValuePairs);
|
||||
if (!Directory.Exists(eDistanceContentTicksDirectory))
|
||||
_ = Directory.CreateDirectory(eDistanceContentTicksDirectory);
|
||||
files = Directory.GetFiles(rootDirectoryParent, "*keyValuePairs-6*.json", SearchOption.TopDirectoryOnly);
|
||||
if (files.Length != 1)
|
||||
keyValuePairs = new();
|
||||
@ -110,19 +112,19 @@ public class MapLogic
|
||||
_KeyValuePairs = keyValuePairs;
|
||||
_IndicesFromNew = indicesFromNew;
|
||||
_SkipCollection = skipCollection;
|
||||
_NotMappedPersonKeys = notMappedTicks;
|
||||
_NotMappedPersonKeys = notMappedPersonKeys;
|
||||
_PeopleKeyValuePairs = peopleKeyValuePairs;
|
||||
_ZPropertyHolderContentTicksDirectory = zPropertyHolderContentTicksDirectory;
|
||||
_EDistanceContentTicksDirectory = eDistanceContentTicksDirectory;
|
||||
_IdThenNormalizedPixelPercentageKeyValuePairs = idThenNormalizedPixelPercentageKeyValuePairs;
|
||||
_IncorrectIdThenNormalizedPixelPercentageKeyValuePairs = incorrectIdThenNormalizedPixelPercentageKeyValuePairs;
|
||||
}
|
||||
|
||||
public MapLogic(int maxDegreeOfParallelism, Property.Models.Configuration propertyConfiguration, string resizeFilenameExtension, string facesFilenameExtension, string facesHiddenFilenameExtension, string facePartsFilenameExtension, long ticks, Person[] people, string peopleDateGroupDirectory, string zResultsFullGroupDirectory) :
|
||||
this(maxDegreeOfParallelism, propertyConfiguration, resizeFilenameExtension, facesFilenameExtension, facesHiddenFilenameExtension, facePartsFilenameExtension, ticks, people, peopleDateGroupDirectory, zResultsFullGroupDirectory, null, new(), null)
|
||||
public MapLogic(int maxDegreeOfParallelism, Property.Models.Configuration propertyConfiguration, Configuration? configuration, string resizeFilenameExtension, string facesFilenameExtension, string facesHiddenFilenameExtension, string facePartsFilenameExtension, long ticks, Person[] people, string peopleDateGroupDirectory, string zResultsFullGroupDirectory) :
|
||||
this(maxDegreeOfParallelism, propertyConfiguration, configuration, resizeFilenameExtension, facesFilenameExtension, facesHiddenFilenameExtension, facePartsFilenameExtension, ticks, people, peopleDateGroupDirectory, zResultsFullGroupDirectory, new(), null)
|
||||
{ }
|
||||
|
||||
public MapLogic(int maxDegreeOfParallelism, Property.Models.Configuration propertyConfiguration, string outputExtension, long ticks, Person[] people, string peopleDateGroupDirectory, string zResultsFullGroupDirectory) :
|
||||
this(maxDegreeOfParallelism, propertyConfiguration, outputExtension, outputExtension, outputExtension, outputExtension, ticks, people, peopleDateGroupDirectory, zResultsFullGroupDirectory, null, new(), null)
|
||||
public MapLogic(int maxDegreeOfParallelism, Property.Models.Configuration propertyConfiguration, Configuration? configuration, string outputExtension, long ticks, Person[] people, string peopleDateGroupDirectory, string zResultsFullGroupDirectory) :
|
||||
this(maxDegreeOfParallelism, propertyConfiguration, configuration, outputExtension, outputExtension, outputExtension, outputExtension, ticks, people, peopleDateGroupDirectory, zResultsFullGroupDirectory, new(), null)
|
||||
{ }
|
||||
|
||||
public override string ToString()
|
||||
@ -131,8 +133,6 @@ public class MapLogic
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Update(Configuration configuration) => _Configuration = configuration;
|
||||
|
||||
public bool Skip(double deterministicHashCodeKey) => _SkipCollection.Contains(deterministicHashCodeKey);
|
||||
|
||||
private List<(long, long, long, long)> GetPersonKeysRangesCollection(PersonBirthday[] personBirthdays)
|
||||
@ -398,7 +398,7 @@ public class MapLogic
|
||||
{
|
||||
personBirthday = IPersonBirthday.GetPersonBirthday(personKey);
|
||||
personKeyFormatted = IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, personBirthday);
|
||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"{facePopulatedKey}NotMapped", personKeyFormatted, propertyConfiguration.ResultAllInOne);
|
||||
directory = Path.Combine(_EDistanceContentTicksDirectory, $"{facePopulatedKey}NotMapped", personKeyFormatted, propertyConfiguration.ResultAllInOne);
|
||||
saveContainer = new(directory);
|
||||
saveContainers.Add(saveContainer);
|
||||
}
|
||||
@ -438,7 +438,7 @@ public class MapLogic
|
||||
if (!_IdThenNormalizedPixelPercentageKeyValuePairs.ContainsKey(face.Mapping.MappingFromItem.Id))
|
||||
{
|
||||
personKey = null;
|
||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"Unnamed{relativePath[2..]}");
|
||||
directory = Path.Combine(_EDistanceContentTicksDirectory, $"Unnamed{relativePath[2..]}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -451,7 +451,7 @@ public class MapLogic
|
||||
if (personBirthdays.Length != 1)
|
||||
{
|
||||
personKey = null;
|
||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"Not Supported{relativePath[2..]}", subDirectoryName);
|
||||
directory = Path.Combine(_EDistanceContentTicksDirectory, $"Not Supported{relativePath[2..]}", subDirectoryName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -469,11 +469,11 @@ public class MapLogic
|
||||
}
|
||||
}
|
||||
personKeyFormatted = IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, personBirthday);
|
||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, "Shortcuts", personKeyFormatted, subDirectoryName);
|
||||
directory = Path.Combine(_EDistanceContentTicksDirectory, "Shortcuts", personKeyFormatted, subDirectoryName);
|
||||
if (face.FaceEncoding is not null && face.Location?.NormalizedPixelPercentage is not null)
|
||||
copyDirectory = Path.Combine(_ZPropertyHolderContentTicksDirectory, "Images", personKeyFormatted, subDirectoryName);
|
||||
copyDirectory = Path.Combine(_EDistanceContentTicksDirectory, "Images", personKeyFormatted, subDirectoryName);
|
||||
else
|
||||
copyDirectory = Path.Combine(_ZPropertyHolderContentTicksDirectory, "ImagesBut", personKeyFormatted, subDirectoryName);
|
||||
copyDirectory = Path.Combine(_EDistanceContentTicksDirectory, "ImagesBut", personKeyFormatted, subDirectoryName);
|
||||
copyFileName = Path.Combine(copyDirectory, $"{face.Mapping.MappingFromItem.Id}{face.Mapping.MappingFromItem.ResizedFileHolder.ExtensionLowered}");
|
||||
}
|
||||
}
|
||||
@ -624,7 +624,7 @@ public class MapLogic
|
||||
_ => throw new NotImplementedException()
|
||||
};
|
||||
}
|
||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, by[1..], personKeyFormatted, face.Mapping.MappingFromPerson.SegmentB);
|
||||
directory = Path.Combine(_EDistanceContentTicksDirectory, by[1..], personKeyFormatted, face.Mapping.MappingFromPerson.SegmentB);
|
||||
if (!keyValuePairs.ContainsKey(directory))
|
||||
keyValuePairs.Add(directory, 0);
|
||||
keyValuePairs[directory]++;
|
||||
|
@ -8,7 +8,7 @@ namespace View_by_Distance.Map.Models.Stateless;
|
||||
public class ByRef
|
||||
{
|
||||
|
||||
private static void SetOther(Property.Models.Configuration propertyConfiguration, Configuration configuration, string resizeFilenameExtension, Person[] people, string deterministicHashCodePeopleDirectory, List<double> skipCollection, Dictionary<long, long> personKeyAliases, List<(string, int?, PersonBirthday[], long)> peopleCollection)
|
||||
private static void SetOther(Property.Models.Configuration propertyConfiguration, Configuration configuration, string resizeFilenameExtension, Person[] people, string a2PeopleContentDirectory, List<double> skipCollection, Dictionary<long, long> personKeyAliases, List<(string, int?, PersonBirthday[], long)> peopleCollection)
|
||||
{
|
||||
long pK;
|
||||
string json;
|
||||
@ -37,7 +37,7 @@ public class ByRef
|
||||
break;
|
||||
personKeyValuePairs.Add(personKeyFormatted, person);
|
||||
}
|
||||
string[] groupDirectories = Directory.GetDirectories(deterministicHashCodePeopleDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
string[] groupDirectories = Directory.GetDirectories(a2PeopleContentDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
foreach (string groupDirectory in groupDirectories)
|
||||
{
|
||||
groupDirectoryName = Path.GetFileName(groupDirectory);
|
||||
@ -138,7 +138,7 @@ public class ByRef
|
||||
}
|
||||
}
|
||||
|
||||
internal static List<(string, char, string, int?, int?, List<Face>?)> DeleteEmptyDirectoriesAndGetCollection(Configuration configuration, long ticks, string zPropertyHolderContentDirectory, Dictionary<int, List<Face>> keyValuePairs)
|
||||
internal static List<(string, char, string, int?, int?, List<Face>?)> DeleteEmptyDirectoriesAndGetCollection(Configuration configuration, long ticks, string eDistanceContentDirectory, Dictionary<int, List<Face>> keyValuePairs)
|
||||
{
|
||||
List<(string, char, string, int?, int?, List<Face>?)> results = new();
|
||||
int? id;
|
||||
@ -156,7 +156,7 @@ public class ByRef
|
||||
string? personFirstInitialDirectory;
|
||||
bool keyValuePairsAny = keyValuePairs.Any();
|
||||
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
string[] ticksDirectories = Directory.GetDirectories(zPropertyHolderContentDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
string[] ticksDirectories = Directory.GetDirectories(eDistanceContentDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
string message = $") {ticksDirectories.Length:000} ticks Director(ies) - A - {totalSeconds} total second(s)";
|
||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||
using ProgressBar progressBar = new(ticksDirectories.Length, message, options);
|
||||
@ -397,17 +397,19 @@ public class ByRef
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static void Set(Property.Models.Configuration propertyConfiguration, Configuration? configuration, long ticks, string resizeFilenameExtension, Person[] people, string zPropertyHolderContentDirectory, string zPropertyHolderPeopleContentDirectory, List<Face> distinctFilteredFaces, Shared.Models.Methods.IFaceDistance? distance, List<double> skipCollection, Dictionary<long, (string DisplayDirectoryName, int? ApproximateYears, PersonBirthday[] PersonBirthdays, long PersonKey)> peopleKeyValuePairs, List<long> notMappedPersonKeys, Dictionary<int, Dictionary<int, PersonBirthday[]>> idThenNormalizedPixelPercentageKeyValuePairs, Dictionary<int, Dictionary<int, PersonBirthday[]>> incorrectIdThenNormalizedPixelPercentageKeyValuePairs)
|
||||
internal static void Set(Property.Models.Configuration propertyConfiguration, Configuration? configuration, long ticks, string resizeFilenameExtension, Person[] people, string eDistanceContentDirectory, string a2PeopleContentDirectory, List<Face> distinctFilteredFaces, Shared.Models.Methods.IFaceDistance? distance, List<double> skipCollection, Dictionary<long, (string DisplayDirectoryName, int? ApproximateYears, PersonBirthday[] PersonBirthdays, long PersonKey)> peopleKeyValuePairs, List<long> notMappedPersonKeys, Dictionary<int, Dictionary<int, PersonBirthday[]>> idThenNormalizedPixelPercentageKeyValuePairs, Dictionary<int, Dictionary<int, PersonBirthday[]>> incorrectIdThenNormalizedPixelPercentageKeyValuePairs)
|
||||
{
|
||||
if (configuration is null)
|
||||
throw new NullReferenceException(nameof(configuration));
|
||||
Dictionary<long, long> personKeyAliases = new();
|
||||
Dictionary<int, List<Face>> keyValuePairs = new();
|
||||
List<long> notMappedAndNotNamedPersonKeys = new();
|
||||
List<long> notMappedAndWithNamedPersonKeys = new();
|
||||
List<long> idThenNormalizedPixelPercentagePersonKeys = new();
|
||||
List<(string, int?, PersonBirthday[], long)> peopleCollection = new();
|
||||
List<(PersonBirthday, int, int)> idThenNormalizedPixelPercentageCollection = new();
|
||||
List<(PersonBirthday, int, int)> incorrectIdThenNormalizedPixelPercentageCollection = new();
|
||||
SetOther(propertyConfiguration, configuration, resizeFilenameExtension, people, zPropertyHolderPeopleContentDirectory, skipCollection, personKeyAliases, peopleCollection);
|
||||
SetOther(propertyConfiguration, configuration, resizeFilenameExtension, people, a2PeopleContentDirectory, skipCollection, personKeyAliases, peopleCollection);
|
||||
foreach (Face face in distinctFilteredFaces)
|
||||
{
|
||||
if (face.FaceEncoding is null || face.Location?.NormalizedPixelPercentage is null)
|
||||
@ -418,7 +420,7 @@ public class ByRef
|
||||
keyValuePairs.Add(face.Mapping.MappingFromItem.Id, new());
|
||||
keyValuePairs[face.Mapping.MappingFromItem.Id].Add(face);
|
||||
}
|
||||
List<(string, char, string, int?, int?, List<Face>?)> collection = DeleteEmptyDirectoriesAndGetCollection(configuration, ticks, zPropertyHolderContentDirectory, keyValuePairs);
|
||||
List<(string, char, string, int?, int?, List<Face>?)> collection = DeleteEmptyDirectoriesAndGetCollection(configuration, ticks, eDistanceContentDirectory, keyValuePairs);
|
||||
int unableToMatchCount = SetCollectionsAndGet(configuration, ticks, distance, personKeyAliases, idThenNormalizedPixelPercentageCollection, incorrectIdThenNormalizedPixelPercentageCollection, collection);
|
||||
SetKeyValuePairs(configuration, idThenNormalizedPixelPercentageCollection, incorrectIdThenNormalizedPixelPercentageCollection, idThenNormalizedPixelPercentageKeyValuePairs, incorrectIdThenNormalizedPixelPercentageKeyValuePairs);
|
||||
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
@ -442,12 +444,18 @@ public class ByRef
|
||||
continue;
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
if (!idThenNormalizedPixelPercentagePersonKeys.Contains(personKey))
|
||||
notMappedPersonKeys.Add(personKey);
|
||||
else
|
||||
if (idThenNormalizedPixelPercentagePersonKeys.Contains(personKey))
|
||||
peopleKeyValuePairs.Add(personKey, new(displayDirectoryName, approximateYears, personBirthdays, personKey));
|
||||
else if (string.IsNullOrEmpty(displayDirectoryName) || displayDirectoryName == propertyConfiguration.ResultAllInOne)
|
||||
notMappedAndNotNamedPersonKeys.Add(personKey);
|
||||
else
|
||||
notMappedAndWithNamedPersonKeys.Add(personKey);
|
||||
}
|
||||
}
|
||||
notMappedAndNotNamedPersonKeys.Sort();
|
||||
notMappedAndWithNamedPersonKeys.Sort();
|
||||
notMappedPersonKeys.AddRange(notMappedAndNotNamedPersonKeys);
|
||||
notMappedPersonKeys.AddRange(notMappedAndWithNamedPersonKeys);
|
||||
if (idThenNormalizedPixelPercentagePersonKeys.Any())
|
||||
{
|
||||
int? approximateYears = null;
|
||||
|
Reference in New Issue
Block a user