Kaynağa Gözat

First commit

tags/v0.1.0^0
Adrian Short 4 yıl önce
işleme
fe78de3bb8
İmzalayan: adrian GPG Anahtar Kimliği: 4B54F9AE91AB06BB
11 değiştirilmiş dosya ile 246 ekleme ve 0 silme
  1. +8
    -0
      .gitignore
  2. +9
    -0
      CHANGELOG.md
  3. +6
    -0
      Gemfile
  4. +29
    -0
      Gemfile.lock
  5. +67
    -0
      README.md
  6. +2
    -0
      Rakefile
  7. +14
    -0
      bin/console
  8. +8
    -0
      bin/setup
  9. +71
    -0
      lib/merton_planning_formatter.rb
  10. +3
    -0
      lib/merton_planning_formatter/version.rb
  11. +29
    -0
      merton_planning_formatter.gemspec

+ 8
- 0
.gitignore Dosyayı Görüntüle

@@ -0,0 +1,8 @@
/.bundle/
/.yardoc
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/

+ 9
- 0
CHANGELOG.md Dosyayı Görüntüle

@@ -0,0 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.1 - 2020-04-30

First release.

+ 6
- 0
Gemfile Dosyayı Görüntüle

@@ -0,0 +1,6 @@
source "https://rubygems.org"

# Specify your gem's dependencies in merton_planning_formatter.gemspec
gemspec

gem "rake", "~> 12.0"

+ 29
- 0
Gemfile.lock Dosyayı Görüntüle

@@ -0,0 +1,29 @@
PATH
remote: .
specs:
merton_planning_formatter (0.1.0)
pragmatic_segmenter

GEM
remote: https://rubygems.org/
specs:
coderay (1.1.2)
method_source (1.0.0)
pragmatic_segmenter (0.3.22)
unicode
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
rake (12.3.3)
unicode (0.4.4.4)

PLATFORMS
ruby

DEPENDENCIES
merton_planning_formatter!
pry (~> 0.11)
rake (~> 12.0)

BUNDLED WITH
2.1.4

+ 67
- 0
README.md Dosyayı Görüntüle

@@ -0,0 +1,67 @@
# Merton Planning Formatter

Formats Merton Council planning application descriptions/proposals nicely.

Converts uppercase descriptions to a readable mixed case format while preserving capitalisation for some proper nouns (eg Merton) and abbreviations (eg LBM, WC), [use classes](https://www.planningportal.co.uk/info/200130/common_projects/9/change_of_use) (eg A1, B1(c), D2), trees (eg TPO, M123, T20) and application reference numbers (eg 19/P1234).

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'merton_planning_formatter'
```

And then execute:

$ bundle install

Or install it yourself as:

$ gem install merton_planning_formatter

## Usage

Some real examples:

```ruby
require 'merton_planning_formatter'

description = "APPLICATION TO DISCHARGE CONDITION 22 (CAR LIFT) ATTACHED TO LBM PLANNING PERMISSION 19/P0140 (PART DEMOLITION AND ERECTION OF A REPLACEMENT DWELLINGHOUSE)"

puts MertonPlanningFormatter::format(description)

# => Application to discharge condition 22 (car lift) attached to LBM planning permission 19/P0140 (part demolition and erection of a replacement dwellinghouse)

description = "APPLICATION TO DETERMINE WHETHER PRIOR APPROVAL IS REQUIRED IN RESPECT OF THE PROPOSED CHANGE OF USE FROM OFFICE SPACE (CLASS B1a) TO RESIDENTIAL (CLASS C3) TO CREATE 1 RESIDENTIAL UNIT (CLASS C3)"

puts MertonPlanningFormatter::format(description)

# => Application to determine whether prior approval is required in respect of the proposed change of use from office space (class B1a) to residential (class C3) to create 1 residential unit (class C3)

description = "APPLICATION FOR DISCHARGE OF CONDITION 25 ATTACHED LBM PLANNING PERMISSION 18/P4447 RELATING TO THE DEMOLITION OF EXISTING BUILDINGS AND STRUCTURES, AND REDEVELOPMENT FOR A NEW 8 - STOREY BUILDING (PLUS ADDITIONAL PLANT AT ROOF LEVEL) COMPRISING OF A HOTEL (USE CLASS C1) AND THREE COMMERCIAL UNITS (A FLEXIBLE USE WITHIN CLASSES A1, A2, A3 AND / OR A4); SUBSTATION; ALTERATIONS TO EXISTING ACCESS AND CREATION OF NEW ACCESS ON GRAHAM ROAD; HARD AND SOFT LANDSCAPING, GROUND WORKS AND ASSOCIATED INFRASTRUCTURE."

puts MertonPlanningFormatter::format(description)

# => Application for discharge of condition 25 attached LBM planning permission 18/P4447 relating to the demolition of existing buildings and structures, and redevelopment for a new 8 - storey building (plus additional plant at roof level) comprising of a hotel (use class C1) and three commercial units (a flexible use within classes A1, A2, A3 and / or A4); substation; alterations to existing access and creation of new access on graham road; hard and soft landscaping, ground works and associated infrastructure.

# Note that "Graham Road" is not capitalised.

description = "TPO M529: FRONT GARDEN - MATURE BEECH TREE (T2) TO BE REMOVED DUE TO STRUCTURAL WEAKNESS IN STEM AND UPPER CANOPY (REPLACEMENT PLANTING PROPOSED)."

puts MertonPlanningFormatter::format(description)

# => TPO M529: front garden - mature beech tree (T2) to be removed due to structural weakness in stem and upper canopy (replacement planting proposed).

```

## Development

After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/adrianshort/merton_planning_formatter.


+ 2
- 0
Rakefile Dosyayı Görüntüle

@@ -0,0 +1,2 @@
require "bundler/gem_tasks"
task :default => :spec

+ 14
- 0
bin/console Dosyayı Görüntüle

@@ -0,0 +1,14 @@
#!/usr/bin/env ruby

require "bundler/setup"
require "merton_planning_formatter"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start

require "pry"
pry.start

+ 8
- 0
bin/setup Dosyayı Görüntüle

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx

bundle install

# Do any other automated setup that you need to do here

+ 71
- 0
lib/merton_planning_formatter.rb Dosyayı Görüntüle

@@ -0,0 +1,71 @@
require "merton_planning_formatter/version"
require 'pragmatic_segmenter'

module MertonPlanningFormatter
class Error < StandardError; end

def self.format(s)
ps = PragmaticSegmenter::Segmenter.new(text: s, language: 'en')

sentences = ps.segment
output = []

sentences.each do |sentence|
sentence = sentence.downcase.capitalize
# Patterns have uppercase and lowercase alertnatives for the first letter to ensure that they match at the start of a sentence when the first letter will already be capitalised.

# Abbreviations
sentence.gsub! /\b[lL]bm\b/, 'LBM'
sentence.gsub! /\b[lL]b\b/, 'LB'
sentence.gsub! /\b[wW]c\b/, 'WC'
sentence.gsub! /\b[lL]ondon borough of merton\b/, 'London Borough of Merton'
sentence.gsub! /\b[mM]erton\b/, 'Merton'

# Districts
# https://en.wikipedia.org/wiki/London_Borough_of_Merton#Districts
sentence.gsub! /\b[bB]ushey mead\b/, 'Bushey Mead'
sentence.gsub! /\b[cC]olliers wood\b/, 'Colliers Wood'
sentence.gsub! /\b[cC]opse hill\b/, 'Copse Hill'
sentence.gsub! /\b[cC]ottenham park\b/, 'Cottenham Park'
sentence.gsub! /\b[cC]rooked bill?ett?\b/, 'Crooked Billet'
sentence.gsub! /\b[lL]ower morden\b/, 'Lower Morden'
sentence.gsub! /\b[mM]erton park\b/, 'Merton Park'
sentence.gsub! /\b[mM]itcham\b/, 'Mitcham'
sentence.gsub! /\b[mM]itcham common\b/, 'Mitcham Common'
sentence.gsub! /\b[mM]orden\b/, 'Morden'
sentence.gsub! /\b[mM]orden park\b/, 'Morden Park'
sentence.gsub! /\b[mM]otspur park\b/, 'Motspur Park'
sentence.gsub! /\b[nN]ew malden\b/, 'New Malden'
sentence.gsub! /\b[nN]orbury\b/, 'Norbury'
sentence.gsub! /\b[pP]ollards hill\b/, 'Pollards Hill'
sentence.gsub! /\b[rR]aynes park\b/, 'Raynes Park'
sentence.gsub! /\b[sS]t\.? Helier\b/, 'St. Helier'
sentence.gsub! /\b[sS]outh Wimbledon\b/, 'South Wimbledon'
sentence.gsub! /\b[sS]ummerstown\b/, 'Summerstown'
sentence.gsub! /\b[wW]imbledon\b/, 'Wimbledon'
sentence.gsub! /\b[wW]imbledon park\b/, 'Wimbledon Park'
# Use classes
# https://www.planningportal.co.uk/info/200130/common_projects/9/change_of_use
sentence.gsub! /\b[aA](\d)\b/, 'A\1'
sentence.gsub! /\b[bB](\d)([abc]?)\b/, 'B\1\2'
sentence.gsub! /\b[cC](\d)([abc]?)\b/, 'C\1\2'
sentence.gsub! /\b[dD](\d)\b/, 'D\1'
# Trees
sentence.gsub! /\b[tT]po\b/, 'TPO'
sentence.gsub! /\b[tT](\d+)\b/, 'T\1'
sentence.gsub! /\b[mM]er(\d+)\b/, 'MER\1'
sentence.gsub! /\b[mM](\d+)\b/, 'M\1'

# Case reference numbers, eg 18/P1234
sentence.gsub! /\b(\d{2})\/p(\d+)\b/, '\1/P\2'

output << sentence
end
output.join(' ')
end
end

+ 3
- 0
lib/merton_planning_formatter/version.rb Dosyayı Görüntüle

@@ -0,0 +1,3 @@
module MertonPlanningFormatter
VERSION = "0.1.0"
end

+ 29
- 0
merton_planning_formatter.gemspec Dosyayı Görüntüle

@@ -0,0 +1,29 @@
require_relative 'lib/merton_planning_formatter/version'

Gem::Specification.new do |spec|
spec.name = "merton_planning_formatter"
spec.version = MertonPlanningFormatter::VERSION
spec.authors = ["Adrian Short"]
spec.email = ["adrian@adrianshort.org"]

spec.summary = %q{Formats planning application descriptions/proposals nicely.}
# spec.description = %q{TODO: Write a longer description or delete this line.}
spec.homepage = "https://github.com/adrianshort/merton_planning_formatter"
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
spec.licenses = ['LGPL-3.0']

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = spec.homepage
spec.metadata["changelog_uri"] = "https://github.com/adrianshort/merton_planning_formatter/CHANGELOG.md"

# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.add_development_dependency "pry", "~> 0.11"
spec.add_runtime_dependency "pragmatic_segmenter"
end

Yükleniyor…
İptal
Kaydet