public SocketOperationsImpl(EntityCache <CustomSocket> socketCache, EntityCache <SocketGroup> socketGroupCache, SocketExchange.SocketExchangeClient client, SocketOperationsOptions options) { _client = client; _socketCache = socketCache; _socketGroupCache = socketGroupCache; _options = options; var sockets = _socketCache.GetAll(); var productionRulesGenerator = new ProductionRulesGenerator(); var logicRulesGenerator = new LogicRulesGenerator(); var fuzzyRulesGenerator = new FuzzyRulesGenerator(); var neuralRulesGenerator = new NeuralRulesGenerator(); // Продукционный вывод var rulesGraph = productionRulesGenerator.GenerateRules(sockets); // Логический вывод var logicRules = logicRulesGenerator.GenerateRules(sockets); // Нечеткий вывод var fuzzyDomains = fuzzyRulesGenerator.GetFuzzyDomains(sockets); var fuzzyFacts = fuzzyRulesGenerator.GetFuzzyFacts(fuzzyDomains, sockets); // Нейро-нечеткий вывод var neuralNetwork = neuralRulesGenerator.GetNeuralNetwork(sockets); var processorOptions = new ProcessorOptions { Debug = _options.Debug }; _productionProcessor = new ProductionProcessor(rulesGraph, processorOptions); _logicProcessor = new LogicProcessor(logicRules, processorOptions); _fuzzyProcessor = new FuzzyProcessor(fuzzyDomains, fuzzyFacts, processorOptions); _neuralProcessor = new NeuralProcessor(neuralNetwork, processorOptions); }
/// <summary> /// Calculate score, sort and visualize rtf field. Upper/Lower cases are not considered. /// </summary> /// <param name="searchPattern">The pattern the search was for</param> /// <param name="fuzzyAlgo"></param> public static void CalulateAndSort(string searchPattern, FuzzyAlgo fuzzyAlgo = FuzzyAlgo.PhraseSimilarity) { switch (fuzzyAlgo) { case FuzzyAlgo.LongestCommonSubsequences: LongestCommonSubsequenceExtensions(searchPattern); break; case FuzzyAlgo.PhraseSimilarity: var processor = new FuzzyProcessor(); foreach (SearchItem item in _staticAllSearches) { item.Score = processor.CalculateRank(item.Name, searchPattern); } // sort list according to score of each line (score against pattern) _staticAllSearches = _staticAllSearches.OrderByDescending(a => a.Score).ToList(); // Algorithm without valuable result DataTable dt = _staticAllSearches.ToDataTable(); if (_staticAllSearches.Count > 0 && _staticAllSearches[0].Score < 0.1) { LongestCommonSubsequenceExtensions(searchPattern); } //var auto completion = new Processor(_staticAllSearches); //var lst = autocompletion.Search(searchPattern); break; } }
public FuzzyRulesProcessorTest(ITestOutputHelper outputHelper) { var generator = new FuzzyRulesGenerator(); var sockets = TestData.GetSockets(); var fuzzyDomains = generator.GetFuzzyDomains(sockets); var fuzzyFacts = generator.GetFuzzyFacts(fuzzyDomains, sockets); _output = outputHelper; _processor = new FuzzyProcessor(fuzzyDomains, fuzzyFacts, new ProcessorOptions { Debug = false }); }