Archie  Powell

Archie Powell

1658188800

Stemmer: An English (Porter2) Stemming Implementation in Elixir.

Stemmer  

An English (Porter2) stemming implementation in Elixir.

In linguistic morphology and information retrieval, stemming is the process of reducing inflected (or sometimes derived) words to their word stem, base or root form—generally a written word form. The stem need not be identical to the morphological root of the word; it is usually sufficient that related words map to the same stem, even if this stem is not in itself a valid root. - Wikipedia

Usage

The Stemmer.stem/1 function supports stemming a single word (String), a sentence (String) or a list of single words (List of Strings).

Stemmer.stem("capabilities")                    # => "capabl"
Stemmer.stem("extraordinary capabilities")      # => "extraordinari capabl"
Stemmer.stem(["extraordinary", "capabilities"]) # => ["extraordinari", "capabl"]

Compatibility

Stemmer is 100% compatible with the official Porter2 implementation, it is tested against the official diffs.txt which contains more than 29000 words.

Naive Bayes

Stemmer was built to support the Simple Bayes library. :heart:


Author:  fredwu
Source code: https://github.com/fredwu/stemmer
License:

#elixir #machine-learning 

What is GEEK

Buddha Community

Stemmer: An English (Porter2) Stemming Implementation in Elixir.
Archie  Powell

Archie Powell

1658188800

Stemmer: An English (Porter2) Stemming Implementation in Elixir.

Stemmer  

An English (Porter2) stemming implementation in Elixir.

In linguistic morphology and information retrieval, stemming is the process of reducing inflected (or sometimes derived) words to their word stem, base or root form—generally a written word form. The stem need not be identical to the morphological root of the word; it is usually sufficient that related words map to the same stem, even if this stem is not in itself a valid root. - Wikipedia

Usage

The Stemmer.stem/1 function supports stemming a single word (String), a sentence (String) or a list of single words (List of Strings).

Stemmer.stem("capabilities")                    # => "capabl"
Stemmer.stem("extraordinary capabilities")      # => "extraordinari capabl"
Stemmer.stem(["extraordinary", "capabilities"]) # => ["extraordinari", "capabl"]

Compatibility

Stemmer is 100% compatible with the official Porter2 implementation, it is tested against the official diffs.txt which contains more than 29000 words.

Naive Bayes

Stemmer was built to support the Simple Bayes library. :heart:


Author:  fredwu
Source code: https://github.com/fredwu/stemmer
License:

#elixir #machine-learning 

GraphQL Elixir: An Elixir Implementation Of Facebook's GraphQL.

GraphQL Elixir

An Elixir implementation of Facebook's GraphQL.

This is the core GraphQL query parsing and execution engine whose goal is to be transport, server and datastore agnostic.

In order to setup an HTTP server (ie Phoenix) to handle GraphQL queries you will need plug_graphql. Examples for Phoenix can be found at hello_graphql_phoenix, so look here for a starting point for writing your own schemas.

Other ways of handling queries will be added in due course.

Installation

First, add GraphQL to your mix.exs dependencies:

defp deps do
  [{:graphql, "~> 0.3"}]
end

Add GraphQL to your mix.exs applications:

def application do
  # Add the application to your list of applications.
  # This will ensure that it will be included in a release.
  [applications: [:logger, :graphql]]
end

Then, update your dependencies:

$ mix deps.get

Usage

First setup your schema

defmodule TestSchema do
  def schema do
    %GraphQL.Schema{
      query: %GraphQL.Type.ObjectType{
        name: "RootQueryType",
        fields: %{
          greeting: %{
            type: %GraphQL.Type.String{},
            resolve: &TestSchema.greeting/3,
            description: "Greeting",
            args: %{
              name: %{type: %GraphQL.Type.String{}, description: "The name of who you'd like to greet."},
            }
          }
        }
      }
    }
  end

  def greeting(_, %{name: name}, _), do: "Hello, #{name}!"
  def greeting(_, _, _), do: "Hello, world!"
end

Execute a simple GraphQL query

iex> GraphQL.execute(TestSchema.schema, "{greeting}")
{:ok, %{data: %{"greeting" => "Hello, world!"}}}

Status

This is a work in progress, right now here's what is done:

  •  Parser for GraphQL (including Type definitions)
  •  AST matching the graphql-js types as closely as possible
  •  Schema definition
  •  Query execution
    •  Scalar types
    •  Arguments
    •  Multiple forms of resolution
    •  Complex types (List, Object, etc)
    •  Fragments in queries
    •  Extract variable values
  •  Introspection
  • [WIP] Query validation
  •  Directives

Resources

Implementation

Tokenisation is done with leex and parsing with yecc. Both very useful Erlang tools for parsing. Yecc in particular is used by Elixir itself.

Some resources on using leex and yecc:

The Execution logic follows the GraphQL JS Reference Implementation pretty closely, as does the module structure of the project. Not to mention the naming of files and concepts.

If you spot anything that isn't following Elixir conventions though, that's a mistake. Please let us know by opening an issue or a PR and we'll fix it.

Developers

Getting Started

Clone the repo and fetch its dependencies:

$ git clone https://github.com/graphql-elixir/graphql.git
$ cd graphql
$ mix deps.get
$ mix test

Atom Editor Support

Using the language-erlang package? .xrl and .yrl files not syntax highlighting?

Syntax highlighting in Atom for leex (.xrl) and yecc (yrl) can be added by modifying grammars/erlang.cson.

Just open the atom-language-erlang package code in Atom and make the change described here:

https://github.com/jonathanmarvens/atom-language-erlang/pull/11

however if that PR has been merged then just grab the latest version of the plugin!

Contributing

We actively welcome pull requests, bug reports, feedback, issues, questions. Come and chat in the #erlang channel on Slack

If you're planning to implement anything major, please let us know before you get too far so we can make sure your PR will be as mergable as possible. Oh, and don't forget to write tests.


Author: graphql-elixir
Source Code: https://github.com/graphql-elixir/graphql
License: View license

#elixir #graphql 

Lilyan  Streich

Lilyan Streich

1603342380

Ruby vs Elixir—Which One to Choose in 2020?

Over the past couple of years, we wrote extensively about Ruby (and Ruby on Rails), so you know we like it a lot.

We’ve also dabbled some in Elixir (and Phoenix), but never before have we compared the two side by side to see which one can be a better fit for you and when. So here it goes.

The Story of Ruby and Elixir (and Phoenix)

Ruby and Ruby on Rails probably need no introduction. They are both widely used tools for writing web applications. Ruby, created as far back as 1995, was built to make the developer work more productive and fun. Ruby on Rails lets developers write applications fast with the use of many gems—libraries with features. In the hands of experienced developers, RoR is an excellent Web development framework for building highly functional, usable, and robust Web apps.

RoR has changed the landscape of Web app development. By introducing tools that facilitate fast app development and focusing on the pleasurable aspect of coding, it set the direction other Web frameworks soon followed.

Ruby and Elixir share many similarities. Elixir’s creator, José Valim, was a Rails core team member. He appreciated Ruby’s flexibility and clean and elegant syntax, but the more he worked with Ruby, the more room for improvement he began to notice. His main concern revolved around Ruby’s code limits in concurrency and throughput. It became clear to José what he needed to do—take what’s best in Ruby and build something entirely different on top of it. Based on the Erlang VM to solve concurrency limitations, Elixir was conceived.

As to Phoenix, a web framework for Elixir, it was put together by Chris McCord. Having come from the same Rails background as José, Chris borrowed essential ingredients from Rails to his Phoenix project, with an intention to create a framework that would ultimately outperform Rails.

#ruby/rails #elixir #development #ruby and elixir

How to Build a Simple Slack Bot with Elixir Phoenix?

Do you know what happens when you type/giphy sorry no can do  in one of your Slack channels? A funny gif pops up, so instead of explaining to your teammates why a particular task will require a bit more work than anticipated, you let them know by sending this:

That is, in short, what a Slack bot does.

It’s been some time since I became interested in Elixir and I finally decided to do something fun with it on my way to mastering it. I went with creating a small Slack bot with slash commands and I’ll show you how to make your own in a short tutorial I compiled below.

Let’s get to it.

One caveat before we start—this tutorial is just a proof of concept as I’ve never either:

  1. used the Slack API before,
  2. deployed anything with Elixir.

So, how to build a Slack bot step by step? Well, we want to:

  1. create a simple REST API with Elixir to accept commands from Slack,
  2. deploy it,
  3. create a Slack app with a slash command communicating with the Elixir API,
  4. introduce the app to the team and test the connection.

#elixir #slack bot #elixir phoenix #development

Why Learn Elixir in 2020? — Elixir Tutorial for Beginners

At Monterail we have fancied the Elixir language for quite a long time. However, for some reasons, we failed to get it into production usage except for a few minor implementations. And I felt like this should change. So when Plataformatec shared the idea on how to learn the language together in teams, within a company, we didn’t hesitate long. In simplest terms—you go through the book for beginners called Learn Functional Programming with Elixir, dedicate each week to the next chapter and do exercises listed at the end of each chapter. Doesn’t it sound like an awesome initiative?

I want to share the reasons why I think you should learn Elixir in 2020. Let’s start with why we got interested in Elixir many years ago.

So we started learning Elixir Phoenix during regular meetings every Friday evening. And then Advent came, also to the coding life and we expanded Elixir education onto participating in the Advent of Code with the language creator, José Valim. AoC is a series of small programming puzzles for a variety of skill sets and skill levels in any programming language you like. It allowed us to learn A LOT in such a short time—it was challenging, exhausting but most above all, really fun!

And as a result of our effort, we managed to introduce Elixir to a key part of our client’s application.

We learned our lessons so I decided to share with you some of my findings, i.e. patterns, specific functions or quirks. A very experienced Elixir developer probably won’t catch much new here but if you are new in the alchemists’ community, you’re more than likely to benefit from it.

Scripting with Elixir — a short tutorial

When you come from the world similar to Ruby, you might have an issue at the beginning with organizing a workflow when you just want to script a small thing. How to test the script with Elixir? Do I need a full mix application? Do I have to recompile the code after every change? Luckily, there is a way:

defmodule Example do
  def fun(bar, baz) do
    ...
  end
end

case System.argv() do
  ["--test"] ->
    ExUnit.start()

    defmodule ExampleTest do
      use ExUnit.Case

      import Example

      test "my code" do
        assert fun() == 1
      end
    end

  [arg1, arg2] ->
    Example.fun(arg1, arg2) |> IO.puts()
end

Simplecase on System.argv() allows you to create a script with tests as simple to run as typing elixir script.exs --test.

And when talking about testing, I cannot keep myself from mentioning Doctest—it’s so cool that it should be banned.

#elixir #development #programming