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
# Smart pane switching with awareness of Vim splits. | |
# See: https://github.com/christoomey/vim-tmux-navigator | |
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ | |
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" | |
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L' | |
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D' | |
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U' | |
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R' | |
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")' | |
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 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
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" let Vundle manage Vundle, required | |
Plugin 'VundleVim/Vundle.vim' | |
" The following are examples of different formats supported. |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from telegram import Update | |
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext | |
import logging | |
from pymongo import MongoClient, TEXT, DESCENDING | |
from datetime import datetime, timedelta | |
import settings | |
import re |
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
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" let Vundle manage Vundle, required | |
Plugin 'VundleVim/Vundle.vim' | |
" The following are examples of different formats supported. |
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 sklearn.metrics.pairwise import cosine_similarity | |
similarity = cosine_similarity(question_repr, sentence_repr) | |
ranks = (-similarity).argsort(axis=None) | |
context_sentences[ranks[0]] | |
'During the middle of 2010, iPhone sales overtook those of the iPod.' |
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 sklearn.feature_extraction.text import TfidfVectorizer | |
sentences = [sentence | |
for datum in squad['data'] | |
for paragraph in datum['paragraphs'] | |
for sentence in paragraph['context'].split('. ') | |
] | |
tf_idf_vect = TfidfVectorizer(tokenizer=tokenize_and_stem) | |
tf_idf_vect.fit(sentences) |
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
question = squad['data'][3]['paragraphs'][3]['qas'][3]['question'] | |
tokenize_and_stem(question) | |
['In', | |
'what', | |
'year', | |
'did', | |
'iphon', | |
'sale', | |
'surpass', |
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
squad['data'][3]['paragraphs'][3]['qas'][3] | |
{'question': 'In what year did iPhone sales surpass those of iPods?', | |
'id': '56ce73d1aab44d1400b887ac', | |
'answers': [{'text': '2010', 'answer_start': 444}], | |
'is_impossible': False} |
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 json | |
with open('data/train-v2.0.json') as squad_file: | |
squad = json.load(squad_file) | |
context = squad['data'][3]['paragraphs'][3]['context'] | |
context | |
'''Before the release of iOS 5, the iPod branding was used for the media player | |
included with the iPhone and iPad, a combination of the Music and Videos apps on |
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 read_csv_to_dicts(filename): | |
with open(filename) as csvfile: | |
reader = csv.reader(csvfile, dialect='excel') | |
header = transform_header(next(reader)) | |
if len(header) != len(set(header)): | |
raise ValueError("Duplicate column names in CSV.") | |
data = [{field: value for field, value in zip(header, row)} | |
for row in reader] |
NewerOlder