Skip to content

Instantly share code, notes, and snippets.

@vseloved
vseloved / dwim-graph.lisp
Last active August 29, 2024 09:07
Simple generation of graph images using dot (and cl-dot)
(defclass dwim-graph () ())
(defmethod cl-dot:graph-object-node ((graph (eql 'dwim-graph)) object)
(make-instance 'cl-dot:node
:attributes (list :label (format nil "~A" object)
:shape :circle)))
(defmacro dwim-graph ((file &key (directed t)) &body edges)
`(progn
(eval-when (:compile-toplevel :load-toplevel :execute)
@vseloved
vseloved / rutils-tutorial.md
Last active August 29, 2024 09:07
RUTILS Tutorial

RUTILS Tutorial

Overview

RUTILS is split into two parts: core (package rutils) and contrib (package rutilsx). These are aggregate packages that just re-export the symbols that are provided by the specific packages like rutils.anaphora or rutils.list. Overall, there are 17 parts of the core, which are described, in more detail, in this tutorial. They include (with some changes and additions) 3 facilities, which are also available from separate libraries: SPLIT-SEQUENCE, ITERATE, and ANAPHORA. Besides, it defines 2 lightweight wrapper data structures: pair and hash-set.

There's also the package rtl that includes the core plus short names for a lot of basic Lisp operations.

Contrib holds "experimental" stuff (in the sense that it's not totally conventional even for me) that, gradually, migrates to core. I won't talk more about it in the tutorial: those who are interested can check on their own or ask questions.

@vseloved
vseloved / unit-numbers.lisp
Created August 19, 2019 06:37
Prototype of dimensional numbers implementation
(set-dispatch-macro-character #\# #\M #'read-dimensional-number)
(set-dispatch-macro-character #\# #\I #'read-dimensional-number)
(defun read-dimensional-number (s c n)
(declare (ignore n))
(let* ((prev-case (readtable-case *readtable*))
(val (unwind-protect
(progn (setf (readtable-case *readtable*) :preserve)
(symbol-name (read s nil)))
(setf (readtable-case *readtable*) prev-case)))

Теми курсових проектів

Проекти, для яких немає готових корпусів

  1. Визначення зв’язків між сутностями на основі даних з Wikipedia, Freebase, DBPedia тощо для української мови.
  2. Визначення суб’єктивних висловлювань в текстах новин (зокрема, новин українською мовою).
  3. Генерація поезії. Доступні дані: сайти з віршами, словники рим тощо.
  4. POS-tagging для української мови. Проанотованих корпусів немає, але є граматичний словник та корпуси сирих текстів.
  5. Перевірка правопису для української мови. Дані можна проанотувати через LanguageTool; також схожий проект є тут.
  6. Автоматична генерація відповідей на запитання. Дані можна брати з Вікіпедії чи https://ukrainian.stackexchange.com (та інших SE сайтів).
@vseloved
vseloved / aoc9-deck.lisp
Last active August 29, 2024 09:09
Advent of Code #9
(defun play-game (max-players last-marble)
(let ((scores (make-hash-table))
(marbles (deque 0)))
(dotimes (marble (1+ last-marble))
(case (mod (1+ marble) 23)
(0 (drotate marbles 7)
(incf (gethash (rem marble max-players) scores 0)
(+ 1 marble (popl marbles))))
(t (drotate marbles -2)
(pushl (1+ marble) marbles))))
@vseloved
vseloved / nnse.lisp
Created April 19, 2017 14:41
Unfinished code for NNSE calculation
(in-package #:nlp.embeddings)
(named-readtables:in-readtable rutilsx-readtable)
(eval-always
(rename-package "BKNR.SKIP-LIST" "BKNR.SKIP-LIST" '("SKLIST")))
(defun gather-freq-dict (vecs dir &key (cutoff 0) (dump-file "/tmp/dict.txt"))
(let ((dict #h(equal))
(idxs #h(equal))
@vseloved
vseloved / stage1.lisp
Last active January 27, 2017 13:59
Filter Cyrillic texts with Ukrainian letters from CC WET files
(let (cur)
(with-output-to-string (out)
(loop :for line := (read-line *standard-input* nil) :while line :do
(cond
((string= #.(format nil "WARC/1.0~C" #\Return) line)
(setf cur :header)
(let* ((outstr (string-trim '(#\Newline #\Return #\Linefeed)
(get-output-stream-string out)))
(count-i (count-if (lambda (char)
(member char '(#\і #\ї #\є #\І #\Ї #\Є #\Ґ #\ґ)))
@vseloved
vseloved / algorithms-glossary-ru-uk.md
Last active July 1, 2016 22:45
Глоссарий алгоритмических терминов

Глоссарий алгоритмических терминов

Общепринятые

English Русский Українська
queue очередь черга
heap куча купа
tree дерево дерево
graph граф граф
@vseloved
vseloved / generator-send.lisp
Last active May 19, 2016 07:36
Implement generator send with restarts
(define-condition generated ()
((item :initarg :item :reader generated-item)))
(defun yield (&optional item)
(restart-case (signal 'generated :item item)
(resume (&optional item) item)))
(defun send (item generator)
(let (already-triggered)
(handler-bind ((generated (lambda (e)