Comments (5)
I copied the HTML source for https://encycolorpedia.com/named, then pretty-printed it and removed everything but the <li>
tags containing the color data. I ended up with a 1,690 line file that looks like this:
I'll write a script in a bit to parse out the data we want, then manually sanitize the names and make sure none are duplicates of the current list
from color-names.
Alright I started working on it now.
I used this regular expression to parse the HTML: view on regexr.com*
/\t\t<li><a href=\/([0-9a-z]{6}) style=background-color:#\1(?:;color:#fff)?>(.*?)<br>#\1<\/a>/g
The RegExp defines two capture groups:
- The six-character hexadecimal color code
- The color name
Using Sublime Text's "Find and Replace" option, I used the stated RegExp as the "Find" field, and for "Replace" I used $2,#$1,
. $2
gets replaced with the second capture group (the color name), and $1
gets replaced with the first (the hex code). The result is a properly formatted CSV
file that matches the structure of the source colornames.csv
file.
Now I need to sanitize the color names to be more descriptive with less words, and I also need to remove the HTML escape sequences. A couple examples of names that should be fixed are:
Dyestalk red (lit. the color from dying with the stalk of the beni plant) (Bengara-iro)
Weathered bamboo (lit. "sooty") (Susutake-iro)
And then I'm gonna merge the file into colornames.csv
, resolve any name or hex conflicts, and finally, when all is ready, I'll submit a PR.
* regexr.com has a bug that can cause the pattern to fail when initially loading it:
To make the pattern load properly, add any arbitrary character to the end of the regex pattern, then delete it. After that, it should load as intended
from color-names.
I've run into something I'm not quite sure of - the following color definitions exist in the new data:
Chinese Black,#141414,
Chinese Blue,#365194,
Chinese Bronze,#cd8032,
Chinese Brown,#ab381f,
Chinese Gold,#cc9900,
Chinese Green,#d0db61,
Chinese Orange,#f37042,
Chinese Pink,#de70a1,
Chinese Purple,#720b98,
Chinese Red,#aa381e,
Chinese Silver,#cccccc,
Chinese Violet,#856088,
Chinese White,#e2e5de,
Chinese Yellow,#ffb200,
The way I interpret this is as a list of colors that are used in Chinese architecture. However, my concern is for situations where a user isn't presented with this full list of "Chinese" colors, but rather just a single value. In particular, the "Chinese Brown" and "Chinese Yellow" names could be interpreted as labels for skin color if no additional context is presented to the user. We can't predict all of the ways this API might be used, so that scenario is definitely a possibility.
So my question is: Should we come up with more specific names for these colors to clarify what they represent, should we simply remove the ones that could be misinterpreted, or am I possibly just overthinking this?
from color-names.
Welp, it's official: I'm dumb.
I finally finished manually sanitizing all ~1500 color names, then ran npm run test
, only to realize that all of these colors have already been added to the list.
At least I documented my process here, so other people might potentially learn from it ¯\_(ツ)_/¯ tbh even if the only thing they learn is to check if someone's already done what you're about to do, that's okay - evidently it's a mistake that even experienced developers make :P
In my defence, I was low on sleep when I started working on this issue
from color-names.
whaaat?! Noooooo but nice effort! There are plenty of other lists that are not imported yet if you want to try your luck on an other one. It would be especially interesting to know if there was a cool way to import the diffs from the wikipedia color name page from time to time. thanks a lot for your time! I appreciate your contribution!
from color-names.
Related Issues (20)
- i18n HOT 3
- Color Groups HOT 2
- Fix: Shell command built from environment values
- Examples In README Do Not Work HOT 1
- Adding ton of colors! HOT 1
- Fix typo "sematnic". HOT 2
- Add Chinese traditional colors HOT 6
- REST API: round response values to 5 decimals
- get some color names from https://colornames.org/ HOT 5
- just an idea HOT 1
- Suggestion For Name Recognition HOT 1
- Color issue HOT 1
- When passing in a hex code to get color name, the hex code needs to be in lower case. So it would be better to accept uppercase too HOT 1
- Use AI to write a description for every single color HOT 1
- Colour Lovers? HOT 1
- Name collision + typo HOT 2
- Yet another name collision HOT 2
- Bad color name for light red and light blue HOT 2
- Professenial color names HOT 1
- Spelling error in README.md HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from color-names.