<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from __future__ import print_function <EOL> from __future__ import division <EOL> from __future__ import unicode_literals <EOL> from . import base <EOL> class Keyword ( object ) : <EOL> def __init__ ( self , _id , word_type , ref ) : <EOL> self . id = _id <EOL> self . word_type = word_type <EOL> self . ref = ref <EOL> def get_id ( self ) : <EOL> return self . id <EOL> def get_type ( self ) : <EOL> return self . word_type <EOL> def get_ref ( self ) : <EOL> return self . ref <EOL> class KeywordsFile ( base . abs_file . File ) : <EOL> def __init__ ( self , path ) : <EOL> super ( KeywordsFile , self ) . __init__ ( path ) <EOL> self . load ( ) <EOL> def load ( self ) : <EOL> self . keywords = [ ] <EOL> text = self . read ( ) <EOL> lines = text . split ( '<STR_LIT:\n>' ) <EOL> for line in lines : <EOL> line = line . strip ( ) <EOL> if line and not line . startswith ( '<STR_LIT:#>' ) and not line . startswith ( '<STR_LIT>' ) : <EOL> word_list = line . split ( ) <EOL> if len ( word_list ) > <NUM_LIT:3> : <EOL> continue <EOL> elif len ( word_list ) == <NUM_LIT:2> : <EOL> if not ( '<STR_LIT>' in word_list [ <NUM_LIT:1> ] or <EOL> '<STR_LIT>' in word_list [ <NUM_LIT:1> ] ) : <EOL> word_list . insert ( <NUM_LIT:1> , '<STR_LIT>' ) <EOL> else : <EOL> word_list . append ( '<STR_LIT>' ) <EOL> elif len ( word_list ) == <NUM_LIT:1> : <EOL> word_list += [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> keyword = Keyword ( * word_list ) <EOL> self . keywords . append ( keyword ) <EOL> self . keyword_ids = [ k . id for k in self . keywords ] <EOL> self . id_keyword_dict = dict ( zip ( self . keyword_ids , self . keywords ) ) <EOL> def get_id_keyword_dict ( self ) : <EOL> return self . id_keyword_dict <EOL> def get_keywords ( self ) : <EOL> return self . keywords <EOL> def get_keyword_ids ( self ) : <EOL> return self . keyword_ids </s>
