Skip to content
Snippets Groups Projects
Unverified Commit 43aabfb1 authored by Octavian Geagla's avatar Octavian Geagla Committed by GitHub
Browse files

Humanization (#10174)

* [test] add simple sql humanization tests wip

* [dict][test] humanization tests to keep sql reserved words whole wip

* [humanization] wip inverse+clean dict

* [humanization] test cases

* [humanization] more user test cases

* [humanization] remove certains words from dict
parent b9670cb5
No related branches found
No related tags found
No related merge requests found
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -11,7 +11,7 @@
(def ^:const ^:private special-words ["checkins"])
(defn- slurp-words-by-frequency []
(concat special-words (str/split-lines (slurp (io/resource "words-by-frequency.txt")))))
(concat special-words (str/split-lines (slurp (io/resource "words-by-inv-frequency.txt")))))
;; wordcost = dict((k, log((i+1)*log(len(words)))) for i,k in enumerate(words))
(defn- make-cost-map
......
......@@ -34,6 +34,57 @@
(expect "User Social Auth" (humanization/name->human-readable-name :advanced "usersocialauth"))
;;; db-inspired
(expect "Sum Subtotal" (humanization/name->human-readable-name :advanced "sumsubtotal"))
(expect "Sum(subtotal)" (humanization/name->human-readable-name :advanced "sum(subtotal)"))
(expect "Sum(subtotal)" (humanization/name->human-readable-name :simple "sum(subtotal)"))
(expect "sum(subtotal)" (humanization/name->human-readable-name :none "sum(subtotal)"))
(expect "Created At::date" (humanization/name->human-readable-name :advanced "created_at::date"))
(expect "Created At::date" (humanization/name->human-readable-name :simple "created_at::date"))
(expect "created_at::date" (humanization/name->human-readable-name :none "created_at::date"))
(expect "Date Created" (humanization/name->human-readable-name :advanced "datecreated"))
(expect "Datecreated" (humanization/name->human-readable-name :simple "datecreated"))
(expect "datecreated" (humanization/name->human-readable-name :none "datecreated"))
(expect "Created At" (humanization/name->human-readable-name :advanced "createdat"))
(expect "Create At" (humanization/name->human-readable-name :advanced "createat"))
(expect "Createdat" (humanization/name->human-readable-name :simple "createdat"))
(expect "createdat" (humanization/name->human-readable-name :none "createdat"))
(expect "Updated At" (humanization/name->human-readable-name :advanced "updatedat"))
(expect "Update At" (humanization/name->human-readable-name :advanced "updateat"))
(expect "Updatedat" (humanization/name->human-readable-name :simple "updatedat"))
(expect "updatedat" (humanization/name->human-readable-name :none "updatedat"))
(expect "Cast Created At As Date" (humanization/name->human-readable-name :advanced "castcreatedatasdate"))
(expect "Cast(createdatasdate)" (humanization/name->human-readable-name :simple "cast(createdatasdate)"))
(expect "cast(createdatasdate)" (humanization/name->human-readable-name :none "cast(createdatasdate)"))
(expect "All Alter" (humanization/name->human-readable-name :advanced "allalter"))
(expect "Alter All" (humanization/name->human-readable-name :advanced "alterall"))
(expect "And Any Or" (humanization/name->human-readable-name :advanced "andanyor"))
(expect "Ascdesc" (humanization/name->human-readable-name :advanced "ascdesc"))
(expect "Decimal Default Delete" (humanization/name->human-readable-name :advanced "decimaldefaultdelete"))
(expect "Else End Exist" (humanization/name->human-readable-name :advanced "elseendexist"))
(expect "For From" (humanization/name->human-readable-name :advanced "forfrom"))
(expect "Goto Grant Group" (humanization/name->human-readable-name :advanced "gotograntgroup"))
(expect "If In Insert Is" (humanization/name->human-readable-name :advanced "ifininsertis"))
(expect "Not Null" (humanization/name->human-readable-name :advanced "notnull"))
(expect "Of On Order" (humanization/name->human-readable-name :advanced "ofonorder"))
(expect "Range Select" (humanization/name->human-readable-name :advanced "rangeselect"))
(expect "Table Then To Type" (humanization/name->human-readable-name :advanced "tablethentotype"))
(expect "Union Unique Update" (humanization/name->human-readable-name :advanced "unionuniqueupdate"))
(expect "Values Where With" (humanization/name->human-readable-name :advanced "valueswherewith"))
(expect "Changelog" (humanization/name->human-readable-name :advanced "changelog"))
(expect "Dataflow" (humanization/name->human-readable-name :advanced "dataflow"))
(expect "Bestseller" (humanization/name->human-readable-name :advanced "bestseller"))
(expect "Uniques" (humanization/name->human-readable-name :advanced "uniques"))
(expect "Cpi" (humanization/name->human-readable-name :advanced "cpi"))
(expect "Ctr" (humanization/name->human-readable-name :advanced "ctr"))
(expect "Paid To Sparkify" (humanization/name->human-readable-name :advanced "paid_to_sparkify"))
(expect "Paid To Sparkify" (humanization/name->human-readable-name :advanced "paidtosparkify"))
(expect "Assassinate" (humanization/name->human-readable-name :advanced "assassinate"))
(expect "An Album Cover" (humanization/name->human-readable-name :advanced "analbumcover"))
;;; :simple humanization
(expect nil (humanization/name->human-readable-name :simple nil))
(expect nil (humanization/name->human-readable-name :simple ""))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment