I am in the middle of trying to cleanup several hundred thousand lines of data that is managed by users inputting data into a field. There has been no re-cleaning of the data after input masks were recently set.
Now I am trying to hypothesize given a word(Color) or sentence(may or may not have a Color in it) passed into a function and return its best Color guess.
Is there a library that currently does this that I am not aware of?
Example
Input: INT SATIN BASE
Output: SATIN
Input: Light Red
Output: Red
Input: Latching Box - White
Output: White
You can use python colour
package to check where input keyword is color or not. To install, use pip install colour
>>> from colour import Color
>>> s = 'Light Red'
>>> _color = [i for i in s.split(' ') if check_color(i)]
['Red']
Here is the custom function:
def check_color(color):
try:
Color(color)
return True
except ValueError:
return False
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With