Jump to content

Index talk:US Copyright Office - Renewal Registrations - 1950.djvu/Reformat

Page contents not supported in other languages.
Add topic
From Wikisource

// This is the code I'm using to reformat these pages.

import java.io._

object Process {

 val o = new PrintWriter (new File ("bob"))
 def outputFormattedData (data : Seq[Seq[(String, Int)]]) : Unit = {
   //println (data)
   val chunk = (data.head +: data.tail.takeWhile (_.head._1.isEmpty)).toVector
   println (chunk)
   for (ch <- chunk) {
     for (c <- ch) {
       if (c._1.isEmpty) {o.println(""); o.print (":")}
       else o.print (c._1 + " ")
     }
   }
   o.println ("")
   o.println ("")
   println (data.tail)
   if (!data.tail.isEmpty)
     outputFormattedData (data.tail.dropWhile (_.head._1.isEmpty))
   else
     o.close()
 }
 def allTails[T] (s : Seq[T], bp : T => Boolean) : Seq[Seq[T]] = {
   if (s.isEmpty) Seq()
   else if (bp(s.head)) s +: allTails(s.tail, bp)
   else allTails(s.tail, bp)
 }
 def main(args: Array[String]): Unit = {
   val file = { if (args.isEmpty) "sample" else args(0)}
   val lines = io.Source.fromFile(file).getLines.toVector
   val processedData = allTails (
     lines.map (l => (l.dropWhile(_ == ' '), l.takeWhile(_ == ' ').length)),
     {x : (String, Int) => (x._2 == 0)}
   ).map {x =>
       (x.head +: x.tail.takeWhile (_._2 != 0))
     }.filter (l => l.length != 1 || (l.head._1 != ""))
   outputFormattedData (processedData.toVector)
 }

}

This work is licensed under the terms of the GNU General Public License.

Public domainPublic domainfalsefalse

 The standard Wikisource licenses apply to the original work of the contributor(s).


This work is licensed under the terms of the GNU Free Documentation License.

The Terms of use of the Wikimedia Foundation require that GFDL-licensed text imported after November 2008 must also be dual-licensed with another compatible license. "Content available only under GFDL is not permissible" (§7.4). This does not apply to non-text media.

Public domainPublic domainfalsefalse

This work is released under the Creative Commons Attribution-ShareAlike 3.0 Unported license, which allows free use, distribution, and creation of derivatives, so long as the license is unchanged and clearly noted, and the original author is attributed.

Public domainPublic domainfalsefalse

Start a discussion about Index:US Copyright Office - Renewal Registrations - 1950.djvu/Reformat

Start a discussion