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
# Примеры на Python 2.7 | |
from rutermextract import TermExtractor | |
term_extractor = TermExtractor() | |
text = u'Съешь еще этих мягких французских булок да выпей же чаю' | |
for term in term_extractor(text): | |
print term.normalized | |
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
Абагур-Лесной | |
Абай | |
Абшвай | |
Абакумовский | |
Аббинокмой | |
Абонкур-сюр-Сей | |
Абрикосовый | |
Абый | |
Абанкай | |
Абомей |
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 | |
from collections import Counter | |
import networkx as nx | |
def get_cities(): | |
with open('cities.txt') as f: | |
for line in f: | |
yield line.strip().decode('utf8').lower() |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/types.h> | |
#include <unistd.h> | |
#include <sys/wait.h> | |
#include <math.h> | |
#include <mqueue.h> | |
#include <sys/stat.h> | |
#include <errno.h> |
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 map_(function, iterable): | |
return reduce(lambda lst, cur: lst + [function(cur)], iterable, []) | |
def filter_(function, iterable): | |
return reduce(lambda lst, cur: ((lst + cur) if type(iterable) is str else (lst + (cur,) if type(iterable) is tuple else lst + [cur])) if (function if function is not None else bool)(cur) else lst, iterable, '' if type(iterable) is str else tuple() if type(iterable) is tuple else []) |
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 Control.Monad | |
import Control.Concurrent.MVar | |
type TreeRef a = MVar (MutableTree a) | |
data MutableTree a = Node { value :: a, left :: TreeRef a, right :: TreeRef a, parent :: TreeRef a } | |
| Leaf { value :: a, parent :: TreeRef a} | |
treeChangeValue :: MutableTree a -> (a -> a) -> MutableTree a | |
treeChangeValue (Leaf a p) f = Leaf (f a) p | |
treeChangeValue (Node a l r p) f = Node (f a) l r p |
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 itertools import combinations | |
from nltk.tokenize import sent_tokenize, RegexpTokenizer | |
from nltk.stem.snowball import RussianStemmer | |
import networkx as nx | |
def similarity(s1, s2): | |
if not len(s1) or not len(s2): | |
return 0.0 | |
return len(s1.intersection(s2))/(1.0 * (len(s1) + len(s2))) |
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 Data.List (sort, insert, elem, concat) | |
data HuffmanTree = Leaf { symbol :: Char, weight :: Int} | Node { left :: HuffmanTree, right :: HuffmanTree, symbols :: [Char], weight :: Int} deriving (Show) | |
instance Eq HuffmanTree where | |
tree1 == tree2 = (weight tree1) == (weight tree2) | |
instance Ord HuffmanTree where | |
tree1 `compare` tree2 = (weight tree1) `compare` (weight tree2) |
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 Data.List (deleteFirstsBy, null) | |
import System.IO.UTF8 (readFile) | |
anagrams :: [Char] -> [String] -> [String] | |
anagrams [] _ = [""] | |
anagrams _ [] = [] | |
anagrams letters dictionary = | |
let currentWord = head dictionary | |
remainingLetters = removeWord letters currentWord | |
newDictionary = filterDictionary remainingLetters dictionary |