Python

Modelling Wikipedia Articles (enwiki) Using Gensim make_wiki.py

  • Posted on: 2 January 2016
  • By: oon
Gensim topic modelling for humans

(Artikel mengenai topik ini akan ditulis dalam bahasa Indonesia.)

Awal mulai penulisan artikel ini karena ingin mencoba (ekplorasi) aplikasi gensim, lalu mencari informasi apa yang bisa dilakukan aplikasi gensim untuk data yang cukup besar, lalu dari beberapa referensi mengacu pada pengolahan data wikipedia yang lebih dari 10GB (dalam format kompresi bz2 yang terkenal sangat efisien).

Ya tentu pertama yang harus dilakukan adalah download file artikel dari wikimedia: download enwiki-latest-pages-articles.xml.bz2 dari situs dumps.wikimedia.org

Django REST Framework with ForeignKey Example

  • Posted on: 10 September 2015
  • By: oon

If you are a noob in Django or Django REST Framework (DRF),
it's pretty hard to find (complete) example about providing REST API for system with (sql relationship) foreign key on its database.

this example on SO is quite straigth forward and complete, about DRF with foreignkey.

http://stackoverflow.com/a/19414405/3991504

ya, you also get django.test.Client information as a bonus. nice!

mostly my problem is about reverse relationship [1][2][3].

Django Template Not Support Simple Math Calculation

  • Posted on: 27 May 2015
  • By: oon
Django, web framework for perfectionists with deadlines

I used to use Jinja2 for templating, and it support Math calculation [1].

Now when try Django template, I can't calculate simple math (only add available via builtin filter), so I have to implement filter by myself, or using django-mathfilters [2].

What do you need is only install mathfilters with pip then add mathfilters to INSTALLED_APPS on your settings.

Easier to Ask for Forgiveness than for Permission (EAFP)

  • Posted on: 2 May 2015
  • By: oon

There is a rule in Python programming called "it is Easier to Ask for Forgiveness than for Permission" (in short: EAFP). It means that you should catch exceptions instead of checking values for validity.

 

[1]http://stackoverflow.com/questions/8381193/python-handle-json-decode-err...

 

Tags: 

Django Model Serializer

  • Posted on: 5 April 2015
  • By: oon

How to serialize model to JSON on Django?

Django has serializers module on it's core.

from django.core import serializers 
from myproject.myapp import models 
data = serializers.serialize("json", models.MyModel.objects.all())

really simple :)

[1]http://stackoverflow.com/questions/1113096/django-dump-data-for-a-single...

Pages