Skip to content

Instantly share code, notes, and snippets.

View ducalpha's full-sized avatar

Duc Bui ducalpha

View GitHub Profile
@ducalpha
ducalpha / stopwords
Created January 13, 2019 19:46
List of stopwords
a
all
an
and
any
are
as
at
be
been
@ducalpha
ducalpha / allnenlp_predict_raw_data.py
Created January 5, 2019 22:31
Predict raw data in Allennlp
# http://ai.orbifold.net/default/what-is-semantic-role-labeling/
instance = self.predictor._dataset_reader.text_to_instance(doc, verb_labels)
output = self.predictor._model.forward_on_instance(instance, -1)
@ducalpha
ducalpha / dau_thu_dvb.md
Created December 13, 2018 07:17
Dau thu DVB note
@ducalpha
ducalpha / sentencize_policy.py
Created November 2, 2018 04:10
Sentencize a policy
from typing import List
from unidecode import unidecode
import spacy
nlp = spacy.load('en')
nlp.remove_pipe('ner')
def sentencized(line: str) -> List[str]:
doc = nlp(line)
@ducalpha
ducalpha / run_ner.py
Created August 2, 2018 04:38
Test NER with Flair framework
from flair.data import NLPTaskDataFetcher, TaggedCorpus, NLPTask
from flair.embeddings import TextEmbeddings, WordEmbeddings, StackedEmbeddings, CharLMEmbeddings, CharacterEmbeddings
from typing import List
import torch
import argparse
def load_data(train_file_path, dev_file_path, test_file_path):
# get training, test and dev data
sentences_train: List[Sentence] = NLPTaskDataFetcher.read_conll_sequence_labeling_data(train_file_path)
sentences_dev: List[Sentence] = NLPTaskDataFetcher.read_conll_sequence_labeling_data(dev_file_path)
@ducalpha
ducalpha / tiling.py
Created January 22, 2017 12:25 — forked from datalyze-solutions/tiling.py
simple python window tiling script with wmctrl
#!/usr/bin/python
import time
start = time.time()
import os, sys
def setWindow(posX, posY, sizeX, sizeY):
values = {
'gravity': 0,
@ducalpha
ducalpha / compton.conf
Created May 29, 2016 05:42
compton config
#.config/compton.conf
# Source: http://www.iwillfolo.com/how-to-use-compton-compositing-manager-to-enhance-xfce-lxde-other-des/
# GLX backend
######################################
backend = "glx";
vsync = "opengl-swc";
glx-no-stencil = true;
glx-copy-from-front = false;
#glx-use-copysubbuffermesa = true;
glx-no-rebind-pixmap = true;
@ducalpha
ducalpha / check_all_range_k.cc
Created May 22, 2016 15:51
Check all ranges of k in an array
#include <my_epi/common.h>
void PrintCache(const multiset<int>& cache) {
for (int i : cache) {
cout << i << ' ';
}
cout << endl;
}
void CheckRange(const vector<int>& nums, int k) {
@ducalpha
ducalpha / string_streams.cpp
Last active May 6, 2016 18:44
Using input/output string streams for dynamic reading
// Example program
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <exception>
using namespace std;
int main()
@ducalpha
ducalpha / factory_method_lambda_functions.cpp
Last active April 24, 2016 15:56
Map function lambda functions C++. Demo factory method, polymorphism, lambda functions.
// Copyright 2016 Duc Hoang Bui, KAIST. All rights reserved.
// Licensed under MIT
#include <iostream>
#include <string>
#include <map>
#include <memory>
#include <functional>
struct Animal {