Skip to content

Instantly share code, notes, and snippets.

View lattejed's full-sized avatar
😀

lattejed lattejed

😀
View GitHub Profile
# Vivake Gupta ([email protected])
# http://tartarus.org/martin/PorterStemmer/python.txt
def m(self):
n = 0
i = self.k0
while 1:
if i > self.j:
return n
if not self.cons(i):
measure :: (String, String) -> Int
measure (_,ds) =
length $ filter (=='c') ds'
where ds' = dropWhile (=='c') [head a | a <- group ds]
getstem :: String -> String -> String
getstem str sfx = take (length str - length sfx) str
swapsfx :: String -> String -> String -> String
swapsfx str sfx [] = take (length str - length sfx) str
swapsfx str sfx sfx' = take (length str - length sfx) str ++ sfx'
step1a :: (String, String) -> String
step1a (str,_) = swapsfx str (fst sfxs') (snd sfxs')
where sfxs' = head $ dropWhile (\ss -> not $ fst ss `isSuffixOf` str) sfxs
{-
Step 2
(m>0) ATIONAL -> ATE
...
(m>0) BILITI -> BLE
-}
step2 :: String -> String
step2 str =
if (not $ null sfxs') && (measure $ snd $ wordDesc $ stm (fst sfx)) > 0
then swapsfx str (fst sfx) (snd sfx)
{-
The MIT License (MIT)
Copyright (c) 2103 Matthew Smith [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
git clone git://github.com/ansible/ansible.git
cd ./ansible
sudo make install
sudo easy_install jinja2
sudo easy_install pyyaml
sudo easy_install paramiko
source ./hacking/env-setup
echo "<your server ip x.x.x.x>" > host.ini
ansible all -i host.ini -m ping -u root
# x.x.x.x | success >> {
# "changed": false,
# "ping": "pong"
# }
# bootstrap.yml
---
- hosts: newservers
vars:
- ubuntu_release: raring
- logwatch_email: <your email addy>
# crypted passwords, generated on a Linux box using:
# echo 'import crypt,getpass; print crypt.crypt(getpass.getpass(), "$6$YOURSALT")' | python -
- root_password: ''
ansible-playbook -i hosts.ini bootstrap.yml --user root
int fromPPQ15360TicksToSamples (int ticks, int tempo, int sampleRate)
{
// ticks -> samples
// 3.9025 = 60000 (milliseconds / min) / 15360 (ticks per quarter note)
return (3.9025 * sampleRate * ticks) / (double)tempo;
}
int fromSamplesToPPQ15360Ticks (int sampleOffset, int tempo, int sampleRate)
{
// samples -> ticks