<commit_before>//Policy.js

//Private
var fs = require("fs"),
    xpath = require("xpath"),
    Dom = require("xmldom").DOMParser;

function Policy(path, fn) {
    this.fileName = fn;
    this.filePath = path + "/" + fn;
    this.messages = { warnings: [], errors: [] };
}

Policy.prototype.getName = function() {
    if (!this.name) {
        var attr = xpath.select("//@name", this.getContent());
        this.name = attr[0] && attr[0].value || "";
    }
    return this.name;
};

Policy.prototype.getDisplayName = function() {
    if (!this.displayName) {
        var doc = xpath.select("//DisplayName", this.getContent());
        this.displayName = doc[0].childNodes[0].nodeValue;
    }
    return this.displayName;
};

Policy.prototype.select = function(xs) {
    return xpath.select(xs, this.getContent());
};

Policy.prototype.getContent = function() {
    //read the contents of the file and return it raw
    if (!this.content) {
        this.content = new Dom().parseFromString(fs.readFileSync(this.filePath).toString());
    }
    return this.content;
};

Policy.prototype.getFileName = function() {
    return this.fileName;
};

Policy.prototype.getType = function() {
    if (!this.type) {
        var doc = xpath.select("/", this.getContent());
        this.type = doc && doc[0] && doc[0].documentElement.tagName || "";<commit_msg>renamed content to element in policy<commit_after>//Policy.js

//Private
var fs = require("fs"),
    xpath = require("xpath"),
    Dom = require("xmldom").DOMParser;

function Policy(path, fn) {
    this.fileName = fn;
    this.filePath = path + "/" + fn;
    this.messages = { warnings: [], errors: [] };
}

Policy.prototype.getName = function() {
    if (!this.name) {
        var attr = xpath.select("//@name", this.getElement());
        this.name = attr[0] && attr[0].value || "";
    }
    return this.name;
};

Policy.prototype.getDisplayName = function() {
    if (!this.displayName) {
        var doc = xpath.select("//DisplayName", this.getElement());
        this.displayName = doc[0].childNodes[0].nodeValue;
    }
    return this.displayName;
};

Policy.prototype.select = function(xs) {
    return xpath.select(xs, this.getElement());
};

Policy.prototype.getElement = function() {
    //read the contents of the file and return it raw
    if (!this.element) {
        this.element = new Dom().parseFromString(fs.readFileSync(this.filePath).toString());
    }
    return this.element;
};

Policy.prototype.getFileName = function() {
    return this.fileName;
};

Policy.prototype.getType = function() {
    if (!this.type) {
        var doc = xpath.select("/", this.getElement());
        this.type = doc && doc[0] && doc[0].documentElement.tagName || "";
{'fraction_non_alphanumeric': 0.17384898710865562, 'fraction_numerical': 0.004419889502762431, 'mean_word_length': 3.065868263473054, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '1641394', 'n_tokens_mistral': 850, 'n_tokens_neox': 849, 'n_words': 175}