aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2015-02-26 16:16:07 +0100
committerJochen Topf <jochen@topf.org>2015-02-26 16:16:07 +0100
commit2a61dab2ed4361b880a318e2b1d68317f3a2ae43 (patch)
tree5606a7134ec1aa693f9ab61c4214e502e52e0598
parent128e7ac9bf397539834148ca9c7b58fd44cbfbf6 (diff)
downloadtaginfo-2a61dab2ed4361b880a318e2b1d68317f3a2ae43.tar
taginfo-2a61dab2ed4361b880a318e2b1d68317f3a2ae43.tar.gz
Add (hidden) similar keys tab on key page and similar keys report.
This commit adds the new tab and new report but doesn't activate them, because they will not work until the database backend is updated.
-rw-r--r--web/i18n/en.yml18
-rw-r--r--web/lib/reports.rb1
-rw-r--r--web/views/key.erb6
-rw-r--r--web/views/reports/similar_keys.erb16
-rw-r--r--web/viewsjs/key.js.erb25
-rw-r--r--web/viewsjs/reports/similar_keys.js.erb36
6 files changed, 102 insertions, 0 deletions
diff --git a/web/i18n/en.yml b/web/i18n/en.yml
index cb7ec28..8c9103d 100644
--- a/web/i18n/en.yml
+++ b/web/i18n/en.yml
@@ -342,6 +342,13 @@ pages:
projects:
title: Projects using this key
description: How this key is used in the project
+ similar:
+ tab: Similar
+ title: Similar keys
+ other: Similar keys
+ count_all_tooltip: Number of objects with the similar key
+ similarity: Similarity
+ similarity_tooltip: Smaller numbers mean more similar
tag:
description_from_wiki: Description of this tag from the wiki (if available in your chosen language, otherwise in English).
no_description_in_wiki: No English language description for this tag in the wiki. (See also the "Wiki" tab.)
@@ -609,4 +616,15 @@ reports:
it just shows the building blocks that can be used to describe languages
irrespective of whether they are actually used in OSM.
</p>
+ similar_keys:
+ name: Similar keys
+ intro: |
+ This reports shows keys used very often and similar keys used very
+ rarely. This exposes many misspellings of common keys, but is not
+ perfect. Take care when fixing the data!
+ key_common: Commonly used keys
+ key_rare: Rarely used keys
+ count_common: Count
+ count_rare: Count
+ similarity: Similarity
diff --git a/web/lib/reports.rb b/web/lib/reports.rb
index 0611744..a822476 100644
--- a/web/lib/reports.rb
+++ b/web/lib/reports.rb
@@ -60,4 +60,5 @@ Report.new 'Language comparison table for keys in the wiki', :wiki
Report.new 'Languages', :wiki
Report.new 'Wiki pages about non-existing keys', :db, :wiki
Report.new 'Name tags'
+#Report.new 'Similar keys', :db
diff --git a/web/views/key.erb b/web/views/key.erb
index b13aaf5..8724b24 100644
--- a/web/views/key.erb
+++ b/web/views/key.erb
@@ -38,6 +38,7 @@
<li><a href="#overview"><%= h(t.taginfo.overview) %></a></li>
<li><a href="#values"><%= h(t.osm.values) %></a></li>
<li><a href="#combinations"><%= h(t.taginfo.key_combinations) %></a></li>
+<!-- <li><a href="#similar"><%= h(t.pages.key.similar.tab) %></a></li>-->
<li><a href="#map"><%= h(t.taginfo.map) %></a></li>
<li><a href="#wiki"><%= h(t.sources.wiki.name) %></a></li>
<li><a href="#projects"><%= h(t.taginfo.projects) %></a></li>
@@ -69,6 +70,11 @@
<table id="grid-keys">
</table>
</div>
+<!-- <div id="similar">
+ <h2><%= h(t.pages.key.similar.title) %></h2>
+ <table id="grid-similar">
+ </table>
+ </div>-->
<div id="map">
<h2><%= h(t.pages.key.geographic_distribution.title) %></h2>
<% if @filter_type == 'all' %>
diff --git a/web/views/reports/similar_keys.erb b/web/views/reports/similar_keys.erb
new file mode 100644
index 0000000..cc57929
--- /dev/null
+++ b/web/views/reports/similar_keys.erb
@@ -0,0 +1,16 @@
+<div class="pre">
+ <h1><%= t.reports.similar_keys.name %></h1>
+ <%= t.reports.similar_keys.intro %>
+</div>
+<div class="box resize">
+ <table id="grid-keys">
+ </table>
+</div>
+<% javascript do
+ JS.raw(<<"JAVASCRIPT")
+function page_init2() {
+// create_flexigrid();
+}
+JAVASCRIPT
+end
+%>
diff --git a/web/viewsjs/key.js.erb b/web/viewsjs/key.js.erb
index 165f91f..8f19ab2 100644
--- a/web/viewsjs/key.js.erb
+++ b/web/viewsjs/key.js.erb
@@ -83,6 +83,31 @@ var create_flexigrid_for = {
}
});
},
+ similar: function(key) {
+ create_flexigrid('grid-similar', {
+ url: '/api/4/key/similar?key=' + encodeURIComponent(key),
+ colModel: [
+ { display: '<%= h(page.similar.other) %>', name: 'other_key', width: 500, sortable: true },
+ { display: '<span title="<%= h(page.similar.count_all_tooltip) %>"><%= h(misc.count) %></span>', name: 'count_all', width: 160, sortable: true, align: 'right' },
+ { display: '<span title="<%= h(page.similar.similarity_tooltip) %>"><%= h(page.similar.similarity) %></span>', name: 'similarity', width: 100, sortable: true, align: 'right' }
+ ],
+ searchitems: [
+ { display: '<%= h(page.similar.other) %>', name: 'other_key' }
+ ],
+ sortname: 'other_key',
+ sortorder: 'asc',
+ preProcess: function(data) {
+ data.rows = jQuery.map(data.data, function(row, i) {
+ return { 'cell': [
+ link_to_key_with_highlight(row.other_key, key),
+ row.count_all,
+ row.similarity
+ ] };
+ });
+ return data;
+ }
+ });
+ },
wiki: function(key, filter_type) {
create_flexigrid('grid-wiki', {
url: '/api/4/key/wiki_pages?key=' + encodeURIComponent(key),
diff --git a/web/viewsjs/reports/similar_keys.js.erb b/web/viewsjs/reports/similar_keys.js.erb
new file mode 100644
index 0000000..1ea191e
--- /dev/null
+++ b/web/viewsjs/reports/similar_keys.js.erb
@@ -0,0 +1,36 @@
+<%
+ osm = @trans.t.osm
+ misc = @trans.t.misc
+ sim = @trans.t.reports.similar_keys
+ %>
+function page_init() {
+ up = function() { window.location = '/reports'; };
+ create_flexigrid('grid-keys', {
+ url: '/api/4/keys/similar',
+ colModel: [
+ { display: '<%= h(sim.key_common) %>', name: 'key_common', width: 350, sortable: true },
+ { display: '<%= h(sim.count_common) %>', name: 'count_all_common', width: 100, sortable: true, align: 'right' },
+ { display: '<%= h(sim.key_rare) %>', name: 'key_rare', width: 350, sortable: true },
+ { display: '<%= h(sim.count_rare) %>', name: 'count_all_rare', width: 100, sortable: true, align: 'right' },
+ { display: '<%= h(sim.similarity) %>', name: 'similarity', width: 100, sortable: true, align: 'right' }
+ ],
+ searchitems: [
+ { display: '<%= h(osm.key) %>', name: 'common_key' }
+ ],
+ sortname: 'count_all_common',
+ sortorder: 'desc',
+ preProcess: function(data) {
+ data.rows = jQuery.map(data.data, function(row, i) {
+ return { 'cell': [
+ link_to_key(row.key_common),
+ row.count_all_common,
+ link_to_key(row.key_rare),
+ row.count_all_rare,
+ row.similarity
+ ] };
+ });
+ return data;
+ }
+ });
+}
+