This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text = text.replace("’", "'").replace('“', '"').replace('”', '"') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ambil text yang sesuai dengan patter (pake re.findall) | |
masukan ke dictionary, lalu replace karakter | |
replace text asli dengan text yg ada di dictionary | |
m = re.findall(r'\w+\.\w+', text) | |
ketemu = {} | |
for i in m: | |
ketemu[i] = i.replace('.', '. ') | |
for key, value in ketemu.iteritems(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
seq = list | |
sep = karakter pemisah | |
contoh: [1,2,3,4,'/',4,5,6,7] karakter '/' akan jadi pemisah, nanti hasilnya akan muncul 2 list | |
def group(self, seq, sep): | |
"""Untuk misahin entitiy di list #LIYEUR.""" | |
g = [] | |
for el in seq: | |
if el == sep: | |
yield g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import re | |
>>> re.sub(r'(.)\1+', r'\1\1', "haaaaapppppyyy") | |
'haappyy' | |
from: http://stackoverflow.com/questions/10072744/remove-repeating-characters-from-words |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# delay 3 detik | |
sleep 3 | |
# jika anda belum tau perintah dmesg itu apa, silahkan baca http://catatan-e-gugun.blogspot.co.id/2012/03/fungsi-dmesg.html | |
# dan juga baca manual nya: man dmesg | |
# clear ring buffer | |
dmesg --clear | |
# assign counter variable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytz | |
import datetime | |
# list of timezone: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones | |
# from indonesia to utc | |
from_timezone = pytz.timezone('Asia/Jakarta') | |
to_timezone = pytz.timezone('UTC') | |
indonesia_time = '2017-05-29 10:00:00' | |
indonesia_time = datetime.datetime.strptime(indonesia_time, '%Y-%m-%d %H:%M:%S') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
re.sub('([a-z])([A-Z])', r'\1 \2', 'ThisIsCamelCase').split() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
re.sub(r'[^\x00-\x7f]|\&\w+;|\&\#\w+;', r'', string).strip() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget -c --tries=0 --read-timeout=20 url_nya |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BM25 | |
biar mereka saja, kan santai jadinya = Langit biru : 0.0 | |
biar mereka saja, kan santai jadinya = Anjing itu lebih pintar dari rubah : 0.0 | |
biar mereka saja, kan santai jadinya = Anjing, rubah dan kucing adalah teman baik : 0.0 | |
biar mereka saja, kan santai jadinya = biar anak-anak aja, biar bisa lebih santai : 1.0 | |
biar mereka saja, kan santai jadinya = “ Sekali lagi, momentum ini harus dimanfaatkan betul. Jangan sampai momentum ini lewat dan kita tidak mendapat apa-apa, ” : 0.0 | |
biar mereka saja, kan santai jadinya = “ Saya harapkan menteri tidak membuat kebijakan baru yang belum dikonsultasikan kepada publik, pada masyarakat, belum melalui kajian dan perhitungan perhitungan mendalam, sehingga justru bisa membikin hal-hal yang tidak diinginkan masyarakat dan membuat masyarakat kecewa, ” : 0.0 | |
biar mereka saja, kan santai jadinya = “ Saya sering dapat bisikan dari Ibu Jokowi, Pak, Ibu Mufidah itu sangat sederhana. Sangat sabar. Saya nggak tahu dengan Pak JK, ” : 0.0 | |
biar mereka saja, kan santai jadinya = “ Pu |
OlderNewer