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
defmodule PhenixDisplays.EnumUtils do | |
@doc """ | |
Make a sliding window of a list | |
## Example | |
iex> alias PhenixDisplays.EnumUtils | |
iex> EnumUtils.sliding([1,2,3], 2) | |
[[1, 2], [2, 3]] | |
iex> EnumUtils.sliding([1,2,3,4], 2) | |
[[1, 2], [2, 3], [3, 4]] |
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
extends Control | |
var pressed = false | |
var offset = Vector2() | |
####### | |
func _gui_input(event): | |
if Input.is_action_just_pressed("left_click") and is_mouse_on_title(): | |
pressed = true |
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
alias love="/Applications/love.app/Contents/MacOS/love" |
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
import scala.io.Source | |
object InvertedIndex { | |
/** | |
* Build an inverted index from a file with this format: | |
* doc0 w0 w1 ... | |
* doc1 w2 w4 ... | |
* Each elements of a line is separated by whitespaces | |
* |
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
word0 document0.txt document1.txt | |
word1 document0.txt | |
word5 document0.txt document1.txt | |
word7 document1.txt |
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
document0.txt word0 word1 word5 | |
document1.txt word0 word5 word7 |
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
package controllers | |
import config.{EndpointConfig => Config} | |
import play.api.mvc._ | |
import play.api.Play.current | |
import play.api.libs.ws.{WSRequest, WS} | |
import scala.concurrent.Future | |
import scala.concurrent.ExecutionContext.Implicits.global |
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
object Marker { | |
val start = "<s>" | |
val end = "</s>" | |
} | |
object NGram { | |
def build(t: String, n: Int): NGram = { | |
NGram(addProbability(addCount(t.split("\n").flatMap(l => | |
sliding(l.split(" ").toList, n)).toList), n), n) | |
} |
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
val ngram = (List.fill(n - 1)("<s>") ++ tokens :+ "</s>") | |
.sliding(n) | |
.toList | |
// Same song | |
val ngramWithCount = ... | |
val ngramWithProbabilityFaster = ... |
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
val sumIndex = ngramWithCount.groupBy { case (k, v) => k.take(n - 1) }.mapValues(_.values.sum) | |
val ngramWithProbabilityFaster = ngramWithCount.map { case (k, v) => | |
(k, v.toDouble / sumIndex(k.take(n - 1))) | |
} | |
// Map(List(eating, the) -> 1.0, List(blue, sky) -> 1.0, List(red, koala) -> 1.0, List(near, the) -> 1.0, List(The, blue) -> 1.0, List(the, sky) -> 0.5, List(koala, eating) -> 1.0, List(sky, is) -> 1.0, List(the, red) -> 0.5, List(is, near) -> 1.0) |
NewerOlder