merton_planning_formatter 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +29 -0
- data/README.md +67 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/merton_planning_formatter/version.rb +3 -0
- data/lib/merton_planning_formatter.rb +71 -0
- data/merton_planning_formatter.gemspec +29 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: aadedc6cd35367b8cf0470b52eb5ec0a427222dd2dd2b4f0d0ef30827dda2c48
|
4
|
+
data.tar.gz: 634038b6164161d1cfe5518212b4c45a7a900548cc420d5a047c92b22c53f1c8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b33704e6148a842e61d726afa0325c2842bdd9c1effcee1a4cfdaf003e76fb451926191e83a11e569347d6953f1a77467d66725429f7fa6762d5f3c6a9f05e6c
|
7
|
+
data.tar.gz: 061ac830fb21a713ea7befe95a19a324498e86844fe6237cf85566ce46977df0a3b041de525ebaf40614df73d1dd2d4dbf7ab367c5cf30090c7e437226268c8e
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## 0.1 - 2020-04-30
|
8
|
+
|
9
|
+
First release.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
merton_planning_formatter (0.1.0)
|
5
|
+
pragmatic_segmenter
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
coderay (1.1.2)
|
11
|
+
method_source (1.0.0)
|
12
|
+
pragmatic_segmenter (0.3.22)
|
13
|
+
unicode
|
14
|
+
pry (0.13.1)
|
15
|
+
coderay (~> 1.1)
|
16
|
+
method_source (~> 1.0)
|
17
|
+
rake (12.3.3)
|
18
|
+
unicode (0.4.4.4)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
merton_planning_formatter!
|
25
|
+
pry (~> 0.11)
|
26
|
+
rake (~> 12.0)
|
27
|
+
|
28
|
+
BUNDLED WITH
|
29
|
+
2.1.4
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Merton Planning Formatter
|
2
|
+
|
3
|
+
Formats Merton Council planning application descriptions/proposals nicely.
|
4
|
+
|
5
|
+
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).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'merton_planning_formatter'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install merton_planning_formatter
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Some real examples:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'merton_planning_formatter'
|
29
|
+
|
30
|
+
description = "APPLICATION TO DISCHARGE CONDITION 22 (CAR LIFT) ATTACHED TO LBM PLANNING PERMISSION 19/P0140 (PART DEMOLITION AND ERECTION OF A REPLACEMENT DWELLINGHOUSE)"
|
31
|
+
|
32
|
+
puts MertonPlanningFormatter::format(description)
|
33
|
+
|
34
|
+
# => Application to discharge condition 22 (car lift) attached to LBM planning permission 19/P0140 (part demolition and erection of a replacement dwellinghouse)
|
35
|
+
|
36
|
+
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)"
|
37
|
+
|
38
|
+
puts MertonPlanningFormatter::format(description)
|
39
|
+
|
40
|
+
# => 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)
|
41
|
+
|
42
|
+
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."
|
43
|
+
|
44
|
+
puts MertonPlanningFormatter::format(description)
|
45
|
+
|
46
|
+
# => 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.
|
47
|
+
|
48
|
+
# Note that "Graham Road" is not capitalised.
|
49
|
+
|
50
|
+
description = "TPO M529: FRONT GARDEN - MATURE BEECH TREE (T2) TO BE REMOVED DUE TO STRUCTURAL WEAKNESS IN STEM AND UPPER CANOPY (REPLACEMENT PLANTING PROPOSED)."
|
51
|
+
|
52
|
+
puts MertonPlanningFormatter::format(description)
|
53
|
+
|
54
|
+
# => TPO M529: front garden - mature beech tree (T2) to be removed due to structural weakness in stem and upper canopy (replacement planting proposed).
|
55
|
+
|
56
|
+
```
|
57
|
+
|
58
|
+
## Development
|
59
|
+
|
60
|
+
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.
|
61
|
+
|
62
|
+
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).
|
63
|
+
|
64
|
+
## Contributing
|
65
|
+
|
66
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/adrianshort/merton_planning_formatter.
|
67
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "merton_planning_formatter"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "pry"
|
14
|
+
pry.start
|
data/bin/setup
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require "merton_planning_formatter/version"
|
2
|
+
require 'pragmatic_segmenter'
|
3
|
+
|
4
|
+
module MertonPlanningFormatter
|
5
|
+
class Error < StandardError; end
|
6
|
+
|
7
|
+
def self.format(s)
|
8
|
+
ps = PragmaticSegmenter::Segmenter.new(text: s, language: 'en')
|
9
|
+
|
10
|
+
sentences = ps.segment
|
11
|
+
output = []
|
12
|
+
|
13
|
+
sentences.each do |sentence|
|
14
|
+
sentence = sentence.downcase.capitalize
|
15
|
+
|
16
|
+
# 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.
|
17
|
+
|
18
|
+
# Abbreviations
|
19
|
+
sentence.gsub! /\b[lL]bm\b/, 'LBM'
|
20
|
+
sentence.gsub! /\b[lL]b\b/, 'LB'
|
21
|
+
sentence.gsub! /\b[wW]c\b/, 'WC'
|
22
|
+
|
23
|
+
sentence.gsub! /\b[lL]ondon borough of merton\b/, 'London Borough of Merton'
|
24
|
+
sentence.gsub! /\b[mM]erton\b/, 'Merton'
|
25
|
+
|
26
|
+
# Districts
|
27
|
+
# https://en.wikipedia.org/wiki/London_Borough_of_Merton#Districts
|
28
|
+
sentence.gsub! /\b[bB]ushey mead\b/, 'Bushey Mead'
|
29
|
+
sentence.gsub! /\b[cC]olliers wood\b/, 'Colliers Wood'
|
30
|
+
sentence.gsub! /\b[cC]opse hill\b/, 'Copse Hill'
|
31
|
+
sentence.gsub! /\b[cC]ottenham park\b/, 'Cottenham Park'
|
32
|
+
sentence.gsub! /\b[cC]rooked bill?ett?\b/, 'Crooked Billet'
|
33
|
+
sentence.gsub! /\b[lL]ower morden\b/, 'Lower Morden'
|
34
|
+
sentence.gsub! /\b[mM]erton park\b/, 'Merton Park'
|
35
|
+
sentence.gsub! /\b[mM]itcham\b/, 'Mitcham'
|
36
|
+
sentence.gsub! /\b[mM]itcham common\b/, 'Mitcham Common'
|
37
|
+
sentence.gsub! /\b[mM]orden\b/, 'Morden'
|
38
|
+
sentence.gsub! /\b[mM]orden park\b/, 'Morden Park'
|
39
|
+
sentence.gsub! /\b[mM]otspur park\b/, 'Motspur Park'
|
40
|
+
sentence.gsub! /\b[nN]ew malden\b/, 'New Malden'
|
41
|
+
sentence.gsub! /\b[nN]orbury\b/, 'Norbury'
|
42
|
+
sentence.gsub! /\b[pP]ollards hill\b/, 'Pollards Hill'
|
43
|
+
sentence.gsub! /\b[rR]aynes park\b/, 'Raynes Park'
|
44
|
+
sentence.gsub! /\b[sS]t\.? Helier\b/, 'St. Helier'
|
45
|
+
sentence.gsub! /\b[sS]outh Wimbledon\b/, 'South Wimbledon'
|
46
|
+
sentence.gsub! /\b[sS]ummerstown\b/, 'Summerstown'
|
47
|
+
sentence.gsub! /\b[wW]imbledon\b/, 'Wimbledon'
|
48
|
+
sentence.gsub! /\b[wW]imbledon park\b/, 'Wimbledon Park'
|
49
|
+
|
50
|
+
# Use classes
|
51
|
+
# https://www.planningportal.co.uk/info/200130/common_projects/9/change_of_use
|
52
|
+
sentence.gsub! /\b[aA](\d)\b/, 'A\1'
|
53
|
+
sentence.gsub! /\b[bB](\d)([abc]?)\b/, 'B\1\2'
|
54
|
+
sentence.gsub! /\b[cC](\d)([abc]?)\b/, 'C\1\2'
|
55
|
+
sentence.gsub! /\b[dD](\d)\b/, 'D\1'
|
56
|
+
|
57
|
+
# Trees
|
58
|
+
sentence.gsub! /\b[tT]po\b/, 'TPO'
|
59
|
+
sentence.gsub! /\b[tT](\d+)\b/, 'T\1'
|
60
|
+
sentence.gsub! /\b[mM]er(\d+)\b/, 'MER\1'
|
61
|
+
sentence.gsub! /\b[mM](\d+)\b/, 'M\1'
|
62
|
+
|
63
|
+
# Case reference numbers, eg 18/P1234
|
64
|
+
sentence.gsub! /\b(\d{2})\/p(\d+)\b/, '\1/P\2'
|
65
|
+
|
66
|
+
output << sentence
|
67
|
+
end
|
68
|
+
|
69
|
+
output.join(' ')
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative 'lib/merton_planning_formatter/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "merton_planning_formatter"
|
5
|
+
spec.version = MertonPlanningFormatter::VERSION
|
6
|
+
spec.authors = ["Adrian Short"]
|
7
|
+
spec.email = ["adrian@adrianshort.org"]
|
8
|
+
|
9
|
+
spec.summary = %q{Formats planning application descriptions/proposals nicely.}
|
10
|
+
# spec.description = %q{TODO: Write a longer description or delete this line.}
|
11
|
+
spec.homepage = "https://github.com/adrianshort/merton_planning_formatter"
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
13
|
+
spec.licenses = ['LGPL-3.0']
|
14
|
+
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
17
|
+
spec.metadata["changelog_uri"] = "https://github.com/adrianshort/merton_planning_formatter/CHANGELOG.md"
|
18
|
+
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
end
|
24
|
+
spec.bindir = "exe"
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ["lib"]
|
27
|
+
spec.add_development_dependency "pry", "~> 0.11"
|
28
|
+
spec.add_runtime_dependency "pragmatic_segmenter"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: merton_planning_formatter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adrian Short
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-04-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pragmatic_segmenter
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- adrian@adrianshort.org
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- CHANGELOG.md
|
50
|
+
- Gemfile
|
51
|
+
- Gemfile.lock
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/console
|
55
|
+
- bin/setup
|
56
|
+
- lib/merton_planning_formatter.rb
|
57
|
+
- lib/merton_planning_formatter/version.rb
|
58
|
+
- merton_planning_formatter.gemspec
|
59
|
+
homepage: https://github.com/adrianshort/merton_planning_formatter
|
60
|
+
licenses:
|
61
|
+
- LGPL-3.0
|
62
|
+
metadata:
|
63
|
+
homepage_uri: https://github.com/adrianshort/merton_planning_formatter
|
64
|
+
source_code_uri: https://github.com/adrianshort/merton_planning_formatter
|
65
|
+
changelog_uri: https://github.com/adrianshort/merton_planning_formatter/CHANGELOG.md
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 2.3.0
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubygems_version: 3.1.2
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Formats planning application descriptions/proposals nicely.
|
85
|
+
test_files: []
|