示例#1
0
 def test_can_reverse_search_kanji(self):
     """Test that we can reverse-find all kanji with specified radical"""
     r = redis.StrictRedis(host='localhost', port=6379, db=0)
     red = Storage(r)
     #red.prepare_reverse_index()
     assert set(['黑', '黕', '黔']).issubset(
         red.find_kanji_with_radical(u'黒')
     )
示例#2
0
文件: cli.py 项目: Xifax/suzu-web
def prepare_radicals(info, reverse):
    """Prepare radical decomposition data"""
    store = Storage()
    store.prepare_radicals()

    if info:
        store.prepare_radicals_info()
    if reverse:
        store.prepare_reverse_index()
示例#3
0
# Application modules
from src.db.models import Key
from src.db.mongo import connectMongo
from src.db.storage import Storage

from src.api.jp.weblio import Weblio
from src.api.jp.wordnet import Wordnet
from src.api.jp.jisho import Jisho

from src.run.peon import Peon

# Initialize MongoDB
db = connectMongo()
# Initialize Redis
store = Storage()


@route('/examples/:term')
def get_examples(term):
    """Lookup examples for item in Weblio"""
    term = unicode(term, 'utf-8')
    examples = Weblio().examples(term)
    return {'examples': examples}


@route('/similar/:term')
def get_similar(term):
    """Lookup similar words for item in Weblio"""
    term = unicode(term, 'utf-8')
    similar = [item['translate'] for item in Wordnet().lookup(term)]
示例#4
0
文件: cli.py 项目: Xifax/suzu-web
def get_radicals(kanji):
    """Get radical decomposition for provided kanji"""
    for rad in Storage().get_radicals(kanji):
        print rad
示例#5
0
 def test_can_process_kradfile(self):
     """Test that we can process kradfile"""
     r = redis.StrictRedis(host='localhost', port=6379, db=0)
     red = Storage(r)
     assert [u'一', u'言', u'口', u'五'] == red.get_radicals(u'語')
示例#6
0
 def test_can_reverse_search_kanji(self):
     """Test that we can reverse-find all kanji with specified radical"""
     r = redis.StrictRedis(host='localhost', port=6379, db=0)
     red = Storage(r)
     #red.prepare_reverse_index()
     assert set(['黑', '黕', '黔']).issubset(red.find_kanji_with_radical(u'黒'))
示例#7
0
 def test_can_process_kradfile(self):
     """Test that we can process kradfile"""
     r = redis.StrictRedis(host='localhost', port=6379, db=0)
     red = Storage(r)
     assert [u'一', u'言', u'口', u'五'] == red.get_radicals(u'語')