Wednesday, October 28, 2009

Python built-in functions

http://docs.python.org/library/functions.html

I heard they're pretty fast

map - maybe better for parallelization purposes
---
>>> l=[1,2,3,4,5]
>>> def dbl(x):
return x*2

>>> map(dbl, l)
[2, 4, 6, 8, 10]

or just
[x*2 for x in l]

set
---
>>> set([1,1,2,2,3,3])
set([1,2,3])

http://stackoverflow.com/questions/672172/how-to-use-python-map-and-other-functional-tools

PuLP - Linear Programming modules for Python

http://www.purplemath.com/modules/linprog.htm
http://code.google.com/p/pulp-or/wiki/OptimisationWithPuLP

http://mail.python.org/pipermail/python-announce-list/2005-May/003989.html
# Borrowed code from Jean-Sebastien, see link above ...
Example script:
--------------------------------------------------
from pulp import *

prob = LpProblem("test1", LpMinimize)

# Variables
x = LpVariable("x", 0, 4)
y = LpVariable("y", -1, 1)
z = LpVariable("z", 0)

# Objective
prob += x + 4*y + 9*z

# Constraints
prob += x+y <= 5
prob += x+z >= 10
prob += -y+z == 7

GLPK().solve(prob)

# Solution
for v in prob.variables():
print v.name, "=", v.varValue

print "objective=", value(prob.objective)
--------------------------------------------------
http://www.gnu.org/software/glpk/glpk.html

Linear programming is good for maximization or minimization problems or solving Sudoku puzzles! (http://130.216.209.237/engsci392/pulp/SudokuAsAnLP)

Works by incorporating linear equations ie y = mx + b (objective function) and a bunch of constraints eg 3*x - y <= 3 or something
works like magic!

As for applications, one example is with Punyakanok et al. '04 where he applies it to optimizing the best set of argument labels in semantic role labeling (SRL)
http://l2r.cs.uiuc.edu/~danr/Papers/PRYZ04.pdf

Tuesday, October 20, 2009

Google going global with Apps

http://www.reuters.com/article/technologyNews/idUSTRE59I09A20091019?feedType=RSS&feedName=technologyNews

Cloud computing.

WordNet / VerbNet via Python NLTK

WordNet as thesaurus
>>> from nltk.corpus import wordnet as wn
>>> set([s.name.split('.')[0] for s in wn.synsets('trade') if s.name.find(".v.") != -1])

VerbNet
>>> from nltk.corpus import verbnet
>>> verbnet.classids('drink')
['eat-39.1-2']
>>> v=verbnet.vnclass('39.1-2')
>>> [t.attrib['type'] for t in v.findall('THEMROLES/THEMROLE/SELRESTRS/SELRESTR')]
['comestible', 'solid']
>>> [t.attrib['type'] for t in v.findall('THEMROLES/THEMROLE')]
['Patient']

Clustering
http://docs.huihoo.com/nltk/0.9.5/api/nltk.cluster-module.html
import numpy
from nltk import cluster

vectors = [numpy.array(f) for f in [[3, 3], [1, 2], [4, 2], [4, 0]]]

# initialise the clusterer (will also assign the vectors to clusters)
clusterer = cluster.KMeansClusterer(2, euclidean_distance)
clusterer.cluster(vectors, True)

# classify a new vector
print clusterer.classify(numpy.array([3, 3]))

Named Entities
http://nltk.googlecode.com/svn/trunk/doc/book/ch07.html#named_entity_detection_index_term
>>> import nltk
>>> sent = nltk.corpus.treebank.tagged_sents()[22]
>>> print nltk.ne_chunk(sent)
(S
The/DT
(GPE U.S./NNP)
is/VBZ
one/CD
...
according/VBG
to/TO
(PERSON Brooke/NNP T./NNP Mossman/NNP)
...)

MontyLemmatiser - Strips inflectional morphology, i.e. changes verbs to infinitive form and nouns to singular form eg. eating -> eat
http://web.media.mit.edu/~hugo/montylingua/
>>> from monty.MontyLemmatiser import MontyLemmatiser
>>> lemmatized = MontyLemmatiser().lemmatise_word('eating')

Sunday, October 18, 2009

まんが日本昔ばなし (Nippon Manga folklore)

昔 むかし olden days / former

まんが日本昔ばなし (Nippon Manga folklore)
Bilingual Books

by Sayumi Kawauchi 川内 and Ralph F. McCarthy

http://ja.wikipedia.org/wiki/%E3%81%BE%E3%82%93%E3%81%8C%E6%97%A5%E6%9C%AC%E6%98%94%E3%81%B0%E3%81%AA%E3%81%97

金太郎 きんたろう
桃太郎 ももたろう 桃=peach

太郎 たろう is common name for healthy boys

吃驚 びっくり bikkuri surprise

Friday, October 16, 2009

RPG Games

The World End With You
Suikoden Tierkreis
Kingdom Hearts 358/2 Days***
Valkyrie Profile: Covenant of the Plume
Shin Megami Tensei:Devil Survivor
Dragon Quest V
Black Sigil
FFX12 Revenant Wings

Shin Megami Tensei:Persona 3 and 4 (PS2)

http://ps2.gamezone.com/gzreviews/r29763.htm
http://www.siliconera.com/2009/09/13/ds-rpgs-wheres-my-plot/

***Note: Fix
http://www.romulation.net/forum/index.php?topic=23731
http://www.gbatemp.net/index.php?showtopic=158107
How to manually hex edit KH rom:
1: Google and download a program called XVI32 (hexer for ubuntu). This is the hex editor I used.
2: Open your KH rom.
3: At the top click address, then click goto, then click hexidecimal.
4: Type 010E5DC into the address box and click ok. (or hex value ctrl + f: 01 E2 0C 51 00 0D)
5: The first block should be highlighted and have 0C in it.
6: At the top click edit, click overwrite string, click hex string, in the bottom box type 37 and click ok.
7: Where it said 0C in the first box it should now say 37.
8: Click file, then click save.
9: Put the file you just saved on your flash cart and enjoy :)

Thursday, October 15, 2009

semantic role labelling - SRL

www.cs.brandeis.edu/~cs114/slides/SemanticRoleLabeling.ppt

Semantic Role Labeling – Giving Semantic Labels to Phrases
[AGENT Sotheby’s] offered [THEME a money-back guarantee] to [RECIPIENT the Dorrance heirs]

Applications
-----------------
Question Answering
Q: When was Napoleon defeated?
Look for: [PATIENT Napoleon] [PRED defeat-synset] [ARGM-TMP *ANS*]

Machine Translation
English (SVO) Farsi (SOV)
[AGENT The little boy] [AGENT pesar koocholo] boy-little
[PRED kicked] [THEME toop germezi] ball-red
[THEME the red ball] [ARGM-MNR moqtam] hard-adverb
[ARGM-MNR hard] [PRED zaad-e] hit-past

Document Summarization
Predicates and Heads of Roles summarize content

Information Extraction
SRL can be used to construct useful rules for IE

Annotations Used
-----------------
Syntactic Parsers
Collins’, Charniak’s (most systems) CCG parses ([Gildea & Hockenmaier 03],[Pradhan et al. 05]) TAG parses ([Chen & Rambow 03])

Shallow parsers
[NPYesterday] , [NPKristina] [VPhit] [NPScott] [PPwith] [NPa baseball].

Semantic ontologies (WordNet, automatically derived), and named entity classes
(v) hit (cause to move by striking)

propel, impel (cause to move forward with force)


Subtasks
-----------------
Identification:
Very hard task: to separate the argument substrings from the rest in this exponentially sized set
Usually only 1 to 9 (avg. 2.7) substrings have labels ARG and the rest have NONE for a predicate
Classification:
Given the set of substrings that have an ARG label, decide the exact semantic label

http://research.microsoft.com/pubs/101987/SRL-Tutorial-AAAI-07-0723.pdf

Wheesung

http://www.4shared.com/dir/21371251/e1d8c53e/Wheesung_Vol6_-_Vocalate.html

http://www.youtube.com/watch?v=8Vzn8l3Hx2s

Wednesday, October 14, 2009

Long-term monkey tests back Oxford's gene therapy

http://www.reuters.com/article/scienceNews/idUSTRE59D4DL20091014?feedType=RSS&feedName=scienceNews

ProSavin, which is administered directly to the striatum in the brain, delivers three genes required to convert cells that normally do not produce dopamine into cells that do.

http://www.ornl.gov/sci/techresources/Human_Genome/medicine/genetherapy.shtml
What factors have kept gene therapy from becoming an effective treatment for genetic disease?

* Short-lived nature of gene therapy - Before gene therapy can become a permanent cure for any condition, the therapeutic DNA introduced into target cells must remain functional and the cells containing the therapeutic DNA must be long-lived and stable. Problems with integrating therapeutic DNA into the genome and the rapidly dividing nature of many cells prevent gene therapy from achieving any long-term benefits. Patients will have to undergo multiple rounds of gene therapy.

* Immune response - Anytime a foreign object is introduced into human tissues, the immune system is designed to attack the invader. The risk of stimulating the immune system in a way that reduces gene therapy effectiveness is always a potential risk. Furthermore, the immune system's enhanced response to invaders it has seen before makes it difficult for gene therapy to be repeated in patients.

* Problems with viral vectors - Viruses, while the carrier of choice in most gene therapy studies, present a variety of potential problems to the patient --toxicity, immune and inflammatory responses, and gene control and targeting issues. In addition, there is always the fear that the viral vector, once inside the patient, may recover its ability to cause disease.

* Multigene disorders - Conditions or disorders that arise from mutations in a single gene are the best candidates for gene therapy. Unfortunately, some the most commonly occurring disorders, such as heart disease, high blood pressure, Alzheimer's disease, arthritis, and diabetes, are caused by the combined effects of variations in many genes. Multigene or multifactorial disorders such as these would be especially difficult to treat effectively using gene therapy. For more information on different types of genetic disease, see Genetic Disease Information.

Somatic cell - Wikipedia, the free encyclopedia
Somatic cells are any cells forming the body of an organism, as opposed to germline cells. In mammals, germline cells (also known as "gametes")

linux changing network info

change hostname
$ sudo hostname new_hostname

change macaddress
$ sudo apt-get install macchanger
$ sudo ifconfig wlan0 down
$ sudo macchanger -r wlan0
$ sudo ifconfig wlan0 up

python best practices

http://www.fantascienza.net/leonardo/ar/python_best_practices.html

# Python profiler:
python -m profile -o stats myscript.py
>>> import pstats
>>> p = pstats.Stats('stats')
>>> p.sort_stats('time').print_stats(15)

# For source code with not 7-bit ASCII
add this on top:
# -*- coding: UTF-8 -*-
# Or just, if you have less memory:
# coding: latin

# Use iter* methods when possible
mapping = {5: "5", 6: "6"}
for key, val in mapping.iteritems(): ...
for key in mapping: ...

a = 5
b = 6
a, b = b, a # swap

a = b = c = 5

if x == 1: y = fun1(x)
elif x == 2: y = fun2(x)
elif x == 3: y = fun3(x)
else: y = None
# But sometimes a dict is better:
funs = {1: fun1, 2: fun2, 3: fun3}
y = funs.get(x, lambda x:None)(x)

def mul(x, y):
return x * y
l = [2, 3]
print mul(*l)

# Generally getters and setters are not used.
# Instance names starting with _ are meant as
# 'to not mess with' by convention.
# Instance names starting with __ are private
# and receive name mangling.
class Foo(object):
def __init__(self, x, y, z):
self.x_public = x
self._y_private = y
self.__z_veryprivate = z
print Foo(1, 2, 3).x_public

finder = re.compile(r"""
^ \s* # start at beginning+ opt spaces
( [\[\]] ) # Group 1: opening bracket
\s* # optional spaces
( [-+]? \d+ ) # Group 2: first number
\s* , \s* # opt spaces+ comma+ opt spaces
( [-+]? \d+ ) # Group 3: second number
\s* # opt spaces
( [\[\]] ) # Group 4: closing bracket
\s* $ # opt spaces+ end at the end
""", flags=re.VERBOSE)
# Sometimes it's positive to indent logically those
# lines just like code.

# Sometimes it can be positive to compose REs:
spaces = r"\s*" # optional spaces
number = r"( [-+]? \d+ )" # Group
bracket = r"( [\[\]] )" # Group. Closing bracket
parts = ["^", bracket, number, ",", number, bracket, "$"]
finder = re.compile(spaces.join(parts), flags=re.VERBOSE)


# Use doctests (or module tests):
def function(data):
"""A comment

>>> function()
None
>>> function(1)
result1
>>> function("a")
Traceback (most recent call last):
...
TypeError
"""
...implementation...

if __name__ == "__main__":
import doctest
doctest.testmod()
print "Tests done."


x = (1, 2, 6, 55, 63, 96, 125, 256,
301, 456, 958, 1256,
1359, 2568, 3597)
# Too much long lines must be broken with \
# but \ isn't necessary inside () [] {}



# Using psyco array.array of double and
# signed long become very fast
import array
a = array.array("d", [3.56, 2.12])

Friday, October 9, 2009

Streaming Music

http://www.live365.com/listen/recommendations.live
http://kawaii-radio.net/page/listen

eeepc ubuntu firefox flash

$ sudo apt-get remove swfdec-mozilla

$ sudo cp libflashplayer.so /usr/lib/mozilla/plugins/

$ ls /usr/lib/mozilla/plugins/ -l
total 10056
lrwxrwxrwx 1 root root 37 2009-10-09 04:47 flashplugin-alternative.so -> /etc/alternatives/mozilla-flashplugin
-rwxr-xr-x 1 root root 10278616 2009-10-09 17:59 libflashplayer.so

$ ls /etc/alternatives/mozilla-flashplugin
/etc/alternatives/mozilla-flashplugin

Thursday, October 8, 2009

YEN to USD

http://www.x-rates.com/d/JPY/USD/graph120.html
http://www.yen-to-dollar.com/

Best place seems to be the Japan Post Office, next are the Japanese banks.

Wednesday, October 7, 2009

Trio wins chemistry Nobel for solving ribosome riddle

http://www.reuters.com/article/scienceNews/idUSTRE5961NG20091007?feedType=RSS&feedName=scienceNews

The academy said many of today's antibiotics cure various diseases by blocking the function of bacterial ribosomes.

"Fifty percent of all antibiotics target the ribosome, and now we have the tools to begin looking at if there are other substances we can fit into different slots to block and disturb bacteria in our bodies," said Peter Brezinski, a member of the chemistry panel at the Royal Academy of Sciences in Stockholm.

Tuesday, October 6, 2009

Japanese handwriting IME

http://singularity.agronesia.net/2007/03/31/japanese-kanji-handwriting-recognition-in-windows-xps-ime/

press F5 to activate while typing something in Japanese

Kanjipad for Ubuntu
http://manpages.ubuntu.com/manpages/intrepid/man1/kanjipad.1.html

ラーメン ramen
醤油 shouyu  a kind of japanese soy sauce
塩 shouyu salt
豚骨 tonkotsu pork
昆布 konbu kelp / a large seaweed (algae)

New flood-tolerant rice offers relief for world's poorest farmers

New flood-tolerant rice offers relief for world's poorest farmers
August 9, 2006 06:36 PM

http://www.biologynews.net/archives/2006/08/09/new_floodtolerant_rice_offers_relief_for_worlds_poorest_farmers.html

http://rice.genomics.org.cn/rice/index2.jsp
The Beijing Genomics Institute (BGI) has long been devoting itself to sequencing, information analysis, and biological research of the rice genome. Our Rice Information System (BGI-RIS) is targeted to be the most up-to-date integrated information resource for rice genomes as well as a workbench for comparative genomic analysis among cereal crops.

http://beta.irri.org/publications/index.php?option=com_content&task=view&id=1&Itemid=24

Friday, October 2, 2009

ubuntu eeepc wifi disabled at boot time

found these while i was looking for a fix ...

http://www.ventanazul.com/webzine/articles/fix-wireless-connection-problem-gutsy-gibbon

hopefully a more standard fix / update comes out soon

Thursday, October 1, 2009

Rodrigo_y_Gabriela 11:11 (2009)

http://en.wikipedia.org/wiki/Rodrigo_y_Gabriela
http://en.wikipedia.org/wiki/11:11_(Rodrigo_y_Gabriela_album)

Firefox optimizations

http://www.zolved.com/synapse/view_content/24939/How_to_reduce_the_memory_usage_on_Firefox

Click Privacy. Un-check the "Remember What I've downloaded" check box.
browser.cache.memory.enable=true
browser.cache.memory.capacity=8192
config.trim_on_minimize=true