Skip to content

Instantly share code, notes, and snippets.

@naoa
naoa / kanji-kana.php
Last active September 1, 2023 09:17
from kanji to katakana convert
<?php
$input_file = $argv[1];
if($argc >= 3){
$output_file = $argv[2];
}
else{
$output_file = "";
}
require "groonga"
database_path = ARGV[0]
table_name = ARGV[1]
index_column_name = ARGV[2]
Groonga::Database.open(database_path)
index = Groonga["#{table_name}.#{index_column_name}"]
terms = Groonga::Hash.create(:key_type => Groonga::Type::SHORT_TEXT,
:value_type => Groonga::Type::UINT32)
@naoa
naoa / groonga-dev.sh
Last active April 18, 2016 04:56
How to build Groonga development environment on Ubuntu 14.04
apt-get update -qq && apt-get install -y build-essential
apt-get -y install software-properties-common
add-apt-repository -y universe
add-apt-repository -y ppa:groonga/ppa
apt-get update
apt-get install -y mecab libmecab-dev mecab-naist-jdic
apt-get install -y debhelper autotools-dev pkg-config liblz4-dev zlib1g-dev libmsgpack-dev libzmq3-dev libevent-dev libpcre3-dev libstemmer-dev libjemalloc-dev libssl-dev
apt-get install -y git
@naoa
naoa / obj_search.c
Last active February 2, 2016 21:35
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <groonga.h>
#include <time.h>
#include <limits.h>
grn_obj *
create_lexicon(grn_ctx *ctx, grn_obj *target_table, grn_obj *target_column,
char *lexicon_name)
@naoa
naoa / score.c
Last active February 1, 2016 01:07
#include <stdio.h>
#include <string.h>
#include <groonga.h>
int main()
{
grn_ctx ctx;
grn_obj *db, *table;
grn_id id;
const char *path = "score.grn";
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <groonga.h>
#include <time.h>
#include <limits.h>
typedef struct {
double score;
int n_subrecs;
plugin_register functions/vector
[[0,0.0,0.0],true]
table_create Users TABLE_NO_KEY
[[0,0.0,0.0],true]
column_create Users names COLUMN_VECTOR ShortText
[[0,0.0,0.0],true]
table_create Words TABLE_PAT_KEY ShortText
[[0,0.0,0.0],true]
column_create Words users COLUMN_INDEX Users names
[[0,0.0,0.0],true]
<?php
$input_file = $argv[1];
if($argc >= 3){
$output_file = $argv[2];
}
else{
$output_file = "";
}
@naoa
naoa / category_enals.php
Created December 8, 2013 10:32
This script has the feature that extract English wikipedia's category has only alphabets, digits, and spaces. %php category_enals.php<database> <output_file>
<?php
$db = "127.0.0.1";
$db_name = $argv[1];
$table = "category";
$username = "mysql";
$password = "";
$output_file = $argv[2];
@naoa
naoa / wiki_fts.php
Created December 8, 2013 10:29
This script has the feature that select full text phrase search from line text in text_file. %php wiki_fts.php <database> <text_file> <output_file>
<?php
$db = "127.0.0.1";
$db_name = $argv[1];
$table = "text";
$index = "title,text";
$username = "mysql";
$password = "";
$category_file = $argv[2];