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: |
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())}) |
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', |
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: |
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, |
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) |
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) + '%' |
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 |
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 |
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