Giter Club home page Giter Club logo

hs-openmoji-data's Introduction

hs-openmoji-data

Built with Nix Haskell Hackage Github CI BSD3 License

The OpenMoji emoji dataset for use in Haskell programs.

For emoji fonts, images, and spritesheets, please consult the documentation at openmoji.org.

Updating the emojis

Use nix-thunk to update the pinned version of openmoji and then use the generator script to produce a new Data.hs file:

nix-thunk update ./openmoji
./gen.sh

Versioning

Versions of this package should correspond to the OpenMoji version number used to generate the data.

Example Usage

> {-# Language LambdaCase #-}
> {-# Language OverloadedStrings #-}
>
> import Control.Monad
> import Data.Map (Map)
> import qualified Data.Map as Map
> import Data.Text (Text)
> import qualified Data.Text as T
> import System.Environment
> import Text.Emoji (emojiFromAlias)
> import Text.Emoji.OpenMoji.Data
> import Text.Emoji.OpenMoji.Types
>
> emojiMap :: Map Text OpenMoji
> emojiMap = Map.fromList $ map (\x -> (_openMoji_emoji x, x)) openmojis
> 
> main :: IO ()
> main = do
>   requestedAliases <- getArgs
>   when (null requestedAliases) $
>     putStrLn "Please search for at least one emoji alias (e.g., \"bricks\")"
>   forM_ requestedAliases $ \alias ->
>     case (\e -> Map.lookup e emojiMap) =<< emojiFromAlias (T.pack alias) of
>       Nothing -> putStrLn $ "Results for '" <> alias <> "': None"
>       Just openmoji -> do
>         putStrLn $ "Results for '" <> alias <> "':"
>         printOpenMojiInfo openmoji
>
> versionedSvg :: Text -> Text -> Text
> versionedSvg rev hex = mconcat
>   [ "https://raw.githubusercontent.com/hfg-gmuend/openmoji/"
>   , rev
>   , "/color/svg/"
>   , hex
>   , ".svg"
>   ]
>
> pinnedRevision :: Text
> pinnedRevision = "4a80b536eb62a78822548a2aa371426f912d7e9d" -- v13
>
> printOpenMojiInfo :: OpenMoji -> IO ()
> printOpenMojiInfo o = putStrLn $ T.unpack $ T.unlines
>   [ "Emoji:      " <> _openMoji_emoji o
>   , "Hexcode:    " <> _openMoji_hexcode o
>   , "Annotation: " <> _openMoji_annotation o
>   , "Group:      " <> _openMoji_group o
>   , "Sub-Group:  " <> _openMoji_subgroups o
>   , "Tags:       " <> T.intercalate ", " (_openMoji_tags o)
>   , "SVG:        " <> versionedSvg pinnedRevision (_openMoji_hexcode o)
>   ]

This program will do something like the following:

Results for 'bricks':
Emoji:      ๐Ÿงฑ
Hexcode:    1F9F1
Annotation: brick
Group:      travel-places
Sub-Group:  place-building
Tags:       bricks, clay, mortar, wall
SVG:        https://raw.githubusercontent.com/hfg-gmuend/openmoji/4a80b536eb62a78822548a2aa371426f912d7e9d/color/svg/1F9F1.svg

Results for 'pilot':
Emoji:      ๐Ÿง‘โ€โœˆ๏ธ
Hexcode:    1F9D1-200D-2708-FE0F
Annotation: pilot
Group:      people-body
Sub-Group:  person-role
Tags:       plane
SVG:        https://raw.githubusercontent.com/hfg-gmuend/openmoji/4a80b536eb62a78822548a2aa371426f912d7e9d/color/svg/1F9D1-200D-2708-FE0F.svg

About the Emojis

All emojis designed by OpenMoji โ€“ the open-source emoji and icon project. License: CC BY-SA 4.0

hs-openmoji-data's People

Contributors

alexfmpe avatar ali-abrar avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.