-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyseGIRT.php
57 lines (35 loc) · 1.35 KB
/
analyseGIRT.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/*
* Manual is at http://pear.php.net/manual/en/package.xml.xml-statistics.intro.php
*/
require_once "XML/Statistics.php";
$stat = new XML_Statistics(array("ignoreWhitespace" => true));
$dir = '/Users/schaer/Desktop/girt_test/solis_xhive';
//if ($handle = opendir('/Users/schaer/Dropbox/Dissertation/diss/data/GIRT4-XML')) {
if ($handle = opendir($dir)) {
// echo "Directory handle: $handle\n";
echo "Filename;"."Total tags;"."doc"."\n";
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "$file".";";
$result = $stat->analyzeFile("$dir/"."$file");
if ($stat->isError($result)) {
die("Error: " . $result->getMessage());
}
// total amount of tags:
echo $stat->countTag() . ";";
// total amount of tags "doc"
// echo $stat->countTag("add") . ";";
echo $stat->countAttribute("field") . ";";
// count total number of tags in depth 4
echo "Amount of Tags in depth 4: " . $stat->countTagsInDepth(4) . "\n";
// echo "Occurences of PHP Blocks: " . $stat->countPI("PHP") . "\n";
echo "Occurences of external entity 'bar': " . $stat->countExternalEntity("bar") . "\n";
echo "Data chunks: " . $stat->countDataChunks() . "\n";
echo "Length of all data chunks: " . $stat->getCDataLength() . "\n";
echo "\n";
}
}
closedir($handle);
}
?>