Natural Language Toolkit
DICHIARAZIONE DI UNA NUOVA KNOLEDGE_BASElocal kb = knowledge_base()SALVATAGGIO DELLA KNOLEDGE_BASEkb:save(filename)CARICAMENTO DI UNA KNOLEDGE_BASE SALVATAkb:load(filename)
kb = { db = { words = { } }}
-- scorciatoia alla tabella wordslocal words = knowledge_base.db.wordswords[iParola][iContesto][iTipo] = RecordDettagli
-- DETTAGLIO PER I NOMIRecordDettaglio ={ sex = { -- definizione del 'sesso' della parola, <true> è impostato in corrispondenza della forma -- corrente della parola, <false> viene usato se una forma non esiste, <noun> è una -- stringa che rimanda al nome nella forma corrispondente. smale = true | false | noun, sfemale = true | false | noun, pmale = true | false | noun, pfemale = true | false | noun }, -- tabella contenente una serie di oggetti synonym (sinonimi) synonyms = {}, -- tabella di oggetti opposite (contrari) opposites = {}, -- tabella dei proprietari (non saprei come definirlo, sono ignurante :) ), partOf -- ossia di tutti i nomi di cui fa parte (es.: ruota -> partOf -> automobile, camion, motorino, ...) partOf = {}, -- tabella delle parti (owners), ossia contiene tutte le parti che lo compongono -- (es.: automobile -> owns -> ruota, sedile, volante, ...), terrà conto anche della quantità compresi -- valori indefiniti (molto, poco, alcuni, ecc...) owners = {}, -- tabella dei gruppi (memberOf), contiene i gruppi di cui fa parte la parola -- (es.: gatto -> memberOf -> mammiferi, felini, ... ) membersOf = {}, -- tabella dei membri di un gruppo rappresentato dalla parola -- (es.: mammifero -> groups -> gatto, delfino, cane, ...) groups = {}, -- tabella delle proprietà (aggettivi) tipiche di questo nome -- (es.: cane -> properties -> peloso, domestico, ecc...) properties = {}, -- tabella degli stati tipici di questo nome -- (** da sviluppare **) states = {}, -- tabella delle locazioni tipici per questo nome -- (es.: sardina -> locations -> mare, oceano, ...), saranno previste modalità per memorizzare -- luoghi indefiniti. locations = {}, -- tabella dei tempi associabili a questo nome -- (** da sviluppare **) timings = {}, -- tabella delle azioni tipiche associabili al nome -- sono distinte in azioni passive e attive. -- (es.: Il pesce nuota = pesce -> active-action -> nuotare, -- (Il pesce viene pescato = pesce -> passive-action -> pescare) actions = { active = {}, passive = {} }, -- patterns di frasi tipiche utilizzate con il nome in oggetto. -- Esisteranno dei pattern generici per i nomi, ma questi qua -- dovrebbero servire ad aiutare con utilizzi figurati e frasi tipo: -- parola = fiasco -> Ho fatto fiasco -> pattern = [SUBJECT][VERB]fiasco -- che in realtà significa 'ho fallito'. -- ** per ora è solo un'idea da sviluppare ** patterns = {}}
kb:noun(name, context, data)
*************************** TEST: Word Class ***************************PARTE 1 : Creazione delle seguenti parole:- veloce, rapido, agile, scattante------------------------000088 +-+-[WORD]:New()000090 | Word correctly created : veloce000092 +-+-[WORD]:New()000096 | Word correctly created : rapido000097 +-+-[WORD]:New()000099 | Word correctly created : agile000100 +-+-[WORD]:New()000102 | Word correctly created : scattantePARTE 2 : Creazione relazioni tra sinonimi:Creazione relazioni tra sinonimi...- veloce sinonimo di rapido- rapido sinonimo di agile- scattante sinonimo di veloce000105 +-+-[WORD]:Synonym() -> 'rapido' synonym of 'veloce'000107 | :: PROPAGATION ::000108 | (1) ENTITY is synonym of all SYNONYM synonyms000109 | (2) ENTITY's synonyms are synonyms of all SYNONYM's synonyms000110 | (3) ENTITY's opposites are opposites of all SYNONYM's synonyms000111 | (4) ENTITY's synonyms are synonym of SYNONYM000112 | (5) ENTITY's synonyms are opposites of all SYNONYM's opposites000114 | (6) ENTITY is opposite of all SYNONYM's opposites000115 | (7) ENTITY's opposites are opposite of SYNONYM000115 | (8) ENTITY's opposites are synonyms of SYNONYM's opposites000117 | Propagated to 0 entities.000117 | :: STRAIGHT RELATION ::000118 | Synonym link between 'veloce' and 'rapido' created.000119 | :: INVERSE RELATION ::000120 +-+-[WORD]:Synonym() -> 'veloce' synonym of 'rapido'000122 | :: PROPAGATION ::000123 | (1) ENTITY is synonym of all SYNONYM synonyms000124 +-+-[WORD]:Synonym() -> 'rapido' synonym of 'rapido'000126 | WARNING [WORD] Cannot link a word with itself.000129 | (2) ENTITY's synonyms are synonyms of all SYNONYM's synonyms000130 | (3) ENTITY's opposites are opposites of all SYNONYM's synonyms000131 | (4) ENTITY's synonyms are synonym of SYNONYM000132 | (5) ENTITY's synonyms are opposites of all SYNONYM's opposites000132 | (6) ENTITY is opposite of all SYNONYM's opposites000133 | (7) ENTITY's opposites are opposite of SYNONYM000134 | (8) ENTITY's opposites are synonyms of SYNONYM's opposites000135 | Propagated to 0 entities.000136 | :: STRAIGHT RELATION ::000137 | Synonym link between 'rapido' and 'veloce' created.000139 +-+-[WORD]:Synonym() -> 'agile' synonym of 'rapido'000141 | :: PROPAGATION ::000142 | (1) ENTITY is synonym of all SYNONYM synonyms000148 | (2) ENTITY's synonyms are synonyms of all SYNONYM's synonyms000149 | (3) ENTITY's opposites are opposites of all SYNONYM's synonyms000151 | (4) ENTITY's synonyms are synonym of SYNONYM000152 +-+-[WORD]:Synonym() -> 'agile' synonym of 'veloce'000154 | :: STRAIGHT RELATION ::000155 | Synonym link between 'veloce' and 'agile' created.000157 | :: INVERSE RELATION ::000158 +-+-[WORD]:Synonym() -> 'veloce' synonym of 'agile'000160 | :: STRAIGHT RELATION ::000162 | Synonym link between 'agile' and 'veloce' created.000164 | (5) ENTITY's synonyms are opposites of all SYNONYM's opposites000165 | (6) ENTITY is opposite of all SYNONYM's opposites000166 | (7) ENTITY's opposites are opposite of SYNONYM000168 | (8) ENTITY's opposites are synonyms of SYNONYM's opposites000171 | Propagated to 1 entities.000172 | :: STRAIGHT RELATION ::000174 | Synonym link between 'rapido' and 'agile' created.000175 | :: INVERSE RELATION ::000176 +-+-[WORD]:Synonym() -> 'rapido' synonym of 'agile'000178 | :: PROPAGATION ::000180 | (1) ENTITY is synonym of all SYNONYM synonyms000181 +-+-[WORD]:Synonym() -> 'agile' synonym of 'agile'000184 | WARNING [WORD] Cannot link a word with itself.000188 +-+-[WORD]:Synonym() -> 'veloce' synonym of 'agile'000190 | :: STRAIGHT RELATION ::000191 | Synonym 'veloce' already linked, No Strenght change.000192 | (2) ENTITY's synonyms are synonyms of all SYNONYM's synonyms000194 +-+-[WORD]:Synonym() -> 'agile' synonym of 'veloce'000196 | :: STRAIGHT RELATION ::000197 | Synonym 'agile' already linked, No Strenght change.000199 +-+-[WORD]:Synonym() -> 'veloce' synonym of 'veloce'000201 | WARNING [WORD] Cannot link a word with itself.000205 +-+-[WORD]:Synonym() -> 'agile' synonym of 'rapido'000207 | :: STRAIGHT RELATION ::000208 | Synonym 'agile' already linked, No Strenght change.000210 +-+-[WORD]:Synonym() -> 'veloce' synonym of 'rapido'000212 | :: STRAIGHT RELATION ::000213 | Synonym 'veloce' already linked, No Strenght change.000214 | (3) ENTITY's opposites are opposites of all SYNONYM's synonyms000216 | (4) ENTITY's synonyms are synonym of SYNONYM000217 +-+-[WORD]:Synonym() -> 'rapido' synonym of 'veloce'000221 | :: STRAIGHT RELATION ::000222 | Synonym 'rapido' already linked, No Strenght change.000223 +-+-[WORD]:Synonym() -> 'rapido' synonym of 'rapido'000225 | WARNING [WORD] Cannot link a word with itself.000229 | (5) ENTITY's synonyms are opposites of all SYNONYM's opposites000231 | (6) ENTITY is opposite of all SYNONYM's opposites000232 | (7) ENTITY's opposites are opposite of SYNONYM000233 | (8) ENTITY's opposites are synonyms of SYNONYM's opposites000234 | Propagated to 5 entities.000236 | :: STRAIGHT RELATION ::000238 | Synonym link between 'agile' and 'rapido' created.000239 +-+-[WORD]:Synonym() -> 'veloce' synonym of 'scattante'000241 | :: PROPAGATION ::000242 | (1) ENTITY is synonym of all SYNONYM synonyms---8<-------------------cutted---8<-------------------VERIFICA PARTE 2Recupero dei sinonimi delle parole createRELATION 'synonyms' OF veloce agile (1) scattante (1) rapido (1)RELATION 'synonyms' OF rapido agile (1) scattante (1) veloce (1)RELATION 'synonyms' OF agile rapido (1) scattante (1) veloce (1)RELATION 'synonyms' OF scattante agile (1) veloce (1) rapido (1)PARTE 3 : Creazione delle seguenti parole:- lento, pigro, calmo, svogliato000515 +-+-[WORD]:New()000517 | Word correctly created : lento000519 +-+-[WORD]:New()000521 | Word correctly created : pigro000522 +-+-[WORD]:New()000524 | Word correctly created : calmo000525 +-+-[WORD]:New()000528 | Word correctly created : svogliatoCreazione relazioni tra sinonimi...- lento sinonimo di pigro- lento sinonimo di calmo- lento sinonimo di svogliato000535 +-+-[WORD]:Synonym() -> 'pigro' synonym of 'lento'000537 | :: PROPAGATION ::000538 | (1) ENTITY is synonym of all SYNONYM synonyms000539 | (2) ENTITY's synonyms are synonyms of all SYNONYM's synonyms000541 | (3) ENTITY's opposites are opposites of all SYNONYM's synonyms000542 | (4) ENTITY's synonyms are synonym of SYNONYM000543 | (5) ENTITY's synonyms are opposites of all SYNONYM's opposites000544 | (6) ENTITY is opposite of all SYNONYM's opposites000546 | (7) ENTITY's opposites are opposite of SYNONYM000547 | (8) ENTITY's opposites are synonyms of SYNONYM's opposites000548 | Propagated to 0 entities.000549 | :: STRAIGHT RELATION ::000550 | Synonym link between 'lento' and 'pigro' created.000551 | :: INVERSE RELATION ::000553 +-+-[WORD]:Synonym() -> 'lento' synonym of 'pigro'000555 | :: PROPAGATION ::000556 | (1) ENTITY is synonym of all SYNONYM synonyms000557 +-+-[WORD]:Synonym() -> 'pigro' synonym of 'pigro'000560 | WARNING [WORD] Cannot link a word with itself.000565 | (2) ENTITY's synonyms are synonyms of all SYNONYM's synonyms000566 | (3) ENTITY's opposites are opposites of all SYNONYM's synonyms000567 | (4) ENTITY's synonyms are synonym of SYNONYM000568 | (5) ENTITY's synonyms are opposites of all SYNONYM's opposites000569 | (6) ENTITY is opposite of all SYNONYM's opposites000570 | (7) ENTITY's opposites are opposite of SYNONYM000572 | (8) ENTITY's opposites are synonyms of SYNONYM's opposites000573 | Propagated to 0 entities.000574 | :: STRAIGHT RELATION ::000576 | Synonym link between 'pigro' and 'lento' created.000577 +-+-[WORD]:Synonym() -> 'calmo' synonym of 'lento'000579 | :: PROPAGATION ::000580 | (1) ENTITY is synonym of all SYNONYM synonyms---8<-----------cutted---8<-----------Recupero dei sinonimi delle parole createRELATION 'synonyms' OF lento calmo (1) svogliato (1) pigro (1)RELATION 'synonyms' OF pigro calmo (1) svogliato (1) lento (1)RELATION 'synonyms' OF calmo lento (1) svogliato (1) pigro (1)RELATION 'synonyms' OF svogliato pigro (1) lento (1) calmo (1)Creazione relazioni tra contrari...lento contrario di veloce000892 +-+-[WORD]:Opposite() -> 'veloce' opposite of 'lento'000896 | :: PROPAGATION ::000897 | (1) ENTITY is opposite of all OPPOSITE's synonyms000898 +-+-[WORD]:Opposite() -> 'scattante' opposite of 'lento'000900 | :: STRAIGHT RELATION ::000902 | WARNING [WORD] Opposite link between 'lento' and 'scattante' created.000907 | :: REVERSE RELATION ::000908 +-+-[WORD]:Opposite() -> 'lento' opposite of 'scattante'000912 | :: STRAIGHT RELATION ::000914 | WARNING [WORD] Opposite link between 'scattante' and 'lento' created.000921 +-+-[WORD]:Opposite() -> 'agile' opposite of 'lento'000924 | :: STRAIGHT RELATION ::000925 | WARNING [WORD] Opposite link between 'lento' and 'agile' created.000932 | :: REVERSE RELATION ::000933 +-+-[WORD]:Opposite() -> 'lento' opposite of 'agile'000936 | :: STRAIGHT RELATION ::000937 | WARNING [WORD] Opposite link between 'agile' and 'lento' created.000942 +-+-[WORD]:Opposite() -> 'rapido' opposite of 'lento'000946 | :: STRAIGHT RELATION ::000948 | WARNING [WORD] Opposite link between 'lento' and 'rapido' created.000954 | :: REVERSE RELATION ::000955 +-+-[WORD]:Opposite() -> 'lento' opposite of 'rapido'000957 | :: STRAIGHT RELATION ::000959 | WARNING [WORD] Opposite link between 'rapido' and 'lento' created.000965 | (2) ENTITY's synonyms are opposite of OPPOSITE's synonyms000967 +-+-[WORD]:Opposite() -> 'scattante' opposite of 'svogliato'000970 | :: STRAIGHT RELATION ::000971 | WARNING [WORD] Opposite link between 'svogliato' and 'scattante' created.000976 | :: REVERSE RELATION ::000977 +-+-[WORD]:Opposite() -> 'svogliato' opposite of 'scattante'000980 | :: STRAIGHT RELATION ::000981 | WARNING [WORD] Opposite link between 'scattante' and 'svogliato' created.000989 +-+-[WORD]:Opposite() -> 'agile' opposite of 'svogliato'000993 | :: STRAIGHT RELATION ::000995 | WARNING [WORD] Opposite link between 'svogliato' and 'agile' created.000999 | :: REVERSE RELATION ::001000 +-+-[WORD]:Opposite() -> 'svogliato' opposite of 'agile'001003 | :: STRAIGHT RELATION ::001004 | WARNING [WORD] Opposite link between 'agile' and 'svogliato' created.001010 +-+-[WORD]:Opposite() -> 'rapido' opposite of 'svogliato'001012 | :: STRAIGHT RELATION ::001014 | WARNING [WORD] Opposite link between 'svogliato' and 'rapido' created.001019 | :: REVERSE RELATION ::001020 +-+-[WORD]:Opposite() -> 'svogliato' opposite of 'rapido'001023 | :: STRAIGHT RELATION ::001024 | WARNING [WORD] Opposite link between 'rapido' and 'svogliato' created.001030 +-+-[WORD]:Opposite() -> 'scattante' opposite of 'calmo'001032 | :: STRAIGHT RELATION ::001034 | WARNING [WORD] Opposite link between 'calmo' and 'scattante' created.001039 | :: REVERSE RELATION ::001040 +-+-[WORD]:Opposite() -> 'calmo' opposite of 'scattante'001042 | :: STRAIGHT RELATION ::001044 | WARNING [WORD] Opposite link between 'scattante' and 'calmo' created.001049 +-+-[WORD]:Opposite() -> 'agile' opposite of 'calmo'001051 | :: STRAIGHT RELATION ::001052 | WARNING [WORD] Opposite link between 'calmo' and 'agile' created.001057 | :: REVERSE RELATION ::001058 +-+-[WORD]:Opposite() -> 'calmo' opposite of 'agile'001061 | :: STRAIGHT RELATION ::001062 | WARNING [WORD] Opposite link between 'agile' and 'calmo' created.001068 +-+-[WORD]:Opposite() -> 'rapido' opposite of 'calmo'001070 | :: STRAIGHT RELATION ::001071 | WARNING [WORD] Opposite link between 'calmo' and 'rapido' created.001077 | :: REVERSE RELATION ::001078 +-+-[WORD]:Opposite() -> 'calmo' opposite of 'rapido'001080 | :: STRAIGHT RELATION ::001082 | WARNING [WORD] Opposite link between 'rapido' and 'calmo' created.001088 +-+-[WORD]:Opposite() -> 'scattante' opposite of 'pigro'001090 | :: STRAIGHT RELATION ::001091 | WARNING [WORD] Opposite link between 'pigro' and 'scattante' created.001096 | :: REVERSE RELATION ::001098 +-+-[WORD]:Opposite() -> 'pigro' opposite of 'scattante'001100 | :: STRAIGHT RELATION ::001102 | WARNING [WORD] Opposite link between 'scattante' and 'pigro' created.001108 +-+-[WORD]:Opposite() -> 'agile' opposite of 'pigro'001110 | :: STRAIGHT RELATION ::001111 | WARNING [WORD] Opposite link between 'pigro' and 'agile' created.001116 | :: REVERSE RELATION ::001117 +-+-[WORD]:Opposite() -> 'pigro' opposite of 'agile'001119 | :: STRAIGHT RELATION ::001121 | WARNING [WORD] Opposite link between 'agile' and 'pigro' created.001126 +-+-[WORD]:Opposite() -> 'rapido' opposite of 'pigro'001129 | :: STRAIGHT RELATION ::001130 | WARNING [WORD] Opposite link between 'pigro' and 'rapido' created.001135 | :: REVERSE RELATION ::001136 +-+-[WORD]:Opposite() -> 'pigro' opposite of 'rapido'001139 | :: STRAIGHT RELATION ::001140 | WARNING [WORD] Opposite link between 'rapido' and 'pigro' created.001146 | (3) ENTITY's opposites are synonyms of OPPOSITE's synonyms001148 +-+-[WORD]:Synonym() -> 'scattante' synonym of 'scattante'001150 | WARNING [WORD] Cannot link a word with itself.001153 +-+-[WORD]:Synonym() -> 'agile' synonym of 'scattante'001155 | :: STRAIGHT RELATION ::---8<-------------cutted---8<-------------Recupero dei contrari delle parole createRELATION 'opposites' OF lento agile (1) rapido (1) veloce (1) scattante (1)RELATION 'opposites' OF pigro agile (1) rapido (1) veloce (1) scattante (1)RELATION 'opposites' OF calmo agile (1) rapido (1) veloce (1) scattante (1)RELATION 'opposites' OF svogliato agile (1) rapido (1) veloce (1) scattante (1)RELATION 'opposites' OF veloce calmo (1) pigro (1) lento (1) svogliato (1)RELATION 'opposites' OF rapido svogliato (1) calmo (1) pigro (1) lento (1)RELATION 'opposites' OF agile svogliato (1) calmo (1) pigro (1) lento (1)RELATION 'opposites' OF scattante svogliato (1) calmo (1) pigro (1) lento (1)Creo la parola 'svelto'002131 +-+-[WORD]:New()002133 | Word correctly created : svelto'svelto' sinonimo di 'rapido'002136 +-+-[WORD]:Synonym() -> 'rapido' synonym of 'svelto'002139 | :: PROPAGATION ::002140 | (1) ENTITY is synonym of all SYNONYM synonyms002141 +-+-[WORD]:Synonym() -> 'scattante' synonym of 'svelto'002144 | :: STRAIGHT RELATION ::002145 | Synonym link between 'svelto' and 'scattante' created.002146 | :: INVERSE RELATION ::002148 +-+-[WORD]:Synonym() -> 'svelto' synonym of 'scattante'002150 | :: STRAIGHT RELATION ::002151 | Synonym link between 'scattante' and 'svelto' created.002153 +-+-[WORD]:Synonym() -> 'agile' synonym of 'svelto'002155 | :: STRAIGHT RELATION ::002156 | Synonym link between 'svelto' and 'agile' created.002157 | :: INVERSE RELATION ::002158 +-+-[WORD]:Synonym() -> 'svelto' synonym of 'agile'002161 | :: STRAIGHT RELATION ::002162 | Synonym link between 'agile' and 'svelto' created.002164 +-+-[WORD]:Synonym() -> 'veloce' synonym of 'svelto'002167 | :: STRAIGHT RELATION ::002168 | Synonym link between 'svelto' and 'veloce' created.002169 | :: INVERSE RELATION ::002170 +-+-[WORD]:Synonym() -> 'svelto' synonym of 'veloce'002172 | :: STRAIGHT RELATION ::002174 | Synonym link between 'veloce' and 'svelto' created.002175 | (2) ENTITY's synonyms are synonyms of all SYNONYM's synonyms002177 +-+-[WORD]:Synonym() -> 'scattante' synonym of 'scattante'002179 | WARNING [WORD] Cannot link a word with itself.002184 +-+-[WORD]:Synonym() -> 'agile' synonym of 'scattante'002186 | :: STRAIGHT RELATION ::002187 | Synonym 'agile' already linked, No Strenght change.002188 | :: INVERSE RELATION ::---8<---------cutted---8<---------VERIFICARELATION 'synonyms' OF svelto agile (1) veloce (1) rapido (1) scattante (1)RELATION 'opposites' OF svelto calmo (1) pigro (1) svogliato (1) lento (1)Waiting...
- delfino [è membro di] mammifero -> mammifero [contiene] delfino- mammifero [è membro di] animale -> animale [contiene] delfino