Please write all the text in English ! {{ :projet:warm_fuzzy_logic_member_function.gif?320|}} ===== Fuzzy Contexter ====== ====== New Tools for Capture and Analysis of Digital Context and Fuzzy Logic ====== == Group Composition : == * Olivier Fauvel-Jaeger * Anthony Soulier * Benjamin Vella * Michel Vedrine == Report : == [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/Rapport.pdf|.pdf]] == Slides of the presentation : == [[https://docs.google.com/presentation/d/1al2Fx3jnoaaX9XSMcYd8bwKx8YAJzqjnYvFKOP_7zXo|Google Presentation]] | [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/Pr%C3%A9sentation.pdf|.pdf]] == Source Code (Temporary) == http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/ ==== Software Specifications : ==== === List of new Beans === == Bean == * purpose of the bean * input interface (exposed methods) * output interface (emitted events) * internal algorithm or simply used librairies (and dependencies) * links on the documentation of such librairies * link to the binary code other .Net (dll of the bean and other requested librairies) * link to the VS solution with C# source code to compile the bean == Bean OutlookMailsChecker == * purpose of the bean \\ This bean is in charge of the extraction of Outlook email. * input interface (exposed methods) * void ReadAllReceivedMailsToJsonString \\ read all e-mails in the inbox and send them on a JSON string by event ( NewReceivedMessagesJsonString ) * void ReadAllSentMailsToJsonString \\read all e-mails in the outbox and send them on a JSON string by event ( NewSentMessagesJsonString ) * void ReadMailReceivedFormDateTimeToJsonString(DateTime d) \\ read all e-mails in the inbox from the date “d” and send them on a JSON string by event ( NewReceivedMessagesJsonString ) * void ReadSentMailFormDateTimeToJsonString(DateTime d) \\ read all e-mails in the outbox from the date “d” and send them on a JSON string by event ( NewSentMessagesJsonString ) * void ReadMailReceivedFormDateTimeToJsonString() \\ read all e-mails in the inbox from the attribute “ReceivedOnDate” and send them on a JSON string by event ( NewReceivedMessagesJsonString ) * void ReadSentMailFormDateTimeToJsonString() \\ read all e-mails in the outbox from the attribute “SentOnDate” and send them on a JSON string by event ( NewSentMessagesJsonString ) * void AllGroupsOfContact() \\ get all groups of contacts in the outlook’s adressbook and send them by event ( GroupsUpdateEvent ) * void AllEmailsAddress() \\ get all e-mail address in the outlook’s adressbook and send them by event ( ContactsUpdateEvent ) * void ContactsForGroup(List nameOfGroups) \\ get all email address in the outlook’s adressbook belong to the given groups and send them by event ( ContactsUpdateEvent ) * void GroupsForEMail(string email) :\\get all groups for a given email address and send them by event ( ContactsUpdateEvent ) * output interface (emitted events) * NewReceivedMessagesJsonString(string json) \\ event when new e-mails are received (automatically sent when the user received a new e-mail in Outlook). * NewSentMessagesJsonString(string json) \\ event when new e-mails are sent (automatically sent when the user sent a new e-mail in Outlook). * GroupsUpdateEvent \\ event when the group of contacts are update. * ContactsUpdateEvent \\ event when the contacts are update. * Used librairies * Microsoft.Office.Interop.Outlook (API provide by Microsoft, Outlook must be installed [[http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.aspx|Outlook API]] * link to the binary code other .Net (dll of the bean and other requested librairies) * link to the VS solution with C# source code to compile the bean == Bean Core == * Purpose:\\ This bean is in charge of the fuzzification of the input values and apply logic rules on the results. First it must be initialized with linguistic variables. * Input interface: * InitializeSystem(List lingVars, List varsToEval, string rulesFilePath)\\ This method needs AForge.Fuzzy objects (LinguisticVariable) and some other informations to initialize the machine for the given scenario. * Evaluate(Dictionary varsToSet)\\ The method called when a fuzzy evaluation is needed on the system. * Output interface:\\ * FireRulesAForgeResultEvent(List fuzzyOutputs)\\ This event carry the results from the evaluation in the form of AForge.Fuzzy objects. This is useful if another Bean using AForge.Fuzzy objects grab this event right after the evaluation (an AForge defuzzifier for example). * FireRulesJSONResultEvent(string json)\\ This event carry the results from the evaluation in the form of a JSON string. Useful for compatibilities reasons with others Beans/Services. * Internal algorithm:\\ Most of the heavy lifting is left to the already functional Fuzzy library from the AForge.NET framework. * Libraries used: * AForge.NET http://www.aforgenet.com/framework/ \\ Fuzzy library only. * NewtonSoft http://james.newtonking.com/json \\ For JSON. * VS Project: [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/sln/MoteurLogiqueFloue/|.csproj]] * DLLs: * Bean: [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/sln/lib/FuzzyLogic/MoteurLogiqueFloue.dll|Whole Engine]] * Libraries: [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/sln/lib/FuzzyLogic/Newtonsoft.Json.dll|JSON]] | [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/sln/lib/FuzzyLogic/AForge.dll|AForge]] + [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/sln/lib/FuzzyLogic/AForge.Fuzzy.dll|AForge.Fuzzy]] == Bean Configurator == * Purpose:\\ This bean is in charge of the initialization of the Core Bean. It reads through one configuration file given by the user. * Input interface:\\ * ReadConfig()\\ This method reads the configuration file and create fuzzy objects (linguistic variables, fuzzy sets, ...). * Output interface:\\ * FireConfigCompletedEvent(List lingVars, List varsToEval, string rulesFilePath)\\ Event carrying the fuzzy objects and the informations needed by the machine for its initialization. * Internal algorithm:\\ The ReadConfig() method reads line by line the configuration file and constructs objects needed by the machine. * Libraries used:\\ * AForge.NET http://www.aforgenet.com/framework/ \\ Fuzzy library only. * VS Project: [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/sln/MoteurLogiqueFloue/|.csproj]] * DLLs: * Bean: [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/sln/lib/FuzzyLogic/MoteurLogiqueFloue.dll|Whole Engine]] * Libraries: [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/sln/lib/FuzzyLogic/AForge.dll|AForge]] + [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/sln/lib/FuzzyLogic/AForge.Fuzzy.dll|AForge.Fuzzy]] == Bean CentroidDefuzzifier == * Purpose:\\ This bean is in charge of the defuzzification of the Core Bean output. The result is a list of numerical values calculated with the centroid method. * Input interface:\\ * Defuzzy(List fuzzyOutputs)\\ Defuzzify a list of outputs from the Core Bean. * Output interface:\\ * FireCentroidDefuzzyCompletedEvent(Dictionary d)\\ Return the result in the form of a dictionary containing the name of the linguistic variable associated with the numeric value. * FireJSONCentroidDefuzzyCompletedEvent(string json)\\ Return the previous result in the form of a JSON. * Internal algorithm:\\ Each FuzzyOutput is processed by a centroid defuzzifier (an AForge object). * Libraries used:\\ * AForge.NET http://www.aforgenet.com/framework/ \\ Fuzzy library only. * NewtonSoft http://james.newtonking.com/json \\ For JSON. * VS Project: [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/sln/MoteurLogiqueFloue/|.csproj]] * DLLs: * Bean: [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/sln/lib/FuzzyLogic/MoteurLogiqueFloue.dll|Whole Engine]] * Libraries: [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/sln/lib/FuzzyLogic/Newtonsoft.Json.dll|JSON]] | [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/sln/lib/FuzzyLogic/AForge.dll|AForge]] + [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/sln/lib/FuzzyLogic/AForge.Fuzzy.dll|AForge.Fuzzy]] == Bean MaxDefuzzifier == * Purpose:\\ This bean is in charge of the defuzzification of the Core Bean output. The result is a list of numerical values calculated with the max method. * Input interface:\\ * Defuzzy(List fuzzyOutputs)\\ Defuzzify a list of outputs from the Core Bean. * Output interface:\\ * FireMaxDefuzzyCompletedEvent(Dictionary d)\\ Return the result in the form of a dictionary containing the name of the linguistic variable associated with the name of the fuzzy set with the maximum strength. * FireJSONMaxDefuzzyCompletedEvent(string json)\\ Return the previous result in the form of a JSON. * Internal algorithm:\\ In each FuzzyOutput is extracted the name of the fuzzy set with the highest strength. And the list is returned. * Libraries used:\\ * AForge.NET http://www.aforgenet.com/framework/ \\ Fuzzy library only. * NewtonSoft http://james.newtonking.com/json \\ For JSON. * VS Project: [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/sln/MoteurLogiqueFloue/|.csproj]] * DLLs: * Bean: [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/sln/lib/FuzzyLogic/MoteurLogiqueFloue.dll|Whole Engine]] * Libraries: [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/sln/lib/FuzzyLogic/Newtonsoft.Json.dll|JSON]] | [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/sln/lib/FuzzyLogic/AForge.dll|AForge]] + [[http://users.polytech.unice.fr/~vedrine/projet_janvier_si4/sln/lib/FuzzyLogic/AForge.Fuzzy.dll|AForge.Fuzzy]] == Bean Expediteur == * purpose of the bean \\ This bean is very specific to the logic core : its purpose is to create the group curves for the fuzzification: a mail sender is part of some groups, and the fuzzy core needs curves to find those groups. For n groups, there are 2^n - 1 possible ways to group someone. We had to let the machine do that for us. * input interface (exposed methods) * public void Initialisation(List groupes) \\ Fix the numbers we will have to use to create curves : Memorize the groups, set the number of group possibilities... * public void GetGroups(List groupes) \\ This method is called by Initialisation. We can call it directly if the function curves have already been created. If they don't, this function creates the curves and write them in a configuration file. * public void GetFloat(string json) \\ Given a list of groups in a property of a json object, find (and send) the correct abscissa. * output interface (emitted events) * NeedGroups() \\ Event sent at the initialization, when this bean needs all the groups to create curves and/or to set the important numbers for the algorithm. * ValeurExpediteur(n) \\ Event sent after having found the abscissa of a sender. The argument is a JObject containing the value. * internal algorithm or simply used librairies (and dependencies) * To set the curves and find the abscissa of a mail sender (thanks to its groups), the algorithm uses the binary count : 00000001 means "is only in the first group", 001001 means "in the first and the fourth", ... So we just had to add 1 from 0 to 2^n - 1 to access every group value possibilities. * Json.Net : http://james.newtonking.com/json * links on the documentation of such librairies * link to the binary code other .Net (dll of the bean and other requested librairies) * link to the VS solution with C# source code to compile the bean == Bean JSONToCSV == * Purpose:\\ This bean transform a json string or a json file to csv file. The json must begin by an array. * input interface (exposed methods) * void ConvertJsonFileToCSV(string pathToJson, string pathToCSV) * void ConvertJsonStringToCSV(string json, string pathToCSV) * void ConvertJsonFileToCSV(string pathToJson) * void ConvertJsonFileToCSV() * void ConvertJsonStringToCSV(string json) All of these methods convert a json file or a json string to a CSV file, if the path of the json file or the cdv file are not in parameter the methods use the attribute “PathCSV” for the CSV file and the attribute “PathToJson” for the json file.\\ You can also set the CSV’s delimiter with the attribute “Delimiter” and the attribute “AppendCSVFile“ allow you to append or replace the csv file if it exist already . * output interface (emitted events) * CSVFileCreate(string path) \\ event sent when the csv file is created. * internal algorithm or simply used librairies (and dependencies) * Json.Net : http://james.newtonking.com/json * link to the binary code other .Net (dll of the bean and other requested librairies) * link to the VS solution with C# source code to compile the bean == Bean Json2Dictionary == * Purpose:\\ This bean transform a json string or a json file into a Dictionary. The json must begin by an array or an object. This bean has been created to make easier the manipulation of specific information like a string and its float value. * input interface (exposed method) * public void GetJSon(string JSon) This method takes in argument a string, parse the json inside, and analyze each object. The analyze constructs a Dictionary for each object, and send it via an event. * output interface (emitted events) * InformationsToTreat(data) \\ event sent when a new Dictionary has been created. * internal algorithm or simply used librairies (and dependencies) * Json.Net : http://james.newtonking.com/json * link to the binary code other .Net (dll of the bean and other requested librairies) * link to the VS solution with C# source code to compile the bean == Bean NotificationIcon == * Purpose Encapsulate the Microsoft ’s NotifyIcon class in a bean * input interface (exposed methods)== *void ShowNotification() *void ShowNotification(int time) *void ShowNotification(int time, string balloonTipText) *void ShowNotification(string balloonTipText) Show a notification in the Windows’ notification area. The balloonTipText must be set to display the notification. * output interface (emitted events) : The bean provide different event of the NotifyIcon class. *event EventHandler BalloonTipClicked *event EventHandler BalloonTipClosed *event EventHandler BalloonTipShown *event EventHandler Click *event EventHandler DoubleClick * link to the binary code other .Net (dll of the bean and other requested librairies) * link to the VS solution with C# source code to compile the bean == Bean Synchronisateur == * purpose of the bean \\ The goal of this bean is to group information to a big one. We can use it for treatment from multiple inputs. It stores data when they come, and, to never loose any information, it sends all of them when an already stored kind of data comes. * input interface (exposed methods) * public void GetNewData(string json) \\ Extract (and store) information from an objet or an array. For each property, if the value is a float, it sends all others if needed and then store it. If it's not a float, it send an event, expecting than another bean would be able to translate that into float (such as Expediteur) * public void getInfosFromArray(string json) \\ Should be the answer to the event called if the property is not a float. The argument must be the string of a json object, and every property must have a float as value. * output interface (emitted events) * InformationsToTreat(json) \\ Send the json with all the last received values of each kind. This json represents an object with multiple properties String Name - Float Value. * NeedInfoArray(json) \\ Send a json representing a property in wich the value is not a float. Potentially, another bean should be able to translate this value into a float and send it back. * internal algorithm or simply used librairies (and dependencies) * Json.Net : http://james.newtonking.com/json * links on the documentation of such librairies * link to the binary code other .Net (dll of the bean and other requested librairies) * link to the VS solution with C# source code to compile the bean === List of various beans assemblies === == Assembly == * purpose of the assembly * screen shot of the assembly * link on the corresponding wcc file === Configuration Files === == Syntax of the configuration files == * Fuzzy sets (one declaration by line) * declaration of linguistic variables variable;[variable name];[start of the interval]|[end of the interval ex: variable;Food;0|10 * declarations of trapezoidal fuzzy sets trapezoid;[variable name];[fuzzy set name];[parameters]|[of]|[trapezoid] ex: trapezoid;Food;Bad;1|7|right * declarations of linear variables linear;[variable name];[fuzzy set name];[point1.X:point1.Y]|[point2.X:point2.Y]|... ex: linear;Food;Bad;1:0,5|7:0,8|8:1 * declarations of the variables to be evaluated by the machine evaluate;[variable name] ex: evaluate;Tip * declaration of the path of the rule file rules;[path of the file] ex: rules;rules.txt * Fuzzy rules (one rule by line) IF [variable] IS (NOT)[fuzzy set] (AND|OR [variable] IS (NOT)[fuzzy set])* THEN [variable] IS [fuzzy set] == Example of configuration == * config.txt // variables linguistiques variable;Nourriture;0,10 variable;Service;0,10 variable;Pourboire;0,30 // ensembles flous trapezes trapezoid;Nourriture;Execrable;1,7,right trapezoid;Nourriture;Delicieux;7,9,left trapezoid;Service;Excellent;5,10,left trapezoid;Service;Bon;0,5,10 trapezoid;Service;Mauvais;0,5,right trapezoid;Pourboire;Bas;0,5,10 trapezoid;Pourboire;Moyen;10,15,20 trapezoid;Pourboire;Eleve;20,25,30 // variables à evaluer evaluate;Pourboire // fichier de regles rules;rules.txt * rules.txt IF QualiteService IS Mauvais OR Nourriture IS Execrable THEN Pourboire IS Faible IF QualiteService IS Bon THEN Pourboire IS Moyen IF QualiteService IS Excellent OR Nourriture IS Delicieux THEN Pourboire IS Eleve ==== Documentation and Tutorial ==== == On the Outlook SDK == * Documentation : http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.aspx == On Fuzzy AForge .Net Librairies == * Concepts: http://www.aforgenet.com/articles/fuzzy_computing_basics/ * Documentation: http://www.aforgenet.com/framework/documentation.html ==== Various scenarios to illustrate the project ==== * With Extracteur 1 : (visualisation des données extraites sous Excel) * With Extracteur 2 : (visualisation des données extraites sous Excel) * With Extracteur 3 : (visualisation des données extraites sous Excel) * With Synchonisation : (visualisation des données de sorties sous Excel) * With Fuzzy Reasonning : (visualisation des données de sorties avant defuzzification sous Excel) * With Fuzzy Reasonning : (visualisation des données de sorties après defussification sous Excel) ==== Prospects : ====