<commit_before>#!/usr/bin/perl
use strict;
use warnings;
# 目录 150707 - Is YYMMDD for documentation purposes. - Brian
# 目录 means Directory required lines. Why Chinese? It doesn't conflict with code or comments yet is filterable. - Brian
# 红白蓝 means Red White Blue code. This is per request of <NAME>. via Mike for the iOS app of school listings. Should be JSON and put in mpu/data/live web directory. - Brian
# All code is in the public domain. - Brian
# All information processed is public information. - Brian
my $credit = "<!-- See GitHub usermac/jcpsdirectory for more about this project. - Brian. -->"; # 目录 150709 - Please do not remove. - Brian
use DateTime qw(); # 目录 150723 - Grab the Date and Time as words only using the qw function. - Brian
my $date = DateTime->now->strftime('%m/%d/%Y'); #150723 - Set to the date var as MM/DD/YYYY. - Brian
open(my $in, "<", "directory-input.txt") or die "Can't open directory-input.txt:$!"; # 目录 150708 - Rename your exported Etherpad text-only export to this name. - Brian
open(my $edited, ">", "directory-timestamp.html") or die "Can't open directory-timestamp.html:$!"; # 目录 150709 - This simply writes to a file the edited timestamp. This is for Mike because I saw this on footer of Web pages - Brian
open(my $out, ">", "directory-output-admin.html") or die "Can't open directory-output-admin.html:$!"; # 目录 150708 - This is the results file to be used on the Web. - Brian
open(my $log, ">>", "directory-log.txt") or die "Can't open directory-log.txt:$!"; # 目录 150708 - Future use. It may become the log file. - Brian
print $out "$credit\n"; # 目录 150708 - Write credit to the top of the file. - Brian
while(<$in>){ # 目录 assigns each line in turn to $_
  s/\n//; # 目录 150709 - Remove the line ending as I'll add them back after the html code. This is just for beauty and has no function. - Brian
  s/jefferson\.kyschools\.us//; # 目录 150709 - Remove the domain name why? Because it becomes a mess when using the web pages' search. Remove it. - Brian
  my $mark = /RWB|HEADING/; # 目录 150708 - If within the html comments of the Etherpad text-only export it finds RWB for Red, White and Blue for schools or HEADING for department heads mark it. - Brian
    if ($mark) { # 目录 150708 - This will be 1 or blank. See above. - Brian
      print $out "<li><h2 class=\"name\">$_</h2>\n"; # 目录 150708 - It is a school name or department heading so print with html trappings of h2. - Brian
    } else {
      print $out "<li><h3 class=\"name\">$_</h3>\n"; # 目录 150708 - It is not a school name or department heading, it's a person, so print with html trappings of h3. - Brian
    }
  }    
print $edited "$date  $credit"; # 目录 150708 - Write the date to a file for later linking with the update information. - Brian<commit_msg>Just off vacation where I *may* have made some changes so I'm pushing them. - Brian<commit_after>#!/usr/bin/perl
use strict;
use warnings;
# All information processed is public information. - Brian
# 150707 - Is YYMMDD for documentation purposes. - Brian
# 150729 - Comments are on the same line as the code. - Brian
# Do a find for "目录" to find Directory code lines. Why Chinese? It doesn't conflict with code yet is uniquely searchable. - Brian
# Do a find for "红白蓝" to find schools only or what we call "Red, White and Blue" list. This is per request of <NAME>. via Mike for the iOS app of school listings. Should be JSON and put in mpu/data/live web directory. - Brian
# All code is in the public domain. - Brian
my $credit = "<!-- See GitHub usermac/jcpsdirectory for more about this project. - Brian. -->"; # 目录 红白蓝 150709 - Please do not remove. - Brian
use DateTime qw(); # 目录 150723 - Grab the Date and Time as words only using the qw function. - Brian
my $date = DateTime->now->strftime('%m/%d/%Y'); #150723 - Set to the date var as MM/DD/YYYY. - Brian
open(my $in, "<", "directory-input.txt") or die "Can't open directory-input.txt:$!"; # 目录 150708 - Rename your exported Etherpad text-only export to this name. - Brian
open(my $edited, ">", "directory-timestamp.html") or die "Can't open directory-timestamp.html:$!"; # 目录 150709 - This simply writes to a file the edited timestamp. This is for Mike because I saw this on footer of Web pages - Brian
open(my $out, ">", "directory-admin.html") or die "Can't open directory-admin.html:$!"; # 目录 150708 - This is the results file to be used on the Web. - Brian
open(my $log, ">>", "directory-log.txt") or die "Can't open directory-log.txt:$!"; # 目录 150708 - Future use. It may become the log file. - Brian
print $out "$credit\n"; # 目录 150708 - Write credit to the top of the file. - Brian
while(<$in>){ # 目录 assigns each line in turn to $_
  s/\n//; # 目录 150709 - Remove the line ending as I'll add them back after the html code. This is just for beauty and has no function. - Brian
  s/jefferson\.kyschools\.us//; # 目录 150709 - Remove the domain name why? Because it becomes a mess when using the web pages' search. Remove it. - Brian
  my $mark = /RWB|HEADING/; # 目录 150708 - If within the html comments of the Etherpad text-only export it finds RWB for Red, White and Blue for schools or HEADING for department heads mark it. - Brian
    if ($mark) { # 目录 150708 - This will be 1 or blank. See above. - Brian
      print $out "<li><h2 class=\"name\">$_</h2>\n"; # 目录 150708 - It is a school name or department heading so print with html trappings of h2. - Brian
    } else { # 目录
      print $out "<li><h3 class=\"name\">$_</h3>\n"; # 目录 150708 - It is not a school name or department heading, it's a person, so print with html trappings of h3. - Brian
    }
  }    
print $edited "$date  $credit"; # 目录 150708 - Write the date to a file for later linking with the update information. - Brian
#
# 红白蓝 150728 Begin processing just schools for JSON format. This is for the iPhone app. - Brian
# 红白蓝 150731 "Louisville, KY" is assumed. (502) area code is also assumed. They are sorted by school name. - Brian
open(my $in2, "<", "directory-input.txt") or die "Can't open directory-input.txt:$!"; # 红白蓝 150708 - Rename your exported Etherpad text-only export to this name. This is the same file as $in above. - Brian
open(my $json_schools, ">", "directory-schools.json") or die "Can't open directory-schools.json:$!"; # 目录 红白蓝 150726 - This is the results file to be used on the Web for JSON read-only. - Brian
      print $json_schools "{\n    \"school\":\n    [\n    {\n"; # 红白蓝 150730 - This is the opening lines to the JSON. - Brian
while(<$in2>){ # 红白蓝 assigns each line in turn to $_
  s/\n//; # 红白蓝 150709 - Remove the line ending as I'll add them back after the html code. This is just for beauty and has no function. - Brian
  my $mark = /RWB/; # 红白蓝 150708 - If within the html comments of the Etherpad text-only export it finds RWB for Red, White and Blue for schools or HEADING for department heads mark it. - Brian
    if ($mark) { # 红白蓝 150708 - This will be 1 or blank. See above. - Brian
      print $json_schools "        \"entity\": $_\n    }, {\n"; # 红白蓝 150708 - It is a school name or department heading so print with html trappings of h2. - Brian
#        "entity": "3",
     }  
  }
      print $json_schools "\n      ]\n}"; # 红白蓝 150730 - This is the closing lines to the JSON. - Brian
{'fraction_non_alphanumeric': 0.1127091688563131, 'fraction_numerical': 0.03872216844143272, 'mean_word_length': 3.2046511627906975, 'pattern_counts': {'":': 3, '<': 25, '<?xml version=': 0, '>': 35, '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': '867294', 'n_tokens_mistral': 2506, 'n_tokens_neox': 2300, 'n_words': 1075}