<commit_before>﻿using System;
using System.Collections.Generic;
using System.Xml;

namespace ModAnalyzer.Domain {
    /// <summary>
    /// TODO
    /// </summary>
    public class FomodPattern {
        public List<FomodFile> Files { get; }
        public List<FomodFlagDependency> Dependencies { get; }

        public FomodPattern(XmlNode node) {
            XmlNode filesNode = node["files"];
            if (filesNode != null) {
                Files = FomodFile.FromNodes(filesNode.ChildNodes);
            }

            XmlNode dependenciesNode = node["dependencies"];
            if (dependenciesNode != null) {
                Dependencies = FomodFlagDependency.FromNodes(dependenciesNode.ChildNodes);
            }
        }

        public static List<FomodPattern> FromDocument(XmlDocument doc) {
            List<FomodPattern> patterns = new List<FomodPattern>();
            foreach (XmlNode node in doc.GetElementsByTagName("pattern")) {
                patterns.Add(new FomodPattern(node));
            }
            return patterns;
        }
    }
}<commit_msg>fixed bug with analyzing fomod configs with pattern nodes under dependencies note: there's probably a better way to do this (getting the nodes by an xpath or something)<commit_after>﻿using System;
using System.Collections.Generic;
using System.Xml;

namespace ModAnalyzer.Domain {
    /// <summary>
    /// TODO
    /// </summary>
    public class FomodPattern {
        public List<FomodFile> Files { get; }
        public List<FomodFlagDependency> Dependencies { get; }

        public FomodPattern(XmlNode node) {
            XmlNode filesNode = node["files"];
            if (filesNode != null) {
                Files = FomodFile.FromNodes(filesNode.ChildNodes);
            }

            XmlNode dependenciesNode = node["dependencies"];
            if (dependenciesNode != null) {
                Dependencies = FomodFlagDependency.FromNodes(dependenciesNode.ChildNodes);
            }
        }

        public static List<FomodPattern> FromDocument(XmlDocument doc) {
            List<FomodPattern> patterns = new List<FomodPattern>();
            foreach (XmlNode node in doc.GetElementsByTagName("pattern")) {
                if (node.ParentNode.ParentNode.Name != "dependencyType") {
                    patterns.Add(new FomodPattern(node));
                }
            }
            return patterns;
        }
    }
}
{'fraction_non_alphanumeric': 0.09660033167495855, 'fraction_numerical': 0.0, 'mean_word_length': 2.154248366013072, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5609076', 'n_tokens_mistral': 652, 'n_tokens_neox': 596, 'n_words': 148}