File containing the old version of the code
Package containing the source code and all the .js files.
File containing the parcours function, allowing the program to run through a folder and return the directory of all of its files.
function getFile(pathTab, directory) Explore recursively the directory given in parameter.
If the the object inspected is a folder, add it to the directory path.
If it's a file, add it with its path to pathTab , the array given in parameter.
Parameters:
* pathFile — string — - The array in which the results of the function will be returned.
* pathFile — string — - The directory to explore.
Returns: Array<String> * An array in which the paths of the file found will be stored*
File containing the parse function, allowing to parse any file using the mailparser library.
function parseFile(pathFile)Make a promise (an object that will produce a single value) that will process the following:
Reads the file at the path indicated by "pathFile", inside an Async block.
Waits that the last promise finished processing, to parse the next line using 'mailparser'.
Then, returns the result of the promise by replacing the unparsed line of the file by the parsed one.
Parameters: pathFile — string — - The directory of the file to parse.
Returns: Promise<Object> — - A promise that provides a mail object when resolved
File containing the parse function, allowing to write a JSON file from a parsed file
function parseFile(directory)Make a promise#1 (an object that will produce a single value) that will process the following:
Creates an array pathTab to stock all the files' directories that need to be parsed.
Then execute the getFile() to add all the filed directories into pathTab.
Next, for each directory contained in pathTab, parses the file at that directory.
After that, for the content of each directory, creates a promise #2 that will process the following:
Creates an array that will stock content of each file by sorting them between content type.
Then, proceed to read the content and put it into the array into the corresponding value.
Finally, writes the formated mail into the JSON file.
Parameters: pathFile — string — - The directory of the file to parse.
Returns: Promise<Void> — - A promise that provides a mail object when resolved
This contains the code of all the commands that can be executed by the user to extract information from the database
Commands summary:
- parse <directory></directory>
- search <directory> <searchedtext></searchedtext></directory>
- periode <datedebut> <datefin></datefin></datedebut>
- buzzy
- inter <user></user>
- list
- occur
- chart <user></user>
.command('parse', 'Parse Email file') .argument('<directory>','The directory with the mail to parse')Execute the parseFile function from WriteJSON.js on the file in given directory.
Parameters: pathFile — string — - The directory of the file where the parse function will be executed.
.command('search', 'Free text search on mail') .argument('<searchedText>','The text to look for') Get the files via the getFile() function from parcours.js,
reads the file, and parse the file into a a JavaScript object.
Then, runs through each mail contained in the object,
and returns the ones where the "Date", "To", "Subject", or "From" fields
that contains the text passed in the argument.
Parameters: searchedText — string — - The text to look for in the database.
.command('periode', 'Gives the number of mails between two given dates').argument('<dateDebut>',art').argument('<dateFin>', 'Finish') Parses "file.json" into a JavaScript variable ("data").
Pass the dates into an array "argDates" while parsing them into a Moment.js format (in UTC).
Runs through each mail contained in "data",
and parse the dates contained in the mails into a Moment.js format (in UTC).
Then, filter the mails to search those whose dates are between the dates passed in arguments,
and returns their total.
Parameters:
* dateDebut — date — - - The oldest date to look up to.
* dateFin — date — - The most recent date to look up to.
.command('buzzy', 'Gives the list of email writen during buzzy days ')Parses "file.json" into a JavaScript variable ("data").
Runs through each mail contained in "data", and parse the dates
contained in the mails into a Moment.js format (in UTC).
Filters the mails to search those whose dates are either on Saturday,
Sunday, or between 10:00 PM and 8:00 AM.
Then, returns them.
.command('inter', 'Gives the top 10 of interlocutors for a given person ').argument('<user>', 'The given person') Parses "file.json" and extracts the subjects into a JavaScript variable ("data").
Runs through each mail contained in "data", and filter them to only retain
the mail written by and sent to the user passed in the argument.
Again, in the reduce() call, runs through each mail (named as the value "elt"),
and determines which user is the interlocutor, between the "from" and the "to" field of the mail.
After that, determines if the user is already stored in the accumulator
("acc") (array[user] = [numberOfInteractions]) that will be returned.
If not, puts the user as a key into the array, and set its value (number of interactions) to 1.
If it is, increments its value by 1.
Then, reduce "data" down to the values of the accumulator, and sort them by the one with the highest value.
Finally, cuts down "data" to the 10 first users, and returns it.
Parameters: * user — string — - The user whose contacts will be sought.
.command('list', 'Gives the list of all the people present in "from" or in "to"') Parses "file.json" and extracts the mails into a JavaScript variable ("data").
Next, creates a Set of interlocutors to prevent doubles.
Then, for each mail, gets the different users contained in the "To" and "From" fields into an array
by splitting them into different values at each occurrence of the ", " character with the split() function.
After that, trims the whitespaces from the usernames with the trim() function and add them to the Set interlocutors.
Finally, returns interlocutors.
.command('inter', 'Gives the top 10 of interlocutors for a given person ').argument('<user>', 'The given person') Parses "file.json" and extracts the subjects into a JavaScript variable ("data").
Runs through each mail contained in "data", and splits them into different values (words).
again, in the reduce() call, runs through each mail (named as the value "elt"),
and determines if the word is already stored in the accumulator
("acc") (array[word] = [numberOfOccurence]) that will be returned.
If not, puts the word as a key into the array, and set its value (number of occurences) to 1.
If it is, increments its value by 1.
Then, reduce "data" down to the values of the accumulator, and sort them by the one with the highest value.
Finally, cuts down "data" to the 10 first words, and returns it.
.command('occur', 'Gives the list of the 10 words the most used in the "subject" field') Parses "file.json" and extracts the subjects into a JavaScript variable ("data").
Runs through each mail contained in "data", and splits them into different values (words).
Again, in the reduce() call, runs through each mail (named as the value "elt"),
and determines if the word is already stored in the accumulator ("acc") (array[word] = [numberOfOccurence]) that will be returned.
("acc") (array[word] = [numberOfOccurence]) that will be returned.
If not, puts the word as a key into the array, and set its value (number of interactions) to 1.
If it is, increments its value by 1.
Then, reduce "data" down to the values of the accumulator, and sort them by the one with the highest value.
Finally, cuts down "data" to the 10 first word, and returns it.
Parameters: * user — string — - The word whose occurences will be sought.
.command('chart', 'Export a Vega-lite chart with top 10 interlocutors').argument('<user>', 'A valid mail address')see .command('inter', ...) for top 10 interlocutor
Uses a vega lite template for a graph, in which is inserted the data from the previous command.
Next compiles it and save its specifications into a javascript variable "MyChart".
After that, parses it, and renders it into an SVG format.
Finally, saves it in the repository, and prints the path in the console
Parameters: * user — string — - The user whose contacts will be sought.
The set of data used to execute the tests.
Contains the code used to execute the tests
Parcours.js (sourceforge.net)
Parse.js (sourceforge.net)
WriteJSON.js (sourceforge.net)
Welcome to your wiki!
This is the default page, edit it as you see fit. To add a new page simply reference it within brackets, e.g.: [SamplePage].
The wiki uses Markdown syntax.