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
# -*- coding: utf-8 -*- | |
# stdlib | |
import re | |
LEFT_SPACES = re.compile(r'\s+<') | |
RIGHT_SPACES = re.compile(r'>\s+') | |
SCRIPT_TAG = re.compile(r'<script[^>]*>.*?</script>') | |
COMMENT = re.compile(r'<!--[\s\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
# -*- coding: utf-8 -*- | |
# third-party lib | |
import networkx | |
def blank_split(text): | |
u""" | |
半角スペースによる単語分割 | |
""" | |
return text.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
# -*- coding: utf-8 -*- | |
def shorten(s, length=80): | |
u""" | |
長い文字列を"abraca ... tabra"のように短く表示 | |
""" | |
if len(s) < length: | |
return s | |
else: | |
if isinstance(s, unicode): |
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
#-*- encoding: utf-8 -*- | |
# thirdlib | |
import requests | |
BASE_URL = "http://en.wikipedia.org/w/api.php" | |
BLLIMIT = 250 | |
def get_regular_name(q): |
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
gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git', :branch => 'bootstrap3' |
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
>>> str(Ellipsis) | |
'Ellipsis' | |
>>> str(pass) | |
File "<stdin>", line 1 | |
str(pass) | |
^ | |
SyntaxError: invalid syntax |
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
$ pip install rstr |
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
>>> c1 = 1 + 1j | |
>>> c2 = 1 - 2j | |
>>> c1 + c2 | |
(2-1j) | |
>>> c1 * c2 | |
(3-1j) | |
>>> c1 / c2 | |
(-0.2+0.6j) |
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 | |
import sqlite3 | |
class SQLite3DB: | |
_IDENTIFIER_RE = re.compile(r'^[a-zA-Z_]\w*$') | |
def __init__(self, filename): | |
self._con = sqlite3.connect(filename, isolation_level=None) | |
self._con.row_factory = sqlite3.Row |
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
identifier: | |
guid: "129961" | |
fileName: "0129961.xml" | |
url: "http://query.nytimes.com/gst/fullpage.html?res=940DE4D9103CF930A15750C0A96E948260" | |
alternativeURL: | |
date: | |
publicationDate: "2004-09-03T00:00:00Z" | |
correctDate: "1987-02-04T00:00:00Z" | |
analyzed_text: | |
articleAbstract: "Gov James E McGreevey, ..." |