View gist:67c993556e897039c871
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
from scrapy.xlib.pydispatch import dispatcher | |
from scrapy import signals | |
from scrapy.http import FormRequest | |
from scrapy.selector import Selector | |
from spider.spiders.basic import StudentSpider | |
from spider.items import StudentItem | |
from scrapy import log | |
class XPATHS: |
View gist:5b273a93a332bd150dc3
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
$('.note-editable').on('keyup', function(){$('[name="fromSummernote"]').val($(this).text())}) |
View gist:c3b713c9ffde0f7589e7
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
//choose the button by id to add "Add type popover" with need parameters | |
$('#addAccType').addTypePopover({ | |
//popover header | |
popOverHeader: 'Add Type', | |
//this is the input form id from which new type name is taken | |
popOverFormInputId: 'NewType', | |
//this is the input form name from which new type name is taken | |
popOverFormInputName: 'NewType', |
View gist:947e8b588cedd8b61b02
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
people_list = [ | |
{name: 'A', | |
friends: 'B','C'}, | |
{name: 'D', | |
friends: 'E','A'}, | |
] | |
friends_groups = 0 | |
for person1 in people_list: |
View gist:680f22703e95fd7d9715
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
//http://www.bennadel.com/blog/2404-compiling-optimizing-a-subset-of-a-requirejs-application.htm | |
({ | |
//appDir: '../js/apps', | |
baseUrl: "../js", // Define our base URL - all module paths are relative to this base directory | |
dir: '../www-built/js', | |
//dir: '../../server-side/assets/SPAS', | |
mainConfigFile: '../src_modules/config-require.js', | |
optimizeCss: "none", | |
optimize: "none", //"uglify", | |
findNestedDependencies: true, |
View 1
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
dataset = [ | |
(vector1, True), | |
(vector2, False), | |
(vector3, False), | |
] | |
train_data = [i[0] for i in dataset] | |
train_labels = [i[1] for i in dataset] | |
classifier.fit(train_data, train_labels) |
View gist:1588878
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 nltk | |
from __future__ import division | |
for genre in nltk.corpus.brown.categories(): | |
words = nltk.corpus.brown.words(categories = genre) | |
print genre +' - ' + str(round((len(set(words))/len(words)),6)*100) + '%' |
View gist:1589515
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
def top_bigrams(text): | |
fdist = nltk.probability.FreqDist(nltk.bigrams(text)) #формируем список кортежей биграмм | |
stopwords = nltk.corpus.stopwords.words('english') #формируем стоплист | |
top_list = [(x,y) for x,y in fdist.keys() if x.isalpha() and y.isalpha() and x not in stopwords and y not in stopwords] #показываем только если элементы кортежа - слова и невходят в стоплист | |
return top_list |
View gist:1593588
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
def word_freq(word, section): | |
freq = nltk.probability.FreqDist(nltk.corpus.brown.words(categories = section)) | |
word_frequency = freq[word] | |
return word_frequency |
View gist:1593818
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
d = nltk.corpus.cmudict.dict() #получаем объект в виде словаря для удобного доступа | |
def count_syllables(text): #вводим текст как список слов | |
syll_text = [] #исходный массив где будут копиться слоги | |
for word in text: | |
syll_text.extend(d[word][0]) #к исходному массиву добавляем первый элемент (в случае нескольких произношений)с помощью метода extend | |
return len(syll_text)# ву-а-ля |
OlderNewer