Example #1
0
        /// <summary>
        /// This method is responsible for initializing the skill list for the json output
        /// </summary>
        /// <param name="jsonOutput"> The intialized json output </param>
        /// <param name="skillAndItsOccurrences"> A dictionary of skills as keys and the number of their occurrences in a text file as value </param>
        private void createSkillListForJsonOutput(JsonOutput jsonOutput, Dictionary <string, int> skillAndItsOccurrences)
        {
            List <object> skillList = new List <object>();
            object        skill;

            foreach (KeyValuePair <string, int> pair in skillAndItsOccurrences)
            {
                skill = "{name: " + pair.Key + ", count: " + pair.Value + "}";
                skillList.Add(skill);
            }

            jsonOutput.Skills = skillList;
        }
Example #2
0
        /// <summary>
        /// This methos is responsible for creating the json output
        /// </summary>
        private void createJsonOutput()
        {
            foreach (KeyValuePair <TextFile, JsonFile> pair in txtAndMatchingJsonFiles)
            {
                Dictionary <string, int> skillAndItsOccurrences = new Dictionary <string, int>();
                JsonOutput jsonOutput = new JsonOutput();
                JsonFile   jsonFile   = pair.Value;
                TextFile   textFile   = pair.Key;

                jsonOutput.filename = textFile.FileName;
                jsonOutput.jobTitle = jsonFile.PositionTitle;
                jsonFile.Skills     = sortSkillOccurences(jsonFile.Skills);
                countSkillOccurrences(textFile, jsonFile.Skills, skillAndItsOccurrences);
                createSkillListForJsonOutput(jsonOutput, skillAndItsOccurrences);
                jsonResult += JsonConvert.SerializeObject(jsonOutput, Formatting.Indented);
                jsonResult += Environment.NewLine;
            }
        }