File: ontology.py

package info (click to toggle)
cyphesis-cpp 0.5.16-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 5,084 kB
  • ctags: 3,627
  • sloc: cpp: 30,418; python: 4,812; xml: 4,674; sh: 4,118; makefile: 902; ansic: 617
file content (23 lines) | stat: -rw-r--r-- 603 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#This file is distributed under the terms of the GNU General Public license.
#Copyright (C) 1999 Aloril (See the file COPYING for details).

from mind.panlingua.panlingua import *

o=semnet

def add_link(fr,type,to,mass=1.0):
    semlink(fr,type,to,mass,o)

add_link("#breakfast_verb1","isa","#eat_verb2")
add_link("#lunch_verb1","isa","#eat_verb2")
add_link("#sup_verb1","isa","#eat_verb2")

def get_isa(id):
    res=[]
    if not o.has_key(id): return res
    s=o[id]
    res.append(s)
    for l in s.semlinks:
        if l.type=='isa' and l.fr==s:
            res=res+get_isa(l.to.id)
    return res