# HG changeset patch # User Steve Losh # Date 1448747541 0 # Node ID c68485e8d84b1d0a0f225b48e0d76bfe01e40195 # Parent 502f0b2e82fee8e84f562c9128477ee99604576a more diff -r 502f0b2e82fe -r c68485e8d84b bin/conj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/conj Sat Nov 28 21:52:21 2015 +0000 @@ -0,0 +1,70 @@ +#!/Users/sjl/.virtualenvs/webscraping/bin/python3 + +import sys +import requests +from bs4 import BeautifulSoup + + +en_url = 'http://conjugator.reverso.net/conjugation-english-verb-%s.html' +is_url = 'http://www.verbix.com/webverbix/go.php?T1=%s&Submit=Go&D1=28&H1=128' + +def english(word): + resp = requests.get(en_url % word).text + soup = BeautifulSoup(resp, "html.parser") + + ws = [t.text.strip() + for t in soup.find_all(class_="indicative-wrap")[0] + .div + .find_all("i")[1:]] + ws[8] = "y'all" + + # fix third person singular + v = ws[5] + ws[4:6] = ['he', v, 'she', v, 'it', v] + + # fix third person plural + v = ws[15] + ws[14:15] = ['they ♂', v, 'they ♀', v, 'they ∅', v] + vals = [a + ' ' + b for a, b in zip(ws[::2], ws[1::2])] + + return vals + +def icelandic(word): + resp = requests.get(is_url % word).text + soup = BeautifulSoup(resp, "html.parser") + + ws = [t.text.strip() + for t in soup.find_all(class_='pure-u-1-2')[0] + .find_all('span')] + + # fix third person singular + v = ws[5] + ws[4:6] = ['hann', v, 'hún', v, 'það', v] + + v = ws[15] + ws[14:15] = ['þeir', v, 'þær', v, 'þau', v] + vals = [a + ' ' + b for a, b in zip(ws[::2], ws[1::2])] + + return vals + +eng_word = sys.argv[1] +ice_word = sys.argv[2] + +print('to %s\tað %s' % (eng_word, ice_word)) + +eng = english(eng_word) +ice = icelandic(ice_word) + +for e, i in zip(eng, ice): + print('%s\t%s' % (e, i)) + +print('to %s / að %s\t' % (eng_word, ice_word), end='') +print('', end='') +for e, i in zip(eng, ice): + e1, e2 = e.rsplit(' ', 1) + i1, i2 = i.split(' ') + + print('', end='') + print('' % (e1, e2, i1, i2), end='') + print('', end='') +print('
%s%s%s%s
') diff -r 502f0b2e82fe -r c68485e8d84b fish/functions/lstrip.fish --- a/fish/functions/lstrip.fish Fri Nov 13 22:46:39 2015 +0000 +++ b/fish/functions/lstrip.fish Sat Nov 28 21:52:21 2015 +0000 @@ -1,4 +1,4 @@ function lstrip -d "Strip whitespace from the left of each line" - sed -e 's/^[ \t]*//' + sed -Ee 's/^[[:space:]]*//' end diff -r 502f0b2e82fe -r c68485e8d84b fish/functions/rstrip.fish --- a/fish/functions/rstrip.fish Fri Nov 13 22:46:39 2015 +0000 +++ b/fish/functions/rstrip.fish Sat Nov 28 21:52:21 2015 +0000 @@ -1,3 +1,3 @@ function rstrip -d "Strip whitespace from the right of each line" - sed -e 's/[ \t]*$//' + sed -e 's/[[:space:]]*$//' end diff -r 502f0b2e82fe -r c68485e8d84b vim/vimrc --- a/vim/vimrc Fri Nov 13 22:46:39 2015 +0000 +++ b/vim/vimrc Sat Nov 28 21:52:21 2015 +0000 @@ -1092,10 +1092,43 @@ " }}} " gnuplot {{{ +function! OpenGnuplotRepl() "{{{ + NeoRepl gnuplot + set syntax=gnuplot + " syn match replPrompt /\v^\*/ + " hi def link replPrompt SpecialChar + + " syn match replResult /\v^#\<[^>]+\>$/ + " hi def link replResult Debug +endfunction "}}} + +function! SendGNUPlotParagraph() "{{{ + let view = winsaveview() + + execute "normal! ^vip\" + call NeoReplSendSelection() + + call winrestview(view) +endfunction "}}} +function! SendGNUPlotBuffer() "{{{ + let view = winsaveview() + + execute "normal! ggVG" + call NeoReplSendSelection() + + call winrestview(view) +endfunction "}}} + augroup ft_gnuplot au! au BufNewFile,BufRead *.gp setlocal filetype=gnuplot + + au FileType gnuplot nnoremap o :call OpenGnuplotRepl() + + au FileType gnuplot nnoremap e :call SendGNUPlotParagraph() + + au FileType gnuplot setlocal foldmethod=marker foldmarker={{{,}}} augroup END " }}} @@ -1736,6 +1769,7 @@ au FileType lisp setlocal commentstring=;\ %s au FileType puppet setlocal commentstring=#\ %s au FileType fish setlocal commentstring=#\ %s + au FileType gnuplot setlocal commentstring=#\ %s augroup END " }}}