<commit_before>import Foundation

let html = "<html><head></head><body><ul><li><input type='image' name='input1' value='string1value' class='abc' /></li><li><input type='image' name='input2' value='string2value' class='def' /></li></ul><span class='spantext'><b>Hello World 1</b></span><span class='spantext'><b>Hello World 2</b></span><a href='example.com'>example(English)</a><a href='example.co.jp'>example(JP)</a><div class='val'>value1</div><div class='val'>value2</div><div class='box'><span class='dat'><strong content='2014-12-31'>2014/12/31</strong></span><h2>Hoge</h2></div></body>"

var err : NSError?
var parser     = HTMLParser(html: html, error: &err)
if err != nil {
    println(err)
    exit(1)
}

var bodyNode   = parser.body

if let inputNodes = bodyNode?.findChildTags("b") {
    for node in inputNodes {
        println(node.contents)
    }
}

if let inputNodes = bodyNode?.findChildTags("a") {
    for node in inputNodes {
        println(node.contents)
        println(node.getAttributeNamed("href"))
    }
}

println(bodyNode?.findChildTagAttr("div", attrName: "class", attrValue: "val")?.contents)
<commit_msg>Cleaned sample html<commit_after>import Foundation

// sample HTML
let html =
"<html>" +
"<head>" +
"</head>" +
"<body>" +
"  <span class='spantext'>" +
"    <b>Hello World 1</b>" +
"  </span>" +
"  <span class='spantext'>" +
"    <b>Hello World 2</b>" +
"  </span>" +
"  <a href='example.com'>example(English)</a>" +
"  <a href='example.co.jp'>example(JP)</a>" +
"  <div class='val'>value1</div>" +
"  <div class='val'>value2</div>" +
"  <div class='box'>" +
"    <span class='dat'>" +
"      <strong content='2014-12-31'>2014/12/31</strong>" +
"    </span>" +
"    <h2>Hoge</h2>" +
"  </div>" +
"</body>" +
"</html>"


var err : NSError?
var parser     = HTMLParser(html: html, error: &err)
if err != nil {
    println(err)
    exit(1)
}

var bodyNode   = parser.body

if let inputNodes = bodyNode?.findChildTags("b") {
    for node in inputNodes {
        println(node.contents)
    }
}

if let inputNodes = bodyNode?.findChildTags("a") {
    for node in inputNodes {
        println(node.contents)
        println(node.getAttributeNamed("href"))
    }
}

println(bodyNode?.findChildTagAttr("div", attrName: "class", attrValue: "val")?.contents)

{'fraction_non_alphanumeric': 0.21419185282522996, 'fraction_numerical': 0.021901007446342532, 'mean_word_length': 4.155756207674943, 'pattern_counts': {'":': 0, '<': 70, '<?xml version=': 0, '>': 70, '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': '6246406', 'n_tokens_mistral': 853, 'n_tokens_neox': 814, 'n_words': 153}