Skip to content

Instantly share code, notes, and snippets.

View inhzus's full-sized avatar
🎯
Coding

Inhzus inhzus

🎯
Coding
  • Shopee
  • Beijing, China
View GitHub Profile
@inhzus
inhzus / HanLPSeg2Sentence.java
Created February 1, 2019 09:29
HanLP seg2sentence
public static void main(String[] args) {
Segment segment = HanLP.newSegment().enableAllNamedEntityRecognize(false).enableCustomDictionary(false);
List<List<Term>> result = segment.seg2sentence("信里说他们离青云山还有很远,老祖宗说不着急,走个两三年也没什么打紧,所以他们走走停停," +
"有时听说哪里有好看好玩的事物,也会专门绕路过去,停驻几天。又说路上什么都好,哪怕是荒郊野外," +
"老祖宗也能变出热腾腾的吃食,还有各种衣物,穿戴比家里都要好。他们还自己动手搭过木屋,在一颗很高很大的树上," +
"建起了一座小小的屋子,为此他还专门学会了爬树…总之是一切都好,让父母大人不用担心他,老祖宗有个百宝囊,里面什么都有," +
"连书都有很多,没事的时候,他们就跟着老祖宗读书练字,最后祝高堂安泰。", true);
for (List<Term> sentence : result) {
for (Term term : sentence) {
System.out.printf("%s ", term.word);
@inhzus
inhzus / Branch. cpp
Last active February 16, 2019 04:11
document tracker gist
class Branch {
Date time;
unsigned index;
unsigned succ;
string comment;
}
@inhzus
inhzus / Histogram_equalization.m
Created March 13, 2019 17:21
Histogram equalization, RGB and HSV
function [output] = Histogram_equalization(input_image)
%first test the image is a RGB or gray image
hsv = true;
if numel(size(input_image)) == 3
%this is a RGB image
%here is just one method, if you have other ways to do the
%equalization, you can change the following code
if hsv
input_image = rgb2hsv(input_image);
h=input_image(:,:,1);
@inhzus
inhzus / apriori.py
Created April 22, 2019 12:40
Frequent itemsets Algorithm: Apriori
# -*- coding: utf-8 -*-
# created by inhzus
import typing
from collections import defaultdict
from itertools import combinations
from numbers import Number
from pprint import pprint
from bitarray import bitarray
@inhzus
inhzus / fp_growth.py
Created April 22, 2019 12:42
Frequent itemsets algorithm: FP-Growth
# -*- coding: utf-8 -*-
# created by inhzus
import typing
from collections import Counter, defaultdict
from itertools import combinations
from pprint import pprint
T = typing.TypeVar('T')
@inhzus
inhzus / edge_detection.m
Created April 30, 2019 03:25
Canny edge dection
function output = my_edge(input_image)
mean_value = mean(mean(input_image));
[height, width] = size(input_image);
fft_mid_img = fftshift(fft2(input_image));
fft_ratio = 12;
a = round(height/fft_ratio):round((fft_ratio-1)*height/fft_ratio);
b = round(width/fft_ratio):round((fft_ratio-1)*width/fft_ratio);
% disp(a);
% disp(b);
fft_mid_img(round(height / 2), round(width / 2)) = 0;
@inhzus
inhzus / edge_linking.m
Created April 30, 2019 03:28
Inner boundary tracing
function output = my_edgelinking(image, row, col)
output = [row col;];
image(row, col) = 0;
dir = 7;
while (1)
[row, col, next_found, dir] = find_next_dir(row, col, dir, image);
if (~next_found)
break;
end
import argparse
from . import user_service, doc_service, repo_service
parser = argparse.ArgumentParser()
# ... set argument
args = parser.parse_args()
print(getattr(
globals()[f'{args.sub}_service'],
getattr(args, args.sub))
@inhzus
inhzus / channel.go
Created July 11, 2019 05:51
Passing channel over channel to do request & get response
package main
import "fmt"
var queue = make(chan int)
var c = make(chan chan error)
func request() {
for i := 0; i < 4; i++ {
queue <- i
import "fmt"
type Other struct {
c bool
x, y int
}
type Model interface{}
type A struct {