From 4e9d1ec76073159a7e49c270a000f8ec7ff4a502 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Thu, 20 Dec 2018 23:04:19 +0000 Subject: [PATCH] Replace tokezing process with actual tokenizer. Now we can handle things like 3*x and even 3x --- polymani.pl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/polymani.pl b/polymani.pl index e00ae01..f26c59e 100644 --- a/polymani.pl +++ b/polymani.pl @@ -33,6 +33,13 @@ */ :- use_module(library(clpr)). +/* + * The porter_stem library implements the stemming algorithm described by + * Porter in Porter, 1980, ``An algorithm for suffix stripping''. + * The library also includes a functional tokenizer +*/ +:- use_module(library(porter_stem)). + /******************************* * NLP * *******************************/ @@ -48,10 +55,11 @@ polyplay :- read_line_to_codes(user_input, InCodes), %% Restore old prompt prompt(_, OldPrompt), - %% Split the input at spaces and ignore \r and \t - split_string(InCodes, " ", "\r\t", LS), - %% Convert each set of codes into a term or atom, as appropriate - maplist(name, LA, LS), + %% Use the porter_stem library to tokenize the input + %% This does more than splitting at the spaces, such as + %% splitting at operators. Aditionally, gives + %% atoms already and handles 'P1' well + tokenize_atom(InCodes, LA), ( %% If we read a 'bye', terminate LA == [bye],