Skip to content

Latest commit

 

History

History
424 lines (299 loc) · 6.42 KB

ProgrammingForLinguistics.org

File metadata and controls

424 lines (299 loc) · 6.42 KB

1 - Generic Introduction to Programming

Notes

Basic Introduction to Programming Languages

Python/Anaconda

Haskell

Visualization - ClojureScript

Java - OpenNLP

Introduction to CodeSharing and Community

Git

GitHub

GitLab

Pages

DataBases

SQLite3

Mongo

Neo4J

MySQL

Redis **

Leading to Good resources in

Artificial Intelligence

Foundations of Computing

Data Science

2 - Introduction to Clojure

Notes

On a personal note, the best thing about Lisp is that it builds a solution from bottom up - and for creators of a systems it’s - I believe ideal , however to understand another system - the top-down approach is the one that prevails - read from top-down and read a lot!

Minimal buildling blocks of logic

conditions/ relationals/ booleans/loops

recursion - hint that we’ll return to it again later

3 - Setting up the Lab

Notes

Setting up the Clojure and focusing initially only on the REPL

Later on we just move on to FileSystem/API/WebPage based work

4 - Alphabet

Notes

The ASCII value of a character

(int \汉)

Alphanumeric characters in the word

cuerdas - only alphabets in the words

  (require '[cuerdas.core :as cuerdas])


  (cuerdas/alpha? "word")


  (cuerdas/alpha-numeric? "word 123")

  (cuerdas/alnum? "word 123")

(cuerdas/letters? "汉语")

INDEX of an alphabet in a word

using the index of the alphabet

(.indexOf  word "o")

find the LAST index of a character

LENGTH of a word

get the length of a word

(.length  word)

native- empty?

(.isEmpty word)

Get a SUBWORD

native - index-range SUBSTRING

(.substring word 1 3)

native - SUBSEQUENCE

(.subSequence word 1 3)

Case of a word

native - uppercase

(.toUpperCase word)

native - lowercase

(.toLowerCase word)

Dealing with whitespaces

native - trim

(.trim "   word  ")

native

Here, the (.toCharArray ) method gives us a Java Array object

we can deal with an Array object using ( get ) method from Clojure

(get (.toCharArray "word") 0)

 (require '[cuerdas.core :as cuerdas])


(cuerdas/chars "characters")

(str "a" "b" "c")

Splitting a sentence

(get (.split "name is bond" " ") 2)

(def ls (list "this" "is" "a" "list"))

(peek ls)
(first ls)
(rest ls)
(last ls)
(peek ls)


dropping n items

(drop 3 ls)

finding elements in the list

(.indexOf "a" ls)

(.lastIndexOf "a" ls)

building up from empty lists

  • doesn’t really matter if we quote it or not
(cons 'a ())

(conj 'ls '("cons"))
(concat ls '("cons"))

general native functions for collections/sequences

count 
empty
not-empty
into 
conj

distinct?
every?
empty?
not-every?
some
not-any?

stuff from clojure.walk - no idea what this does?!!

(use '[clojure.walk :as walk])

walk
prewalk
prewalk-demo
prewalk-replace

postwalk
postwalk-demo
postwalk-replace

capabilities

sequential?
associative?
sorted?
counted?
reversible?

Vector

Map

Set

8 - Algorithms from books

Algorithms Unlocked

ch2

pg28 - Linear Search

(def ls '("this" "is" "a" "list"))
(for [x (range (length-of-list ls))]
        (println ( nth ls x)))
Linear Search
  • we don’t know what exactly a symbol is
  • we need to look into a
(def ls '("this" "is" "a" "list"))

(def look-up (read-line))

(defn length-of-list [ls]
  (count ls))


(for [x (range (length-of-list ls))]
  (if ( = look-up  ( nth ls x))
    x
    nil
    ))

pg29 - better linear search

pg30 - sentinel linear search

9 - Algorithms for Linguists

LATER

More on Clojure and LISP as it’s heritage

Introduction to the DSL

A basic overview of the DSL we’ve created to work with.

Need to provide a basic WordNet etc. integration for the Clojars.org package

Java interop

introduce all the native methods in this case

use StanfordNLP - java as an example

Language Construction Kit and simulations based on that book

Asking Questions from Clojure ( and Emacs? )

Importing libraries and concept of namespaces in Clojure

Regular Expressions

Code Structure and Documentation

Our Understanding of a Language

The depth of chunking a language we try out.

Clarify that we abstract away from the Cultural Contexts in a language.

How to design programs

sicp

introduction to algorithms

Algorithms - cormen