Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add initial script + copyright blurb.

  • Loading branch information...
commit 7a072c15ade14e3fccbb994309588f3c51346632 1 parent 27800fd
@neilconway authored
Showing with 57 additions and 0 deletions.
  1. +18 −0 COPYING.txt
  2. +39 −0 hyphen-consistency.rb
View
18 COPYING.txt
@@ -0,0 +1,18 @@
+Copyright (c) 2012, Neil Conway
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
39 hyphen-consistency.rb
@@ -0,0 +1,39 @@
+#!/usr/bin/env ruby
+require 'set'
+
+if ARGV.empty?
+ puts "usage: #{$0} <file> ..."
+ exit
+end
+
+words = {}
+ARGV.each do |f|
+ IO.readlines(f).each_with_index do |line, idx|
+ # Skip TeX comments
+ if line =~ /^(.*)(?<!\\)%/
+ line = $1
+ end
+
+ line.split(/[\s.,;:{}()\[\]`"\/\\%~]/).each do |w|
+ w = w.chomp("''") # remove closing TeX-style quotation marks
+ next if w.empty?
+ w = w.downcase
+ words[w] ||= Set.new
+ words[w] << [f, idx + 1]
+ end
+ end
+end
+
+def format_usage(w, words)
+ words[w].to_a.sort.map {|l| l.join(":")}.join(", ")
+end
+
+words.keys.sort.each do |w|
+ next unless w =~ /^(.+)-(.+)$/
+ no_hyphen = "#{$1}#{$2}"
+ if words.has_key? no_hyphen
+ usage_w = format_usage(w, words)
+ usage_nh = format_usage(no_hyphen, words)
+ puts "\"#{w}\" @ [#{usage_w}], \"#{no_hyphen}\" @ [#{usage_nh}]"
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.