This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Renato Ceolin - 10/28/2020 | |
# Built with elixir 1.11 | |
# To run the code use the comamnd `elixir n_grams.exs` | |
# Tests will be run after the script execution | |
defmodule NGrams do | |
@moduledoc """ | |
NGrams are continguos sequences of words in a sentence | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
def flatten_array(array) | |
raise ArgumentError unless array.class == Array | |
flattened = [] | |
array.each do |item| | |
if item.class == Array | |
flattened += flatten_array(item) | |
else |