ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - eljojo/ex_chain: Simple Markov Chain written in Elixir
Simple Markov Chain written in Elixir. Contribute to eljojo/ex_chain development by creating an account on GitHub.
Visit Site

GitHub - eljojo/ex_chain: Simple Markov Chain written in Elixir

GitHub - eljojo/ex_chain: Simple Markov Chain written in Elixir

ExChain

Very simple Markov Chain written in Elixir. This is my toy-project, so I can learn Elixir.

If you have experience with Elixir and find improvements, please let me know, or simply write a comment in the appropiate line. All suggestions are more than welcome.

It's mostly based in the Markov Models in Ruby tutorial.

The Markov Model creates funny messages based on tweets downloaded from your Twitter Archive.

It generates messages like this.

How to run this?

The first thing you need is Elixir. If you have a Mac, you can install it using brew install elixir.

This program needs your twitter archive, so go ahead and dowload it from your settings in twitter.com.

Download the repository with git clone [email protected]:eljojo/ex_chain.git. Extract your twitter archive, and put the contents of the data/js/tweets folder into ex_chain/data.

$ cd ex_chain
$ mix deps.get # get the dependencies using mix, Elixir's rake. Analog to bundle install.
$ iex -S mix # analog to irb or rails console

Inside iex, you can generate new messages by typing:

iex(1)> {:ok, model} = ExChain.MarkovModel.start_link
{:ok, #PID<0.126.0>}
iex(2)> ExChain.MarkovModel.populate_model(model, ExChain.FileDatasource.get_data)
{:ok}
iex(3)> ExChain.SentenceGenerator.create_filtered_sentence(model)
{:ok, "I'm not a Food Social Network?", 0.4668037713169559, 4}
iex(4)> ExChain.SentenceGenerator.create_filtered_sentence(model)
{:ok, "I am in churros.", 0.30839889769910056, 2}
iex(5)> ExChain.SentenceGenerator.create_filtered_sentence(model)
{:ok, "I'm never sleeping again.", 0.3546596799639396, 14}
iex(6)> ExChain.SentenceGenerator.create_sentence(model)
{"future: scumbag apple: makes you release the happiness hormone.",
 0.8334241103848947}
iex(7)> ExChain.SentenceGenerator.complete_sentence(model, "i love")
{"i love the smell of shipping technical debt", 0.6685185185185185}

Where's the code?

The meat and potatos are located in just three files:

File what it does
lib/ex_chain/file_datasource.ex This file parses the tweets located in the data folder.
lib/ex_chain/markov_model.ex This file is in charge of holding the state of the "Markov Model".
lib/ex_chain/sentence_generator.ex This file generates the sentences using the Markov Model.

CLI

ExChain also has a CLI interface. To use it, you first need to compile the application into an escript (Erlang VM) binary.

$ mix escript.build
$ ./ex_chain generate_sentence
I think currywurst is the best time to wake up.

Suggestions

Please send me all your suggestions to @eljojo or directly to my email jojo at eljojo dot net.

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory