
% (C) Copyright 1992
% Institute for New Generation Computer Technology, Japan
% ALL RIGHTS RESERVED

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% August 3, 1992     SANO,H. %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

?- no_style_check(all).		% for Quintus
?- unknown(_,fail).		% for Quintus and SICStus
?- [
	'~/FSE/LangLAB-Grm/lib/runtime',
	'~/FSE/LangLAB-Grm/lib/dictionary',	% **index ̤
%	'~/FSE/lib/SanoSpecial/dictionary',	% **index 
	'~/FSE/lib/SanoSpecial/runtime_user'
].

% Parameters

grammar(v62,'~/FSE/JUMAN-LangLAB/grmV62/').

file_name(body,'LUG_L_L').
file_name(dict,'DICT_L_L').
file_name(extra,'EXTRA_L').

extension(body,'.dcg.G').
extension(dict,'.dcg.D').
extension(extra,'.dcg').

% Usage Summary

% Invoking a parser.
% After you translate your grammar rules and then enter the sftb/2 predicate.
%
% sftb(Version,Level).
% Version : v62
% Level   : level1 to level12

sftb(Version,Level) :-
	grammar(Version,Path),
	name(Path,PathL),
      (	name(Level,[_,_,_,_,_,N]),
		Num = [N]
      ;	name(Level,[_,_,_,_,_,N1,N2]),
		Num = [N1,N2]	),
	grammar_file(PathL,Num,GFile),
	consult(GFile),
	dictionary_file(PathL,Num,DFile),
	consult(DFile),
	extra_file(PathL,Num,PFile),
	consult(PFile),
	jumanTolanglab.

% Error
sftb(Version,Level) :-
	write('Irregal Version or Level was specified : '),
	write(Version), write(' or '), write(Level), nl,
	fail.

grammar_file(Path,Level,File) :-
	file_name(body,Body),
	name(Body,BodyL),
	append(Path,BodyL,F),
	append(F,Level,Fi),
	extension(body,Ext),
	name(Ext,ExtL),
	append(Fi,ExtL,Fil),
	name(File,Fil).

dictionary_file(Path,Level,File) :-
	file_name(dict,Body),
	name(Body,BodyL),
	append(Path,BodyL,F),
	append(F,Level,Fi),
	extension(dict,Ext),
	name(Ext,ExtL),
	append(Fi,ExtL,Fil),
	name(File,Fil).

extra_file(Path,Level,File) :-
	file_name(extra,Body),
	name(Body,BodyL),
	append(Path,BodyL,F),
	append(F,Level,Fi),
	extension(extra,Ext),
	name(Ext,ExtL),
	append(Fi,ExtL,Fil),
	name(File,Fil).

% You can use the jumanTolanglab/0 predicate to parse Japanese sentences.
% You do this by consulting the files, `juman2sax.pl' and `jumanTwosax.pl'.
% Then entering `jlanglab' into Prolog query.

jumanTolanglab :-
        ['~/sax/juman2sax.pl',
         '~/FSE/JUMAN-LangLAB/lib/juman2langlab.pl'].

% Miscellaneous predicates

append([],L,L) :- !.
append([X|T],Y,[X|Z]) :-
	append(T,Y,Z).

% End of File
