summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgnowgi <nagarjun@gnowledge.org>2012-07-13 00:45:11 -0700
committergnowgi <nagarjun@gnowledge.org>2012-07-13 00:45:11 -0700
commit184877f00ded7fe61420111de4ec8d48d3bee634 (patch)
tree24d4a963714dfbde84ebfe16ed8dd7edd1222da4
parent97bd4e1f8007a6ab6b6d2f1b3a158567c61f7d72 (diff)
parent2d412122742571b17a4d9a3bc79f20a199c223e6 (diff)
downloadgnowsys-184877f00ded7fe61420111de4ec8d48d3bee634.tar.gz
Merge pull request #70 from anujag/master
controlled natural language presentation, first cut
-rw-r--r--demo/Lexicon.pl114
-rw-r--r--demo/aFile.pl1043
-rw-r--r--gstudio/CNL.py825
-rwxr-xr-xgstudio/createhtml.py19
-rw-r--r--gstudio/lex.py147
-rw-r--r--gstudio/static/gstudio/js/orgitdown/orgitdown/sets/org/images/save.jpegbin0 -> 416 bytes
-rw-r--r--gstudio/templates/gstudio/nodetype_detail.html216
-rw-r--r--gstudio/templatetags/gstudio_tags.py28
-rw-r--r--gstudio/update_lexicon.py100
-rw-r--r--gstudio/views/ajaxviews.py11
-rw-r--r--objectapp/cnlgb.py633
-rw-r--r--objectapp/templates/objectapp/skeleton.html5
-rw-r--r--objectapp/views/ajaxviews.py1
13 files changed, 3018 insertions, 124 deletions
diff --git a/demo/Lexicon.pl b/demo/Lexicon.pl
new file mode 100644
index 0000000..173dfdc
--- /dev/null
+++ b/demo/Lexicon.pl
@@ -0,0 +1,114 @@
+noun_sg(person, person, neutr).
+noun_pl(persons, person, neutr).
+noun_sg(human-being, human-being, neutr).
+adj_tr('parent-of', 'parent-of', of).
+adj_tr('child-of', 'child-of', of).
+noun_sg(common-noun, common-noun, neutr).
+noun_sg(simple-noun, simple-noun, neutr).
+noun_sg(noun, noun, neutr).
+noun_sg(college, college, neutr).
+noun_pl(colleges, college, neutr).
+noun_sg(university, university, neutr).
+noun_sg(human, human, neutr).
+noun_sg(people, people, neutr).
+pn_sg('Ananya', 'Ananya', neutr).
+pn_sg('Shruti', 'Shruti', neutr).
+pn_sg('User', 'User', neutr).
+pn_sg('Sancheeta', 'Sancheeta', neutr).
+pn_sg('Crunch', 'Crunch', neutr).
+adj_tr('located-in', 'located-in', in).
+prep(in, in).
+tv_finsg(contains, contain).
+adj_tr('spouse-of', 'spouse-of', of).
+prep(of, of).
+adj_tr('sibling-of', 'sibling-of', of).
+adj_tr('friend-of', 'friend-of', of).
+noun_sg(time, time, neutr).
+noun_sg(date, date, neutr).
+noun_sg(color, color, neutr).
+noun_sg(date-of-birth, date-of-birth, neutr).
+noun_sg(birth-date, birth-date, neutr).
+tv_finsg(comprises, comprise).
+pn_sg('India', 'India', neutr).
+pn_sg('Bharat', 'Bharat', neutr).
+pn_sg('Mumbai', 'Mumbai', neutr).
+pn_sg('Bombay', 'Bombay', neutr).
+noun_sg(place, place, neutr).
+noun_pl(places, place, neutr).
+noun_sg(location, location, neutr).
+noun_sg(man, man, neutr).
+noun_pl(men, man, neutr).
+noun_sg(male, male, neutr).
+pn_sg('Delhi', 'Delhi', neutr).
+pn_sg('Sugu', 'Sugu', neutr).
+noun_sg(proper-noun, proper-noun, neutr).
+noun_sg(population, population, neutr).
+noun_sg(laboratory, laboratory, neutr).
+noun_pl(laboratories, laboratory, neutr).
+noun_sg(lab, lab, neutr).
+noun_sg(field, field, neutr).
+noun_sg(profession, profession, neutr).
+noun_pl(professions, profession, neutr).
+noun_sg(career, career, neutr).
+noun_sg(teacher, teacher, neutr).
+noun_pl(teachers, teacher, neutr).
+noun_sg(professor, professor, neutr).
+noun_pl(universities, university, neutr).
+noun_sg(country, country, neutr).
+noun_pl(countries, country, neutr).
+noun_sg(nation, nation, neutr).
+noun_sg(city, city, neutr).
+noun_pl(cities, city, neutr).
+noun_sg(metropolis, metropolis, neutr).
+noun_sg(institution, institution, neutr).
+pn_sg('Milind-K', 'Milind-K', neutr).
+pn_sg('Engineering', 'Engineering', neutr).
+pn_sg('Computer-Science', 'Computer-Science', neutr).
+pn_sg('Information-Technology', 'Information-Technology', neutr).
+pn_sg('It', 'It', neutr).
+pn_sg('Vidyullata-Devmane', 'Vidyullata-Devmane', neutr).
+pn_sg('Abirami-Shivaprasad', 'Abirami-Shivaprasad', neutr).
+pn_sg('Mumbai-University', 'Mumbai-University', neutr).
+pn_sg('Shah-And-Anchor-Kutchhi-Engineering-College', 'Shah-And-Anchor-Kutchhi-Engineering-College', neutr).
+pn_sg('Sakec', 'Sakec', neutr).
+pn_sg('Vinit-Kotak', 'Vinit-Kotak', neutr).
+pn_sg('Kotak-Sir', 'Kotak-Sir', neutr).
+tv_finsg(teaches, teach).
+noun_sg(taught, taught, neutr).
+noun_pl(taughts, taught, neutr).
+adj_tr('taught-by', 'taught-by', by).
+prep(by, by).
+noun_sg(student, student, neutr).
+noun_pl(students, student, neutr).
+adj_tr('student-of', 'student-of', of).
+noun_sg(teacher, teacher, neutr).
+noun_pl(teachers, teacher, neutr).
+adj_tr('teacher-of', 'teacher-of', of).
+noun_sg(branch, branch, neutr).
+noun_pl(branches, branch, neutr).
+adj_tr('branch-of', 'branch-of', of).
+noun_sg(comprises, comprises, neutr).
+noun_pl(comprise, comprises, neutr).
+adj_tr('comprises-of', 'comprises-of', of).
+noun_sg(bigger, bigger, neutr).
+noun_pl(biggers, bigger, neutr).
+adj_tr('bigger-than', 'bigger-than', than).
+prep(than, than).
+noun_sg(smaller, smaller, neutr).
+noun_pl(smallers, smaller, neutr).
+adj_tr('smaller-than', 'smaller-than', than).
+noun_sg(located, located, neutr).
+noun_pl(locateds, located, neutr).
+noun_sg(spouse, spouse, neutr).
+noun_pl(spouses, spouse, neutr).
+noun_sg(sibling, sibling, neutr).
+noun_pl(siblings, sibling, neutr).
+noun_sg(friend, friend, neutr).
+noun_pl(friends, friend, neutr).
+noun_sg(parent, parent, neutr).
+noun_pl(parents, parent, neutr).
+noun_sg(child, child, neutr).
+noun_pl(children, child, neutr).
+adj_tr('husband-of', 'husband-of', of).
+adj_tr('wife-of', 'wife-of', of).
+adj_tr('trunk-of', 'trunk-of', of).
diff --git a/demo/aFile.pl b/demo/aFile.pl
new file mode 100644
index 0000000..daa4b53
--- /dev/null
+++ b/demo/aFile.pl
@@ -0,0 +1,1043 @@
+noun_sg(person, person, neutr).
+noun_pl(persons, person, neutr).
+noun_sg(human-being, human-being, neutr).
+adj_tr('parent-of', 'parent-of', of).
+adj_tr('child-of', 'child-of', of).
+noun_sg(common-noun, common-noun, neutr).
+noun_sg(simple-noun, simple-noun, neutr).
+noun_sg(noun, noun, neutr).
+noun_sg(college, college, neutr).
+noun_pl(colleges, college, neutr).
+noun_sg(university, university, neutr).
+noun_sg(human, human, neutr).
+noun_sg(people, people, neutr).adj_itr(active, active).
+adj_itr(angry, angry).
+adj_itr(authenticated, authenticated).
+adj_itr(automatic, automatic).
+adj_itr(average, average).
+adj_itr(bad, bad).
+adj_itr(big, big).
+adj_itr(blue, blue).
+adj_itr(clean, clean).
+adj_itr(clever, clever).
+adj_itr(cold, cold).
+adj_itr(correct, correct).
+adj_itr(criminal, criminal).
+adj_itr(deep, deep).
+adj_itr(dirty, dirty).
+adj_itr(empty, empty).
+adj_itr(enormous, enormous).
+adj_itr(evil, evil).
+adj_itr(expensive, expensive).
+adj_itr(expired, expired).
+adj_itr(fair, fair).
+adj_itr(false, false).
+adj_itr(famous, famous).
+adj_itr(far, far).
+adj_itr(fast, fast).
+adj_itr(female, female).
+adj_itr(flat, flat).
+adj_itr(good, good).
+adj_itr(great, great).
+adj_itr(green, green).
+adj_itr(happy, happy).
+adj_itr(hard, hard).
+adj_itr(high, high).
+adj_itr(human, human).
+adj_itr(hungry, hungry).
+adj_itr(important, important).
+adj_itr(impossible, impossible).
+adj_itr(interesting, interesting).
+adj_itr(invalid, invalid).
+adj_itr(large, large).
+adj_itr(long, long).
+adj_itr(lost, lost).
+adj_itr(natural, natural).
+adj_itr(necessary, necessary).
+adj_itr(new, new).
+adj_itr(nice, nice).
+adj_itr(numb, numb).
+adj_itr(numeric, numeric).
+adj_itr(old, old).
+adj_itr(open, open).
+adj_itr(personal, personal).
+adj_itr(public, public).
+adj_itr(quick, quick).
+adj_itr(raw, raw).
+adj_itr(real, real).
+adj_itr(red, red).
+adj_itr(reflexive, reflexive).
+adj_itr(rich, rich).
+adj_itr(sad, sad).
+adj_itr(small, small).
+adj_itr(smart, smart).
+adj_itr(tall, tall).
+adj_itr(tired, tired).
+adj_itr(transitive, transitive).
+adj_itr(true, true).
+adj_itr(unnecessary, unnecessary).
+adj_itr(used, used).
+adj_itr(valid, valid).
+adj_itr(warm, warm).
+adj_itr(wet, wet).
+adj_itr(white, white).
+adj_itr(young, young).
+adj_itr_comp(angrier, angry).
+adj_itr_comp(worse, bad).
+adj_itr_comp(bigger, big).
+adj_itr_comp(bluer, blue).
+adj_itr_comp(cleaner, clean).
+adj_itr_comp(cleverer, clever).
+adj_itr_comp(colder, cold).
+adj_itr_comp(deeper, deep).
+adj_itr_comp(dirtier, dirty).
+adj_itr_comp(fairer, fair).
+adj_itr_comp(falser, false).
+adj_itr_comp(farther, far).
+adj_itr_comp(further, far).
+adj_itr_comp(faster, fast).
+adj_itr_comp(better, good).
+adj_itr_comp(greater, great).
+adj_itr_comp(greener, green).
+adj_itr_comp(happier, happy).
+adj_itr_comp(harder, hard).
+adj_itr_comp(higher, high).
+adj_itr_comp(larger, large).
+adj_itr_comp(longer, long).
+adj_itr_comp(newer, new).
+adj_itr_comp(nicer, nice).
+adj_itr_comp(number, numb).
+adj_itr_comp(elder, old).
+adj_itr_comp(older, old).
+adj_itr_comp(redder, red).
+adj_itr_comp(richer, rich).
+adj_itr_comp(sadder, sad).
+adj_itr_comp(smaller, small).
+adj_itr_comp(smarter, smart).
+adj_itr_comp(taller, tall).
+adj_itr_comp(truer, true).
+adj_itr_comp(warmer, warm).
+adj_itr_comp(wetter, wet).
+adj_itr_comp(whiter, white).
+adj_itr_comp(younger, young).
+adj_itr_sup(angriest, angry).
+adj_itr_sup(worst, bad).
+adj_itr_sup(biggest, big).
+adj_itr_sup(bluest, blue).
+adj_itr_sup(cleanest, clean).
+adj_itr_sup(cleverest, clever).
+adj_itr_sup(coldest, cold).
+adj_itr_sup(deepest, deep).
+adj_itr_sup(dirtiest, dirty).
+adj_itr_sup(fairest, fair).
+adj_itr_sup(falsest, false).
+adj_itr_sup(farthest, far).
+adj_itr_sup(furthest, far).
+adj_itr_sup(fastest, fast).
+adj_itr_sup(best, good).
+adj_itr_sup(greatest, great).
+adj_itr_sup(greenest, green).
+adj_itr_sup(happiest, happy).
+adj_itr_sup(hardest, hard).
+adj_itr_sup(highest, high).
+adj_itr_sup(largest, large).
+adj_itr_sup(longest, long).
+adj_itr_sup(newest, new).
+adj_itr_sup(nicest, nice).
+adj_itr_sup(numbest, numb).
+adj_itr_sup(eldest, old).
+adj_itr_sup(oldest, old).
+adj_itr_sup(reddest, red).
+adj_itr_sup(richest, rich).
+adj_itr_sup(saddest, sad).
+adj_itr_sup(smallest, small).
+adj_itr_sup(smartest, smart).
+adj_itr_sup(tallest, tall).
+adj_itr_sup(truest, true).
+adj_itr_sup(warmest, warm).
+adj_itr_sup(wettest, wet).
+adj_itr_sup(whitest, white).
+adj_itr_sup(youngest, young).
+adj_tr('located-in', 'located-in', in).
+adj_tr('registered-at', 'registered-at', at).
+adj_tr('fond-of', 'fond-of', of).
+adj_tr('interested-in', 'interested-in', in).
+adj_tr('mad-about', 'mad-about', about).
+adj_tr_comp('fonder-of', 'fond-of', of).
+adj_tr_comp('madder-about', 'mad-about', about).
+adj_tr_sup('fondest-of', 'fond-of', of).
+adj_tr_sup('maddest-about', 'mad-about', about).
+adv(always, always).
+adv(carefully, carefully).
+adv(easily, easily).
+adv(extremely, extremely).
+adv(fast, fast).
+adv(happily, happily).
+adv(hard, hard).
+adv(large, large).
+adv(long, long).
+adv(loudly, loudly).
+adv(manually, manually).
+adv(patiently, patiently).
+adv(quickly, quickly).
+adv(safely, safely).
+adv(silently, silently).
+adv(soundly, soundly).
+adv(speedily, speedily).
+adv(vaguely, vaguely).
+adv(wisely, wisely).
+adv(consistently, consistently).
+adv_comp(faster, fast).
+adv_comp(harder, hard).
+adv_sup(fastest, fast).
+adv_sup(hardest, hard).
+iv_finsg(ages, age).
+iv_finsg(appears, appear).
+iv_finsg(arrives, arrive).
+iv_finsg(barks, bark).
+iv_finsg(blinks, blink).
+iv_finsg(boils, boil).
+iv_finsg(collapses, collapse).
+iv_finsg(comes, come).
+iv_finsg(counts, count).
+iv_finsg(dances, dance).
+iv_finsg(drinks, drink).
+iv_finsg(drives, drive).
+iv_finsg(eats, eat).
+iv_finsg(exists, exist).
+iv_finsg(expires, expire).
+iv_finsg(flies, fly).
+iv_finsg(flows, flow).
+iv_finsg(goes, go).
+iv_finsg(happens, happen).
+iv_finsg(holds, hold).
+iv_finsg(hurries, hurry).
+iv_finsg(lives, live).
+iv_finsg(loses, lose).
+iv_finsg(moves, move).
+iv_finsg(plays, play).
+iv_finsg(reads, read).
+iv_finsg(runs, run).
+iv_finsg(scores, score).
+iv_finsg(sinks, sink).
+iv_finsg(sits, sit).
+iv_finsg(sleeps, sleep).
+iv_finsg(smells, smell).
+iv_finsg(smiles, smile).
+iv_finsg(snores, snore).
+iv_finsg(succeeds, succeed).
+iv_finsg(talks, talk).
+iv_finsg(waits, wait).
+iv_finsg(walks, walk).
+iv_finsg(wins, win).
+iv_finsg(works, work).
+iv_infpl(age, age).
+iv_infpl(appear, appear).
+iv_infpl(arrive, arrive).
+iv_infpl(bark, bark).
+iv_infpl(blink, blink).
+iv_infpl(boil, boil).
+iv_infpl(collapse, collapse).
+iv_infpl(come, come).
+iv_infpl(count, count).
+iv_infpl(dance, dance).
+iv_infpl(drink, drink).
+iv_infpl(drive, drive).
+iv_infpl(eat, eat).
+iv_infpl(exist, exist).
+iv_infpl(expire, expire).
+iv_infpl(fly, fly).
+iv_infpl(flow, flow).
+iv_infpl(go, go).
+iv_infpl(happen, happen).
+iv_infpl(hold, hold).
+iv_infpl(hurry, hurry).
+iv_infpl(live, live).
+iv_infpl(lose, lose).
+iv_infpl(move, move).
+iv_infpl(play, play).
+iv_infpl(read, read).
+iv_infpl(run, run).
+iv_infpl(score, score).
+iv_infpl(sink, sink).
+iv_infpl(sit, sit).
+iv_infpl(sleep, sleep).
+iv_infpl(smell, smell).
+iv_infpl(smile, smile).
+iv_infpl(snore, snore).
+iv_infpl(succeed, succeed).
+iv_infpl(talk, talk).
+iv_infpl(wait, wait).
+iv_infpl(walk, walk).
+iv_infpl(win, win).
+iv_infpl(work, work).
+noun_pl('zip-codes', 'zip-code', neutr).
+noun_pl(accounts, account, neutr).
+noun_pl(addresses, address, neutr).
+noun_pl(adjectives, adjective, neutr).
+noun_pl(ages, age, neutr).
+noun_pl(aircraft, aircraft, neutr).
+noun_pl(airlines, airline, neutr).
+noun_pl(ancestors, ancestor, human).
+noun_pl(animals, animal, neutr).
+noun_pl(apes, ape, neutr).
+noun_pl(apples, apple, neutr).
+noun_pl(approaches, approach, neutr).
+noun_pl(articles, article, neutr).
+noun_pl(assets, asset, neutr).
+noun_pl(balls, ball, neutr).
+noun_pl(banks, bank, neutr).
+noun_pl(beds, bed, neutr).
+noun_pl(beers, beer, neutr).
+noun_pl(bikes, bike, neutr).
+noun_pl(bodies, body, neutr).
+noun_pl(bones, bone, neutr).
+noun_pl(books, book, neutr).
+noun_pl(bosses, boss, human).
+noun_pl(boxes, box, neutr).
+noun_pl(boys, boy, masc).
+noun_pl(branches, branch, neutr).
+noun_pl(bretheren, brother, human).
+noun_pl(brothers, brother, masc).
+noun_pl(buttons, button, neutr).
+noun_pl(cakes, cake, neutr).
+noun_pl(cars, car, neutr).
+noun_pl(cards, card, neutr).
+noun_pl(cases, case, neutr).
+noun_pl(cats, cat, neutr).
+noun_pl(cheeses, cheese, neutr).
+noun_pl(children, child, human).
+noun_pl(circles, circle, neutr).
+noun_pl(cities, city, neutr).
+noun_pl(clerks, clerk, human).
+noun_pl(codes, code, neutr).
+noun_pl(colors, color, neutr).
+noun_pl(companies, company, human).
+noun_pl(computers, computer, neutr).
+noun_pl(contents, content, neutr).
+noun_pl(contracts, contract, neutr).
+noun_pl(countries, country, neutr).
+noun_pl(covers, cover, neutr).
+noun_pl(cows, cow, human).
+noun_pl(criminals, criminal, human).
+noun_pl(customers, customer, human).
+noun_pl(databases, database, neutr).
+noun_pl(dates, date, neutr).
+noun_pl(days, day, neutr).
+noun_pl(declarations, declaration, neutr).
+noun_pl(deliveries, delivery, neutr).
+noun_pl(descriptions, description, neutr).
+noun_pl(desks, desk, neutr).
+noun_pl(developments, development, neutr).
+noun_pl(displays, display, neutr).
+noun_pl(doctors, doctor, human).
+noun_pl(dogs, dog, neutr).
+noun_pl(donkeys, donkey, neutr).
+noun_pl(drinks, drink, neutr).
+noun_pl(eggs, egg, neutr).
+noun_pl(elements, element, neutr).
+noun_pl(equals, equal, neutr).
+noun_pl(errors, error, neutr).
+noun_pl(eyes, eye, neutr).
+noun_pl(farmers, farmer, human).
+noun_pl(fathers, father, masc).
+noun_pl(flats, flat, neutr).
+noun_pl(flowers, flower, neutr).
+noun_pl(flies, fly, neutr).
+noun_pl(forms, form, neutr).
+noun_pl(foxes, fox, neutr).
+noun_pl(fridges, fridge, neutr).
+noun_pl(friends, friend, human).
+noun_pl(gardens, garden, neutr).
+noun_pl(girls, girl, fem).
+noun_pl(goals, goal, neutr).
+noun_pl(groups, group, neutr).
+noun_pl(hands, hand, neutr).
+noun_pl(heroes, hero, human).
+noun_pl(horses, horse, neutr).
+noun_pl(hours, hour, neutr).
+noun_pl(houses, house, neutr).
+noun_pl(humans, human, human).
+noun_pl(institutions, institution, neutr).
+noun_pl(integers, integer, neutr).
+noun_pl(left_applicable_type, left_applicable_type, neutr).
+noun_pl(left_subjecttypes, left_subjecttype, neutr).
+noun_pl(lives, life, neutr).
+noun_pl(lifts, lift, neutr).
+noun_pl(lists, list, neutr).
+noun_pl(machines, machine, neutr).
+noun_pl(mails, mail, neutr).
+noun_pl(men, man, human).
+noun_pl(managers, manager, human).
+noun_pl(masters, master, human).
+noun_pl(members, member, human).
+noun_pl(messages, message, neutr).
+noun_pl(milks, milk, neutr).
+noun_pl(mothers, mother, fem).
+noun_pl(mice, mouse, neutr).
+noun_pl(names, name, neutr).
+noun_pl(numbers, number, neutr).
+noun_pl(objects, object, neutr).
+noun_pl(offers, offer, neutr).
+noun_pl(offices, office, neutr).
+noun_pl(owners, owner, human).
+noun_pl(papers, paper, neutr).
+noun_pl(parents, parent, human).
+noun_pl(parks, park, neutr).
+noun_pl(passwords, password, neutr).
+noun_pl(pencils, pencil, neutr).
+noun_pl(persons, person, human).
+noun_pl(pets, pet, neutr).
+noun_pl(pizzas, pizza, neutr).
+noun_pl(places, place, neutr).
+noun_pl(points, point, neutr).
+noun_pl(posterior_nodes, posterior_node, neutr).
+noun_pl(prices, price, neutr).
+noun_pl(prior_nodes, prior_node, neutr).
+noun_pl(processes, process, neutr).
+noun_pl(programs, program, neutr).
+noun_pl(propositions, proposition, neutr).
+noun_pl(rats, rat, neutr).
+noun_pl(reasons, reason, neutr).
+noun_pl(resources, resource, neutr).
+noun_pl(right_applicable_type, right_applicable_type, neutr).
+noun_pl(right_subjecttypes, right_subjecttype, neutr).
+noun_pl(rooms, room, neutr).
+noun_pl(schools, school, neutr).
+noun_pl(scores, score, neutr).
+noun_pl(screens, screen, neutr).
+noun_pl(sentences, sentence, neutr).
+noun_pl(services, service, neutr).
+noun_pl(sheep, sheep, neutr).
+noun_pl(signs, sign, neutr).
+noun_pl(sisters, sister, fem).
+noun_pl(slots, slot, neutr).
+noun_pl(spaces, space, neutr).
+noun_pl(statins, station, neutr).
+noun_pl(streets, street, neutr).
+noun_pl(subscriptions, subscription, neutr).
+noun_pl(subtypes, subtype, neutr).
+noun_pl(surfaces, surface, neutr).
+noun_pl(symmetricals, symmetrical, neutr).
+noun_pl(tables, table, neutr).
+noun_pl(talks, talk, neutr).
+noun_pl(terms, term, neutr).
+noun_pl(tests, test, neutr).
+noun_pl(texts, text, neutr).
+noun_pl(things, thing, neutr).
+noun_pl(titles, title, neutr).
+noun_pl(towns, town, neutr).
+noun_pl(trains, train, neutr).
+noun_pl(uncles, uncle, masc).
+noun_pl(users, user, human).
+noun_pl(values, value, neutr).
+noun_pl(vehicles, vehicle, neutr).
+noun_pl(villages, village, neutr).
+noun_pl(watches, watch, neutr).
+noun_pl(wives, wife, human).
+noun_pl(wines, wine, neutr).
+noun_pl(wolves, wolf, neutr).
+noun_pl(women, woman, human).
+noun_pl(works, work, neutr).
+noun_pl(years, year, neutr).
+noun_sg('zip-code', 'zip-code', neutr).
+noun_sg(account, account, neutr).
+noun_sg(address, address, neutr).
+noun_sg(adjective, adjective, neutr).
+noun_sg(age, age, neutr).
+noun_sg(aircraft, aircraft, neutr).
+noun_sg(airline, airline, neutr).
+noun_sg(ancestor, ancestor, human).
+noun_sg(animal, animal, neutr).
+noun_sg(ape, ape, neutr).
+noun_sg(apple, apple, neutr).
+noun_sg(approach, approach, neutr).
+noun_sg(article, article, neutr).
+noun_sg(asset, asset, neutr).
+noun_sg(ball, ball, neutr).
+noun_sg(bank, bank, neutr).
+noun_sg(bed, bed, neutr).
+noun_sg(beer, beer, neutr).
+noun_sg(bike, bike, neutr).
+noun_sg(body, body, neutr).
+noun_sg(bone, bone, neutr).
+noun_sg(book, book, neutr).
+noun_sg(boss, boss, human).
+noun_sg(box, box, neutr).
+noun_sg(boy, boy, masc).
+noun_sg(branch, branch, neutr).
+noun_sg(brother, brother, masc).
+noun_sg(button, button, neutr).
+noun_sg(cake, cake, neutr).
+noun_sg(car, car, neutr).
+noun_sg(card, card, neutr).
+noun_sg(case, case, neutr).
+noun_sg(cat, cat, neutr).
+noun_sg(cheese, cheese, neutr).
+noun_sg(child, child, human).
+noun_sg(circle, circle, neutr).
+noun_sg(city, city, neutr).
+noun_sg(clerk, clerk, human).
+noun_sg(code, code, neutr).
+noun_sg(color, color, neutr).
+noun_sg(company, company, human).
+noun_sg(computer, computer, neutr).
+noun_sg(content, content, neutr).
+noun_sg(contract, contract, neutr).
+noun_sg(country, country, neutr).
+noun_sg(cover, cover, neutr).
+noun_sg(cow, cow, human).
+noun_sg(criminal, criminal, human).
+noun_sg(customer, customer, human).
+noun_sg(database, database, neutr).
+noun_sg(date, date, neutr).
+noun_sg(day, day, neutr).
+noun_sg(declaration, declaration, neutr).
+noun_sg(delivery, delivery, neutr).
+noun_sg(description, description, neutr).
+noun_sg(desk, desk, neutr).
+noun_sg(development, development, neutr).
+noun_sg(display, display, neutr).
+noun_sg(doctor, doctor, human).
+noun_sg(dog, dog, neutr).
+noun_sg(donkey, donkey, neutr).
+noun_sg(drink, drink, neutr).
+noun_sg(egg, egg, neutr).
+noun_sg(element, element, neutr).
+noun_sg(equal, equal, neutr).
+noun_sg(error, error, neutr).
+noun_sg(eye, eye, neutr).
+noun_sg(farmer, farmer, human).
+noun_sg(father, father, masc).
+noun_sg(flat, flat, neutr).
+noun_sg(flower, flower, neutr).
+noun_sg(fly, fly, neutr).
+noun_sg(form, form, neutr).
+noun_sg(fox, fox, neutr).
+noun_sg(fridge, fridge, neutr).
+noun_sg(friend, friend, human).
+noun_sg(garden, garden, neutr).
+noun_sg(girl, girl, fem).
+noun_sg(goal, goal, neutr).
+noun_sg(group, group, neutr).
+noun_sg(hand, hand, neutr).
+noun_sg(hero, hero, human).
+noun_sg(horse, horse, neutr).
+noun_sg(hour, hour, neutr).
+noun_sg(house, house, neutr).
+noun_sg(human, human, human).
+noun_sg(id, id, neutr).
+noun_sg(institution, institution, neutr).
+noun_sg(integer, integer, neutr).
+noun_sg(inverse, inverse, neutr).
+noun_sg(left_applicable_type, left_applicable_type, neutr).
+noun_sg(left_subjecttype, left_subjecttype, neutr).
+noun_sg(life, life, neutr).
+noun_sg(lift, lift, neutr).
+noun_sg(list, list, neutr).
+noun_sg(machine, machine, neutr).
+noun_sg(mail, mail, neutr).
+noun_sg(man, man, masc).
+noun_sg(manager, manager, human).
+noun_sg(master, master, human).
+noun_sg(member, member, human).
+noun_sg(message, message, neutr).
+noun_sg(milk, milk, neutr).
+noun_sg(mother, mother, fem).
+noun_sg(mouse, mouse, neutr).
+noun_sg(name, name, neutr).
+noun_sg(number, number, neutr).
+noun_sg(object, object, neutr).
+noun_sg(object_type, object_type, neutr).
+noun_sg(offer, offer, neutr).
+noun_sg(office, office, neutr).
+noun_sg(owner, owner, human).
+noun_sg(paper, paper, neutr).
+noun_sg(parent, parent, human).
+noun_sg(park, park, neutr).
+noun_sg(password, password, neutr).
+noun_sg(pencil, pencil, neutr).
+noun_sg(person, person, human).
+noun_sg(pet, pet, neutr).
+noun_sg(pizza, pizza, neutr).
+noun_sg(place, place, neutr).
+noun_sg(plural, plural, neutr).
+noun_sg(point, point, neutr).
+noun_sg(posterior_node, posterior_node, neutr).
+noun_sg(price, price, neutr).
+noun_sg(prior_node, prior_node, neutr).
+noun_sg(process, process, neutr).
+noun_sg(program, program, neutr).
+noun_sg(proposition, proposition, neutr).
+noun_sg(rat, rat, neutr).
+noun_sg(reason, reason, neutr).
+noun_sg(resource, resource, neutr).
+noun_sg(right_applicable_type, right_applicable_type, neutr).
+noun_sg(right_subjecttype, right_subjecttype, neutr).
+noun_sg(room, room, neutr).
+noun_sg(school, school, neutr).
+noun_sg(score, score, neutr).
+noun_sg(screen, screen, neutr).
+noun_sg(sentence, sentence, neutr).
+noun_sg(service, service, neutr).
+noun_sg(sheep, sheep, neutr).
+noun_sg(sign, sign, neutr).
+noun_sg(sister, sister, fem).
+noun_sg(slot, slot, neutr).
+noun_sg(space, space, neutr).
+noun_sg(station, station, neutr).
+noun_sg(street, street, neutr).
+noun_sg(subscription, subscription, neutr).
+noun_sg(subtype, subtype, neutr).
+noun_sg(surface, surface, neutr).
+noun_sg(symmetrical, symmetrical, neutr).
+noun_sg(table, table, neutr).
+noun_sg(talk, talk, neutr).
+noun_sg(term, term, neutr).
+noun_sg(test, test, neutr).
+noun_sg(text, text, neutr).
+noun_sg(thing, thing, neutr).
+noun_sg(title, title, neutr).
+noun_sg(town, town, neutr).
+noun_sg(train, train, neutr).
+noun_sg(uncle, uncle, masc).
+noun_sg(user, user, human).
+noun_sg(value, value, neutr).
+noun_sg(vehicle, vehicle, neutr).
+noun_sg(village, village, neutr).
+noun_sg(watch, watch, neutr).
+noun_sg(wife, wife, fem).
+noun_sg(wine, wine, neutr).
+noun_sg(wolf, wolf, neutr).
+noun_sg(woman, woman, fem).
+noun_sg(work, work, neutr).
+noun_sg(year, year, neutr).
+pn_sg('Bill', 'Bill', masc).
+pn_sg('John', 'John', masc).
+pn_sg('Tom', 'Tom', masc).
+pn_sg('Mike', 'Mike', masc).
+pn_sg('Mary', 'Mary', fem).
+pn_sg('Sue', 'Sue', fem).
+pn_sg('Lara', 'Lara', fem).
+pn_sg('Jane', 'Jane', fem).
+pn_sg('Berlin', 'Berlin', neutr).
+pn_sg('Paris', 'Paris', neutr).
+pn_sg('Zurich', 'Zurich', neutr).
+pn_sg('Rome', 'Rome', neutr).
+pn_sg('Switzerland', 'Switzerland', neutr).
+pn_sg('Germany', 'Germany', neutr).
+pn_sg('France', 'France', neutr).
+pn_sg('Italy', 'Italy', neutr).
+pn_sg('Austria', 'Austria', neutr).
+pn_sg('Russia', 'Russia', neutr).
+pn_sg('Canada', 'Canada', neutr).
+tv_finsg('comes-from', 'come-from').
+tv_finsg('lives-at', 'live-at').
+tv_finsg('looks-at', 'look-at').
+tv_finsg('waits-for', 'wait-for').
+tv_finsg('works-at', 'work-at').
+tv_finsg(accepts, accept).
+tv_finsg(accesses, access).
+tv_finsg(assigns, assign).
+tv_finsg(awaits, await).
+tv_finsg(beats, beat).
+tv_finsg(believes, believe).
+tv_finsg(bites, bite).
+tv_finsg(blames, blame).
+tv_finsg(books, book).
+tv_finsg(brings, bring).
+tv_finsg(buys, buy).
+tv_finsg(cancels, cancel).
+tv_finsg(carries, carry).
+tv_finsg(charges, charge).
+tv_finsg(cleans, clean).
+tv_finsg(codes, code).
+tv_finsg(considers, consider).
+tv_finsg(contains, contain).
+tv_finsg(corrects, correct).
+tv_finsg(counts, count).
+tv_finsg(dates, date).
+tv_finsg(delivers, deliver).
+tv_finsg(displays, display).
+tv_finsg(downloads, download).
+tv_finsg(drinks, drink).
+tv_finsg(drives, drive).
+tv_finsg(eats, eat).
+tv_finsg(enters, enter).
+tv_finsg(fears, fear).
+tv_finsg(forms, form).
+tv_finsg(gets, get).
+tv_finsg(gives, give).
+tv_finsg(has, have).
+tv_finsg(hates, hate).
+tv_finsg(hears, hear).
+tv_finsg(hits, hit).
+tv_finsg(holds, hold).
+tv_finsg(inserts, insert).
+tv_finsg(invites, invite).
+tv_finsg(keeps, keep).
+tv_finsg(knows, know).
+tv_finsg(lifts, lift).
+tv_finsg(likes, like).
+tv_finsg(lists, list).
+tv_finsg(loses, lose).
+tv_finsg(loves, love).
+tv_finsg(masters, master).
+tv_finsg(meets, meet).
+tv_finsg(moves, move).
+tv_finsg(needs, need).
+tv_finsg(offers, offer).
+tv_finsg(opens, open).
+tv_finsg(owns, own).
+tv_finsg(pays, pay).
+tv_finsg(processes, process).
+tv_finsg(proves, prove).
+tv_finsg(reads, read).
+tv_finsg(rejects, reject).
+tv_finsg(replaces, replace).
+tv_finsg(runs, run).
+tv_finsg(says, say).
+tv_finsg(sees, see).
+tv_finsg(sells, sell).
+tv_finsg(sends, send).
+tv_finsg(sets, set).
+tv_finsg(steals, steal).
+tv_finsg(takes, take).
+tv_finsg(tests, test).
+tv_finsg(understands, understand).
+tv_finsg(uses, use).
+tv_finsg(visits, visit).
+tv_finsg(wants, want).
+tv_finsg(watches, watch).
+tv_finsg(wins, win).
+tv_finsg(writes, write).
+tv_infpl('come-from', 'come-from').
+tv_infpl('live-at', 'live-at').
+tv_infpl('look-at', 'look-at').
+tv_infpl('wait-for', 'wait-for').
+tv_infpl('work-at', 'work-at').
+tv_infpl(accept, accept).
+tv_infpl(access, access).
+tv_infpl(assign, assign).
+tv_infpl(await, await).
+tv_infpl(beat, beat).
+tv_infpl(believe, believe).
+tv_infpl(bite, bite).
+tv_infpl(blame, blame).
+tv_infpl(book, book).
+tv_infpl(bring, bring).
+tv_infpl(buy, buy).
+tv_infpl(cancel, cancel).
+tv_infpl(carry, carry).
+tv_infpl(charge, charge).
+tv_infpl(clean, clean).
+tv_infpl(code, code).
+tv_infpl(consider, consider).
+tv_infpl(contain, contain).
+tv_infpl(correct, correct).
+tv_infpl(count, count).
+tv_infpl(date, date).
+tv_infpl(deliver, deliver).
+tv_infpl(display, display).
+tv_infpl(download, download).
+tv_infpl(drink, drink).
+tv_infpl(drive, drive).
+tv_infpl(eat, eat).
+tv_infpl(enter, enter).
+tv_infpl(fear, fear).
+tv_infpl(form, form).
+tv_infpl(get, get).
+tv_infpl(give, give).
+tv_infpl(have, have).
+tv_infpl(hate, hate).
+tv_infpl(hear, hear).
+tv_infpl(hit, hit).
+tv_infpl(hold, hold).
+tv_infpl(insert, insert).
+tv_infpl(invite, invite).
+tv_infpl(keep, keep).
+tv_infpl(know, know).
+tv_infpl(lift, lift).
+tv_infpl(like, like).
+tv_infpl(list, list).
+tv_infpl(lose, lose).
+tv_infpl(love, love).
+tv_infpl(master, master).
+tv_infpl(meet, meet).
+tv_infpl(move, move).
+tv_infpl(need, need).
+tv_infpl(offer, offer).
+tv_infpl(open, open).
+tv_infpl(own, own).
+tv_infpl(pay, pay).
+tv_infpl(process, process).
+tv_infpl(prove, prove).
+tv_infpl(read, read).
+tv_infpl(reject, reject).
+tv_infpl(replace, replace).
+tv_infpl(run, run).
+tv_infpl(say, say).
+tv_infpl(see, see).
+tv_infpl(sell, sell).
+tv_infpl(send, send).
+tv_infpl(set, set).
+tv_infpl(steal, steal).
+tv_infpl(take, take).
+tv_infpl(test, test).
+tv_infpl(understand, understand).
+tv_infpl(use, use).
+tv_infpl(visit, visit).
+tv_infpl(want, want).
+tv_infpl(watch, watch).
+tv_infpl(win, win).
+tv_infpl(write, write).
+tv_pp(accepted, accept).
+tv_pp(assigned, assign).
+tv_pp(awaited, await).
+tv_pp(beaten, beat).
+tv_pp(believed, believe).
+tv_pp(bitten, bite).
+tv_pp(blamed, blame).
+tv_pp(booked, book).
+tv_pp(brought, bring).
+tv_pp(bought, buy).
+tv_pp(cancelled, cancel).
+tv_pp(carried, carry).
+tv_pp(charged, charge).
+tv_pp(cleaned, clean).
+tv_pp(coded, code).
+tv_pp(considered, consider).
+tv_pp(contained, contain).
+tv_pp(containing, contain).
+tv_pp(corrected, correct).
+tv_pp(counted, count).
+tv_pp(dated, date).
+tv_pp(delivered, deliver).
+tv_pp(displayed, display).
+tv_pp(downloaded, download).
+tv_pp(drunk, drink).
+tv_pp(driven, drive).
+tv_pp(eaten, eat).
+tv_pp(entered, enter).
+tv_pp(feared, fear).
+tv_pp(formed, form).
+tv_pp(got, get).
+tv_pp(gotten, get).
+tv_pp(given, give).
+tv_pp(had, have).
+tv_pp(hated, hate).
+tv_pp(heard, hear).
+tv_pp(hit, hit).
+tv_pp(held, hold).
+tv_pp(inserted, insert).
+tv_pp(invited, invite).
+tv_pp(kept, keep).
+tv_pp(known, know).
+tv_pp(lifted, lift).
+tv_pp(liked, like).
+tv_pp(listed, list).
+tv_pp(lost, lose).
+tv_pp(loved, love).
+tv_pp(mastered, master).
+tv_pp(met, meet).
+tv_pp(moved, move).
+tv_pp(needed, need).
+tv_pp(offered, offer).
+tv_pp(opened, open).
+tv_pp(owned, own).
+tv_pp(paid, pay).
+tv_pp(processed, process).
+tv_pp(proved, prove).
+tv_pp(proven, prove).
+tv_pp(read, read).
+tv_pp(rejected, reject).
+tv_pp(replaced, replace).
+tv_pp(run, run).
+tv_pp(said, say).
+tv_pp(seen, see).
+tv_pp(sold, sell).
+tv_pp(sent, send).
+tv_pp(set, set).
+tv_pp(stolen, steal).
+tv_pp(taken, take).
+tv_pp(tested, test).
+tv_pp(understood, understand).
+tv_pp(used, use).
+tv_pp(visited, visit).
+tv_pp(wanted, want).
+tv_pp(watched, watch).
+tv_pp(won, win).
+tv_pp(written, write).
+prep(from, from).
+prep(as, as).
+prep(about, about).
+prep(for, for).
+prep(among, among).
+prep(amongst, amongst).
+prep(like, like).
+prep(without, without).
+prep(despite, despite).
+prep(amid, amid).
+prep(aboard, aboard).
+prep(in, in).
+prep(at, at).
+prep(on, on).
+prep(over, over).
+prep(around, around).
+prep(between, between).
+prep(inside, inside).
+prep(behind, behind).
+prep(below, below).
+prep(beneath, beneath).
+prep(outside, outside).
+prep(upon, upon).
+prep(under, under).
+prep(above, above).
+prep(beside, beside).
+prep(near, near).
+prep(throughout, throughout).
+prep(before, before).
+prep(after, after).
+prep(within, within).
+prep(till, till).
+prep(until, until).
+prep(to, to).
+prep(into, into).
+prep(through, through).
+prep(toward, toward).
+prep(towards, towards).
+prep(onto, onto).
+prep(across, across).
+prep(off, off).
+prep(down, down).
+prep(up, up).
+prep(along, along).
+prep(past, past).
+prep(beyond, beyond).
+prep(out, out).
+prep(against, against).
+prep(alongside, alongside).
+prep(via, via).
+prep(with, with).
+prep(during, during).
+noun_sg(college, college, neutr).
+noun_pl(colleges, college, neutr).
+noun_sg(university, university, neutr).
+noun_sg(human-being, human-being, neutr).
+noun_sg(human, human, neutr).
+noun_sg(person, person, neutr).
+noun_pl(persons, person, neutr).
+noun_sg(human-being, human-being, neutr).
+pn_sg('Ananya', 'Ananya', neutr).
+pn_sg('Shruti', 'Shruti', neutr).
+pn_sg('User', 'User', neutr).
+adj_tr('parent-of', 'parent-of', of).
+adj_tr('child-of', 'child-of', of).
+noun_sg(common-noun, common-noun, neutr).
+noun_sg(simple-noun, simple-noun, neutr).
+noun_sg(noun, noun, neutr).
+noun_sg(date-of-birth, date-of-birth, neutr).
+noun_sg(birth-date, birth-date, neutr).
+noun_sg(people, people, neutr).
+pn_sg('Ananya', 'Ananya', neutr).
+pn_sg('Shruti', 'Shruti', neutr).
+pn_sg('User', 'User', neutr).
+pn_sg('Sancheeta', 'Sancheeta', neutr).
+pn_sg('Crunch', 'Crunch', neutr).
+adj_tr('located-in', 'located-in', in).
+prep(in, in).
+tv_finsg(contains, contain).
+adj_tr('spouse-of', 'spouse-of', of).
+prep(of, of).
+adj_tr('sibling-of', 'sibling-of', of).
+adj_tr('friend-of', 'friend-of', of).
+noun_sg(time, time, neutr).
+noun_sg(date, date, neutr).
+noun_sg(color, color, neutr).
+noun_sg(date-of-birth, date-of-birth, neutr).
+noun_sg(birth-date, birth-date, neutr).
+tv_finsg(comprises, comprise).
+pn_sg('India', 'India', neutr).
+pn_sg('Bharat', 'Bharat', neutr).
+pn_sg('Mumbai', 'Mumbai', neutr).
+pn_sg('Bombay', 'Bombay', neutr).
+noun_sg(place, place, neutr).
+noun_pl(places, place, neutr).
+noun_sg(location, location, neutr).
+noun_sg(man, man, neutr).
+noun_pl(men, man, neutr).
+noun_sg(male, male, neutr).
+pn_sg('Delhi', 'Delhi', neutr).
+pn_sg('Sugu', 'Sugu', neutr).
+noun_sg(proper-noun, proper-noun, neutr).
+noun_sg(population, population, neutr).
+noun_sg(laboratory, laboratory, neutr).
+noun_pl(laboratories, laboratory, neutr).
+noun_sg(lab, lab, neutr).
+noun_sg(field, field, neutr).
+noun_sg(profession, profession, neutr).
+noun_pl(professions, profession, neutr).
+noun_sg(career, career, neutr).
+noun_sg(teacher, teacher, neutr).
+noun_pl(teachers, teacher, neutr).
+noun_sg(professor, professor, neutr).
+noun_pl(universities, university, neutr).
+noun_sg(country, country, neutr).
+noun_pl(countries, country, neutr).
+noun_sg(nation, nation, neutr).
+noun_sg(test2, test2, neutr).
+noun_sg(city, city, neutr).
+noun_pl(cities, city, neutr).
+noun_sg(metropolis, metropolis, neutr).
+noun_sg(institution, institution, neutr).
+pn_sg('Milind-K', 'Milind-K', neutr).
+pn_sg('Engineering', 'Engineering', neutr).
+pn_sg('Computer-Science', 'Computer-Science', neutr).
+pn_sg('Information-Technology', 'Information-Technology', neutr).
+pn_sg('It', 'It', neutr).
+pn_sg('Vidyullata-Devmane', 'Vidyullata-Devmane', neutr).
+pn_sg('Abirami-Shivaprasad', 'Abirami-Shivaprasad', neutr).
+pn_sg('Mumbai-University', 'Mumbai-University', neutr).
+pn_sg('Shah-And-Anchor-Kutchhi-Engineering-College', 'Shah-And-Anchor-Kutchhi-Engineering-College', neutr).
+pn_sg('Sakec', 'Sakec', neutr).
+pn_sg('Vinit-Kotak', 'Vinit-Kotak', neutr).
+pn_sg('Kotak-Sir', 'Kotak-Sir', neutr).
+tv_finsg(teaches, teach).
+noun_sg(taught, taught, neutr).
+noun_pl(taughts, taught, neutr).
+adj_tr('taught-by', 'taught-by', by).
+prep(by, by).
+noun_sg(student, student, neutr).
+noun_pl(students, student, neutr).
+adj_tr('student-of', 'student-of', of).
+noun_sg(teacher, teacher, neutr).
+noun_pl(teachers, teacher, neutr).
+adj_tr('teacher-of', 'teacher-of', of).
+noun_sg(branch, branch, neutr).
+noun_pl(branches, branch, neutr).
+adj_tr('branch-of', 'branch-of', of).
+noun_sg(comprises, comprises, neutr).
+noun_pl(comprise, comprises, neutr).
+adj_tr('comprises-of', 'comprises-of', of).
+noun_sg(bigger, bigger, neutr).
+noun_pl(biggers, bigger, neutr).
+adj_tr('bigger-than', 'bigger-than', than).
+prep(than, than).
+noun_sg(smaller, smaller, neutr).
+noun_pl(smallers, smaller, neutr).
+adj_tr('smaller-than', 'smaller-than', than).
+noun_sg(located, located, neutr).
+noun_pl(locateds, located, neutr).
+noun_sg(spouse, spouse, neutr).
+noun_pl(spouses, spouse, neutr).
+noun_sg(sibling, sibling, neutr).
+noun_pl(siblings, sibling, neutr).
+noun_sg(friend, friend, neutr).
+noun_pl(friends, friend, neutr).
+noun_sg(parent, parent, neutr).
+noun_pl(parents, parent, neutr).
+noun_sg(child, child, neutr).
+noun_pl(children, child, neutr).
+adj_tr('husband-of', 'husband-of', of).
+adj_tr('wife-of', 'wife-of', of).
+adj_tr('trunk-of', 'trunk-of', of).
diff --git a/gstudio/CNL.py b/gstudio/CNL.py
new file mode 100644
index 0000000..4139474
--- /dev/null
+++ b/gstudio/CNL.py
@@ -0,0 +1,825 @@
+from gstudio.models import *
+from django.template.defaultfilters import slugify
+import inflect
+
+
+def get_CNL_list(self):
+ x = []
+ a = get_lex_sentence(self)
+ if not a:
+ pass
+ else:
+ x.extend(a)
+ b = lex_sentence_optional(self)
+ if not b:
+ pass
+ else:
+ x.extend(b)
+ c = contains_subtypes_sentence(self)
+ if not c:
+ pass
+ else:
+ x.extend(c)
+ d = typeof_sentence(self)
+ if not d:
+ pass
+ else:
+ x.extend(d)
+ e = get_CNL_dependency(self)
+ if not e:
+ pass
+ else:
+ x.extend(e)
+ f = get_rel(self)
+ if not f:
+ pass
+ else:
+ x.extend(f)
+ g = get_attr_sentence(self)
+ if not g:
+ pass
+ else:
+ x.extend(g)
+ return x
+
+
+def advanced_CNL(self):
+ y = []
+ h = get_leftST_sentence(self)
+ if not h:
+ pass
+ else:
+ y.extend(h)
+ i = get_rightST_sentence(self)
+ if not i:
+ pass
+ else:
+ y.extend(i)
+ j = get_ST_sentence(self)
+ if not j:
+ pass
+ else:
+ y.extend(j)
+ k = get_CNL_sentence_authors(self)
+ if not k:
+ pass
+ else:
+ y.extend(k)
+ """To generate CNL data about RT/R"""
+ a = get_RT_sentence(self)
+ if not a:
+ pass
+ else:
+ y.extend(a)
+ return y
+
+#Returns lex sentence - Title
+def get_lex_sentence(self):
+ if self.ref.__class__.__name__ is 'Relationtype' or self.ref.__class__.__name__ is 'Attribute':
+ pass
+ else:
+ # If AT or RT
+ at = []
+ if self.title:
+ title = slugify(self.title)
+ title_slug = slugify(title)
+ if self.ref.__class__.__name__ is 'Attributetype' or self.ref.__class__.__name__ is 'Objecttype':
+ g = "A "+str(title_slug).lower()+" is a common-noun."
+ elif self.ref.__class__.__name__ is 'Metatype':
+ g = "A "+str(title_slug).lower()+" is a metatype."
+
+ at.append(g)
+ return at
+
+#Returns CNL sentences - Plural & Alternate names
+def lex_sentence_optional(self):
+
+ # If AT, MT or OT
+ a = []
+ if self.ref.__class__.__name__ is 'Attribute' or self.ref.__class__.__name__ is 'Relationtype':
+ pass
+ elif self.ref.__class__.__name__ is 'Attributetype' or self.ref.__class__.__name__ is 'Objecttype' or self.ref.__class__.__name__ is 'Metatype':
+ title_slug = slugify(self.title)
+ if self.altnames:
+ alt = self.altnames
+ alt_slug = slugify(alt)
+ e = "A "+str(alt_slug)+" is an alternate name for it."
+ a.append(e.capitalize())
+
+ # If MT or OT
+ if self.ref.__class__.__name__ is 'Objecttype' or self.ref.__class__.__name__ is 'Metatype':
+ if self.plural:
+ plu_slug = slugify(self.plural)
+ m="Some "+str(plu_slug)+" are a plural of a "+str(title_slug)+"."
+ a.append(m.capitalize())
+ return a
+
+#Generates CNL sentence for RT for which OT or MT is the left-subjecttype
+def get_leftST_sentence(self):
+ if self.ref.__class__.__name__ is 'Attributetype' or self.ref.__class__.__name__ is 'Relationtype' or self.ref.__class__.__name__ is 'Attribute':
+ pass
+ else:
+ #If OT or MT
+ cns=self.ref.get_nbh
+ d = []
+ for k in cns:
+ title = str(cns['title'])
+ title_slug = slugify(title)
+ if self.ref.__class__.__name__ is 'Objecttype' or 'Metatype':
+ if k == 'left_subjecttype_of':
+ if not cns[k]:
+ pass
+ else:
+ l_s_a = []
+ l_s_a = self.left_subjecttype_of.all()
+ len_lsa=len(l_s_a)
+ if len_lsa == 1:
+ #If singular:
+ for each in l_s_a:
+ al=slugify(each)
+ #A person is a n:left_subjecttype of a n:relation_type a:teaches and a:student-of and a:sibling-of and a:friend-of.
+ if self.ref.__class__.__name__ is 'Objecttype':
+ c = "A "+str(title_slug)+" is a left_subjecttype of a relation_type "+str(al)+"."
+ elif self.ref.__class__.__name__ is 'Metatype':
+ c = "A "+str(title_slug)+" is a left_subjecttype of a relation_type "+str(al)+"."
+ d.append(c.capitalize())
+
+ else:
+ #If plural:
+ y=[]
+ for each in self.left_subjecttype_of.all():
+ a=each
+ a_slug=slugify(a)
+ y.append(a_slug)
+ for e_i in y:
+ if y.index(e_i) == 0:
+ sen = str(e_i)
+ else:
+ sen = str(sen)+" and "+str(e_i)
+ if self.ref.__class__.__name__ is 'Objecttype':
+ c = "A "+str(title_slug)+" is a left_subjecttype of a relation_type "+sen+"."
+ elif self.ref.__class__.__name__ is 'Metatype':
+ c = "A "+str(title_slug)+" is a left_subjecttype of a relation_type "+sen+"."
+
+ d.append(c.capitalize())
+ return d
+
+#Generates CNL sentence for RT for which OT or MT is the right-subjecttype
+def get_rightST_sentence(self):
+ if self.ref.__class__.__name__ is 'Attributetype' or self.ref.__class__.__name__ is 'Relationtype' or self.ref.__class__.__name__ is 'Attribute':
+ pass
+ else:
+ #If OT or MT
+ cns=self.ref.get_nbh
+ d = []
+ for k in cns:
+ title = str(cns['title'])
+ title_slug = slugify(title)
+ if self.ref.__class__.__name__ is 'Objecttype' or self.ref.__class__.__name__ is 'Metatype':
+ if k == 'right_subjecttype_of':
+ if not cns[k]:
+ pass
+ else:
+ r_s_a = []
+ r_s_a = self.right_subjecttype_of.all()
+ len_rsa=len(r_s_a)
+ if len_rsa == 1:
+ #If singular:
+ for each in r_s_a:
+ al=slugify(each)
+ if self.ref.__class__.__name__ is 'Objecttype':
+ c = "A "+str(title_slug)+" is a right_subjecttype of a relation_type "+str(al)+"."
+ elif self.ref.__class__.__name__ is 'Metatype':
+ c = "A "+str(title_slug)+" is a right_subjecttype of a relation_type "+str(al)+"."
+ d.append(c.capitalize())
+
+ else:
+ #If plural:
+ y=[]
+ for each in self.right_subjecttype_of.all():
+ a=each
+ a_slug=slugify(a)
+ y.append(a_slug)
+ for e_i in y:
+ if y.index(e_i) == 0:
+ sen = str(e_i)
+ else:
+ sen = str(sen)+" and "+str(e_i)
+ if self.ref.__class__.__name__ is 'Objecttype':
+ c = "A "+str(title_slug)+" is a right_subjecttype of a relation_type "+sen+"."
+ elif self.ref.__class__.__name__ is 'Metatype':
+ c = "A "+str(title_slug)+" is a right_subjecttype of a relation_type "+sen+"."
+
+ d.append(c.capitalize())
+ return d
+
+#Generates Subject-type sentence for AT
+def get_ST_sentence(self):
+ if self.ref.__class__.__name__ is 'Attribute':
+ pass
+ elif self.ref.__class__.__name__ is 'Attributetype':
+ a = []
+ if self.subjecttype:
+ subjecttype = self.subjecttype
+ st_type = subjecttype.ref.__class__.__name__
+ if st_type == 'Gbobject':
+ c = str(subjecttype)+" is a subject_type_name for it."
+ else:
+ c = "A "+str(subjecttype)+" is a subject_type_name for it."
+ a.append(c.capitalize())
+ return a
+
+
+#Generates contains-subtypes for MT or OT
+def contains_subtypes_sentence(self):
+ if self.ref.__class__.__name__ is 'Metatype' or self.ref.__class__.__name__ is 'Objecttype' or self.ref.__class__.__name__ is 'Attribute':
+ pass
+ elif self.ref.__class__.__name__ is 'Metatype' or self.ref.__class__.__name__ is 'Objecttype':
+ #print "is a mt or OT"
+ #print "it just entered the loop"
+ cns=self.ref.get_nbh
+ d = []
+ for k in cns:
+ title = str(cns['title'])
+ title_slug = slugify(title)
+ if k=='contains_subtypes':
+ if not cns[k]:
+ pass
+ else:
+ if self.ref.__class__.__name__ is 'Metatype':
+ nof=self.children.get_query_set()
+ elif self.ref.__class__.__name__ is 'Objecttype':
+ nof=Nodetype.objects.filter(parent=self.id)
+ len_nof=len(nof)
+ #print "nof----" ,nof
+ #print len_nof, "len - nof"
+ if len_nof == 1:
+ for each in nof:
+ nf=slugify(each)
+ l = "A "+str(nf)+" is a subtype of a "+str(title_slug)+"."
+ d.append(l.capitalize())
+ else:
+ #print "len not 1"
+ y=[]
+ for each in nof:
+ a=each
+ a_slug=slugify(a)
+ y.append(a_slug)
+ for e_i in y:
+ if y.index(e_i) == 0:
+ sen = str(e_i)
+ else:
+ sen = str(sen)+" and a "+str(e_i)
+
+ l = "A "+sen+" are some subtypes of "+str(title_slug)+"."
+ d.append(l.capitalize())
+ return d
+
+#Generates Type-Of sentence for OT or MT
+#get_nbh type_of --- Metatype
+def typeof_sentence(self):
+ d = []
+ if self.ref.__class__.__name__ is 'Relationtype' or self.ref.__class__.__name__ is 'Attributetype' or self.ref.__class__.__name__ is 'Attribute':
+ pass
+ elif self.ref.__class__.__name__ is 'Objecttype' or self.ref.__class__.__name__ is 'Metatype':
+ #print "mt or ot"
+ cns = self.ref.get_nbh
+ for k in cns:
+ title = str(cns['title'])
+ title_slug = slugify(title)
+ if k=='type_of':
+ if not cns[k]:
+ pass
+ else:
+ if self.ref.__class__.__name__ is 'Objecttype':
+ n = self.parent
+ n_slug=slugify(n)
+ elif self.ref.__class__.__name__ is 'Metatype':
+ n = str(cns[k])
+ n_slug=slugify(n)
+ an = "A "+str(title_slug)+" is a type of a "+str(n_slug)+"."
+ d.append(an.capitalize())
+ return d
+
+#Generates CNL Sentence - Prior & Posterior Nodes
+def get_CNL_dependency(self):
+ if self.ref.__class__.__name__ is 'Attribute':
+ pass
+ elif self.ref.__class__.__name__ is 'Objecttype' or self.ref.__class__.__name__ is 'Attributetype' :
+ title = self.title
+ title_slug = slugify(title)
+ d=[]
+ if self.prior_nodes.all():
+ p_n_a = []
+ p_n_a = self.prior_nodes.all()
+ #print len(p_n_a)
+ len_pna=len(p_n_a)
+ if len_pna == 1:
+ for each in p_n_a:
+ pn=slugify(each)
+ h="A "+str(title_slug)+" depends on a "+str(pn)+"."
+ d.append(h.capitalize())
+ else:
+ sen = dependency_plural(p_n_a)
+ h = "A "+str(sen)+". It is required for the meaning of a "+str(title_slug)+"."
+ d.append(h)
+
+ if self.posterior_nodes.all():
+ p_n_a = []
+ p_n_a = self.posterior_nodes.all()
+ #print "length of posterior nodes-----" ,len(p_n_a)
+ len_pna=len(p_n_a)
+ if len_pna == 1:
+ for each in p_n_a:
+ pn = slugify(each)
+ p = "A "+str(title_slug)+" is required for the meaning of a "+str(pn)+"."
+ d.append(p.capitalize())
+ else:
+ sen = dependency_plural(p_n_a)
+ p = "A "+str(sen)+". It depends on "+str(title_slug)+"."
+ d.append(p)
+ return d
+
+#Generates dependency sentence for plural
+def dependency_plural(p_n_a):
+ y=[]
+ #print "len not 1"
+ for each in p_n_a:
+ each_r = each.ref.__class__.__name__
+ apn = each
+ apn_slug = slugify(apn)
+ if len(y) == 0:
+ "If Y is empty, for first item"
+ if each_r == 'Relationtype':
+ b_slug = str(apn_slug)+" is an adjective"
+ else:
+ b_slug = str(apn_slug)+" is a common-noun"
+ y.append(b_slug)
+ else:
+ if each_r != 'Relationtype':
+ #print "Its not a relation_type, but a noun, so appending an 'a' "
+ aa_slug = "a "+str(apn_slug)+" is a common-noun"
+ y.append(aa_slug)
+ else:
+ #print "It is a relationtype"
+ ab_slug = str(apn_slug)+" is an adjective"
+ y.append(ab_slug)
+ for e_i in y:
+ if y.index(e_i) == 0:
+ sen = str(e_i).lower()
+ else:
+ sen = str(sen)+" and "+str(e_i).lower()
+ return sen
+
+
+
+#Generates CNL sentence for authors, in OT and AT
+def get_CNL_sentence_authors(self):
+ title = self.title
+ title_slug = slugify(title)
+ d=[]
+ if self.ref.__class__.__name__ is 'Attribute':
+ pass
+ elif self.ref.__class__.__name__ is 'Objecttype' or self.ref.__class__.__name__ is 'Attributetype':
+ if self.authors.all():
+ auth = []
+ auth = self.authors.all()
+ len_auth=len(auth)
+ if len_auth == 1:
+ for each in auth:
+ aut=slugify(each)
+ e=str(aut).title()+" is an author to a "+str(title_slug)+"."
+ d.append(e.capitalize())
+ else:
+ #print "len not 1"
+ y=[]
+ for each in self.authors.all():
+ a=each
+ a_slug=slugify(a)
+ y.append(a_slug)
+ for e_i in y:
+ if y.index(e_i) == 0:
+ sen = str(e_i)
+ else:
+ sen = str(sen)+" and "+str(e_i)
+
+ e = str(sen).title()+" are all chosen authors to a "+str(title_slug)+"."
+ d.append(e.capitalize())
+ return d
+
+
+
+
+
+
+#Checks if RT-title is a transitive verb finite singular or an iterative adjective
+def istv_title(self):
+ p = inflect.engine()
+ from django.template.defaultfilters import slugify
+ destination = open( "/home/user/gnowsys-studio/demo/aFile.pl", "r+" )
+ f = destination.read()
+ a_t = self.title
+ a = slugify(a_t)
+ if '-' not in a:
+ if a[-1] == 's':
+ a_s = p.singular_noun(a)
+ a_lex = "tv_finsg("+a+", "+str(a_s)+")."
+ strpos = f.find(a_lex)
+ if strpos != -1:
+ return True
+ else:
+ return False
+
+#Checks if RT-inverse is a transitive verb finite singular or an iterative adjective
+def istv_inverse(self):
+ p = inflect.engine()
+ destination = open( "/home/user/gnowsys-studio/demo/aFile.pl", "r+" )
+ f = destination.read()
+ a_t = self.inverse
+ a = slugify(a_t)
+ if '-' not in a:
+ if a[-1] == 's':
+ a_s = p.singular_noun(a)
+ a_lex = "tv_finsg("+a+", "+str(a_s)+")."
+ strpos = f.find(a_lex)
+ if strpos != -1:
+ return True
+ else:
+ return False
+
+
+#Returns attributes for the given OT
+def get_attr_sentence(self):
+ if self.ref.__class__.__name__ is 'Objecttype':
+ from django.template.defaultfilters import slugify
+ ot = self.get_attributes
+ if not ot:
+ pass
+ else:
+ a = []
+ title = self.title
+ title_slug = slugify(title)
+ for k,v in ot.iteritems():
+ attr = k
+ for each in v:
+ value = each
+ attr_slug = slugify(attr)
+ sen = "The "+str(attr_slug)+" of a "+str(title_slug)+" is "+str(value)+"."
+ a.append(sen)
+ return a
+ else:
+ pass
+
+
+def get_list_relation(self, lr):
+ """Returns the list of relations"""
+ gbr = self.get_relations1
+ if not gbr:
+ pass
+ else:
+ for k,v in gbr.iteritems():
+ if k == 'lrelations':
+ val_l = v
+ if k == 'rrelations':
+ val_r = v
+
+ if lr == 0:
+ return val_l
+ elif lr == 1:
+ return val_r
+
+#Generating CNL for RT and Relations:
+#(**Execute get_lex property to update new RT's in lexicon before executing CNL sentences.)
+def get_CNL_sentence_RT(self, lst, rst, detail_level):
+ if self.ref.__class__.__name__ is 'Relationtype':
+ core = [] #core data list
+ core_t = []
+ core_i = []
+ reflexive = []
+ adv = [] # advanced data list
+ title=self.title
+ title_slug=slugify(title)
+ inverse=self.inverse
+ inverse_slug=slugify(inverse)
+ is_symmetrical=self.is_symmetrical
+ is_reflexive=self.is_reflexive
+ llist = []
+ rlist = []
+ llist = lst
+ rlist = rst
+ #print "lst",llist
+ #print "rst",rlist
+ #Flag variable that checks if plural or not
+ plural_l = 0
+ plural_r = 0
+ #print "ll--",llist
+ #print "rr---",rlist
+ if isinstance(llist,list):
+ """If llist is a list"""
+ ll = []
+ for each in llist:
+ if each.ref.__class__.__name__ is not 'Gbobject':
+ """Common-noun"""
+ lst = "a "+str(each).lower()
+ else:
+ """Proper-noun"""
+ lst = str(each).title()
+ ll.append(lst)
+ #print "ll",ll
+ if len(ll) == 1:
+ for e in ll:
+ left_subtype = e
+ #print "e in ll",left_subtype
+ else:
+ plural_l = 1
+ for e in ll:
+ if ll.index(e)==0:
+ sen = str(e)
+ else:
+ sen = str(sen)+" and "+str(e)
+ left_subtype = sen
+ else:
+ """If llist is not a list"""
+ if lst.ref.__class__.__name__ is 'Gbobject':
+ left_subtype = lst
+ else:
+ left_subtype = "a "+str(lst)
+ #print "left_subtype---",left_subtype
+
+ if isinstance(rlist,list):
+ """If rlist is a list"""
+ rl = []
+ for each in rlist:
+ if each.ref.__class__.__name__ is not 'Gbobject':
+ """Common-noun"""
+ rst = "a "+str(each)
+ else:
+ rst = each
+ rl.append(rst)
+ if len(rl) == 1:
+ for e in rl:
+ right_subtype = e
+ #print "rst in e---",right_subtype
+ else:
+ plural_r = 1
+ for e in rl:
+ if rl.index(e)==0:
+ sen = str(e)
+ else:
+ sen = str(sen)+" and "+str(e)
+ right_subtype = sen
+ else:
+ """If Rlist is not a list"""
+ if rst.ref.__class__.__name__ is 'Gbobject':
+ right_subtype = rst
+ else:
+ right_subtype = "a "+str(rst)
+ #print "right_subtype---",right_subtype
+
+
+ #Core sentence - title
+
+ rel = rel_CNL(self, left_subtype, right_subtype, plural_l)
+ #print rel, "the sentence"
+ #print left_subtype
+ #print right_subtype
+ core_t.extend(rel)
+
+
+ rlex = rel_lex_sentence(self)
+ adv.extend(rlex)
+ #print "rlex---",rlex
+
+ app_NT = get_app_NT(self)
+ adv.extend(app_NT)
+ #print "app_NT",app_NT
+
+ st = get_RT_subjecttype(self, left_subtype, right_subtype)
+ adv.extend(st)
+ #print "st---",st
+
+
+
+ #Is symmetrical
+ if is_symmetrical:
+ symm = is_symmetrical_RT(self, left_subtype, right_subtype, plural_r)
+ core_i.extend(symm)
+ #print "symm---",symm
+
+ else:
+ asymm = is_asymmetrical_RT(self, left_subtype, right_subtype, plural_r)
+ core_i.extend(asymm)
+ #print "asymm--",asymm
+ #Is reflexive
+ if is_reflexive:
+ if detail_level == 1 or plural_l == 1:
+ st = right_subtype
+ else:
+ st = left_subtype
+ is_refl = is_reflexive_sentence(self, st)
+ core.extend(is_refl)
+ reflexive.extend(is_refl)
+ #print "is_refl" ,is_refl
+
+ if detail_level==0:
+ #Title,Reflexive
+ for e in core_t:
+ a = e
+ reflexive.insert(0, a)
+ return reflexive
+ elif detail_level==1:
+ #Inverse,reflexive
+ for e in core_i:
+ a = e
+ reflexive.insert(0,a)
+ return reflexive
+ elif detail_level==2:
+ #Title, Inverse & Reflexive
+ core.extend(core_t)
+ core.extend(core_i)
+ core.extend(reflexive)
+ return core
+ elif detail_level==3:
+ #Return advanced grammatical information
+ return adv
+ elif detail_level==4:
+ #Return all info - Core & Advanced Info
+ newlist = []
+ newlist.extend(core)
+ newlist.extend(adv)
+ return newlist
+
+def rel_CNL(self, left_subtype, right_subtype, plural_l):
+ """To generate sentence for relation"""
+ title = self.title
+ title_slug = slugify(title)
+ if self.ref.__class__.__name__ is 'Relationtype':
+ rel = []
+ if istv_title(self):
+ st = str(left_subtype)+" "+str(title).lower()+" "+str(right_subtype)+"."
+ else:
+ if plural_l == 0:
+ st = str(left_subtype)+" is "+str(title).lower()+" "+str(right_subtype)+"."
+ elif plural_l == 1:
+ st = str(left_subtype)+" are "+str(title).lower()+" "+str(right_subtype)+"."
+ rel.append(st.capitalize())
+ return rel
+
+
+def is_reflexive_sentence(self, st):
+ refl = []
+ title = self.title
+ title_slug = slugify(title)
+ if istv_title(self):
+ j= "It is a reflexive sentence. "+str(st).title()+" "+str(title)+" "+str(st)+"."
+ else:
+ j= "It is a reflexive sentence. "+str(st).title()+" is "+str(title)+" "+str(st)+"."
+ refl.append(j)
+ return refl
+
+def is_symmetrical_RT(self, left_subtype, right_subtype, plural_r):
+ """Generates CNL Sentence for Relation/RT if symmetrical"""
+ symm = []
+ title = self.title
+ title_slug = slugify(title)
+ if istv_title(self):
+ g = str(right_subtype).title()+" "+str(title)+" "+str(left_subtype).title()+"."
+ else:
+ if plural_r == 0:
+ g = str(right_subtype).title()+" is "+str(title)+" "+str(left_subtype).title()+"."
+ else:
+ g = str(right_subtype).title()+" are "+str(title)+" "+str(left_subtype).title()+"."
+ symm.append(g.capitalize())
+ return symm
+
+def is_asymmetrical_RT(self, left_subtype, right_subtype, plural_r):
+ """Generates CNL Sentence for Relation/RT if symmetrical"""
+ asymm = []
+ inverse = self.inverse
+ inverse_slug = slugify(inverse)
+ if istv_inverse(self):
+ g = str(right_subtype).title()+" "+str(inverse)+" "+str(left_subtype).title()+"."
+ else:
+ if plural_r == 0:
+ g = str(right_subtype).title()+" is "+str(inverse)+" "+str(left_subtype).title()+"."
+ elif plural_r == 1:
+ g = str(right_subtype).title()+" is "+str(inverse)+" "+str(left_subtype).title()+"."
+ asymm.append(g.capitalize())
+ return asymm
+
+
+def rel_lex_sentence(self):
+ """Generates RT's title & inverse sentence"""
+ if self.ref.__class__.__name__ is 'Relationtype':
+ rlex = []
+ title=self.title
+ title_slug=slugify(title)
+ inverse=self.inverse
+ inverse_slug=slugify(inverse)
+ h="A relation_type's title is "+str(title_slug)+"."
+ rlex.append(h.capitalize())
+
+ if (title==inverse):
+ b="Its title and its inverse are equal."
+ else:
+ b="Its inverse is "+str(inverse_slug)+"."
+ rlex.append(b.capitalize())
+ return rlex
+
+
+def get_app_NT(self):
+ """Generates CNL Sentences for left & right applicable NT for RT"""
+ if self.ref.__class__.__name__ is 'Relationtype':
+ a = []
+ l_app = self.left_applicable_nodetypes
+ r_app=self.right_applicable_nodetypes
+ e = "Its left_applicable_nodetype is "+str(l_app).upper()+"."
+ a.append(e)
+
+ f = "Its right_applicable_nodetype is "+str(r_app).upper()+"."
+ a.append(f)
+ return a
+
+
+
+def get_RT_sentence(self):
+ #Generates CNL Sentences in RT
+ if self.ref.__class__.__name__ is 'Relationtype':
+ sentence = get_CNL_sentence_RT(self, self.left_subjecttype, self.right_subjecttype, 4)
+ return sentence
+
+ #Generates CNL sentences in Relation
+ elif self.ref.__class__.__name__ is 'Relation':
+ sentence = get_CNL_sentence_RT(self.relationtype, self.left_subject, self.right_subject, 4)
+ return sentence
+ else:
+ pass
+
+
+
+
+def get_rel(self):
+ if not self.ref.__class__.__name__ is 'Objecttype':
+ pass
+ else:
+ sen = []
+ sentence = []
+ lr = Relation.objects.filter(left_subject = self.id)
+ rr = Relation.objects.filter(right_subject = self.id)
+
+
+ if lr:
+ """List which stores each right subject"""
+ lst = get_list_relation(self, 0)
+ #print "LR",lst
+ for k,v in lst.iteritems():
+ rel = Relationtype.objects.filter(title = k)
+ val = v
+ for rt in rel:
+ sen = get_CNL_sentence_RT(rt, self, val, 0)
+ #print "sen----lr",sen
+ sentence.extend(sen)
+ #print "sentence lr",sentence
+
+ if rr:
+ """List which stores each left subject"""
+ lst = get_list_relation(self, 1)
+ #print "RR",lst
+ for k,v in lst.iteritems():
+ rel = Relationtype.objects.filter(inverse = k)
+ val = v
+ #print "rel ",rel
+ #print "v ",v
+ for rt in rel:
+ sen = get_CNL_sentence_RT(rt, val, self, 1)
+ #print sen,"sen"
+ sentence.extend(sen)
+ return sentence
+
+
+
+def get_RT_subjecttype(self,lst,rst):
+ """Returns CNL sentence of left & right subject type of RT"""
+ if self.ref.__class__.__name__ is 'Relationtype':
+ left_subtype = lst
+ right_subtype = rst
+ st = []
+ ce = "Its left_subjecttype is "+str(left_subtype)+"."
+ c = ce.capitalize()
+ st.append(c)
+
+ de = "Its right_subjecttype is "+str(right_subtype)+"."
+ d = de.capitalize()
+ st.append(d)
+ return st
+ else:
+ pass
+
+
+
+
+
+
+
+
+
diff --git a/gstudio/createhtml.py b/gstudio/createhtml.py
new file mode 100755
index 0000000..7841408
--- /dev/null
+++ b/gstudio/createhtml.py
@@ -0,0 +1,19 @@
+#! /usr/bin/env python
+
+import sys
+import os
+import commands
+
+def main(argv):
+ #f_name =sys.argv[1]
+ f_name = "/tmp/file.org"
+ s1='commands.getoutput("emacs --batch '
+ s2=" --eval '"
+ s3="(org-export-as-html nil)'"
+ s4='")'
+ out = str(s1)+str(f_name)+str(s2)+str(s3)+str(s4)
+ exec out
+
+if __name__ == "__main__":
+ main(sys.argv)
+
diff --git a/gstudio/lex.py b/gstudio/lex.py
new file mode 100644
index 0000000..a0a90ed
--- /dev/null
+++ b/gstudio/lex.py
@@ -0,0 +1,147 @@
+from gstudio.models import *
+from objectapp.models import *
+from django.template.defaultfilters import slugify
+import inflect
+
+
+def get_lex_author(self):
+ """
+ Generating lexicon file for authors-Proper name
+ """
+ author=self.authors.all()
+ author_list=[]
+ for each in author:
+ author_each=str(each).capitalize()
+ aut="pn_sg('"+author_each+"', '"+author_each+"', neutr)."
+ author_list.append(aut)
+ return author_list
+
+
+
+def get_lex_GB(self):
+ if self.ref.__class__.__name__ is 'Gbobject':
+ a=[]
+ title=self.title
+ title_slug=slugify(title)
+
+ alt=self.altnames
+ alt_slug=slugify(alt)
+ singular="pn_sg('"+title_slug.title()+"', '"+title_slug.title()+"', neutr)."
+ a.append(singular)
+
+ if alt:
+ alts="pn_sg('"+str(alt_slug).title()+"', '"+str(alt_slug).title()+"', neutr)."
+ a.append(alts)
+ return a
+
+
+
+def get_lex_RT(self):
+ if self.ref.__class__.__name__ is 'Relationtype':
+ p = inflect.engine()
+ a=[]
+ title=self.title
+ st=str(title)
+ rst=slugify(st)
+ if '-' in rst:
+ i=rst.index('-')
+ j=i+1
+ l=len(rst)
+ ss=rst[j:l]
+ lext = "adj_tr('"+rst+"', '"+rst+"', "+ss+")."
+ a.append(lext)
+ lex_p = "prep("+ss+", "+ss+")."
+ a.append(lex_p)
+ else:
+ if rst[-1] == 's':
+ rst_sing = p.singular_noun(rst)
+ lex_tv = "tv_finsg("+rst+", "+rst_sing+")."
+ a.append(lex_tv)
+ else:
+ lexa = "adj_tr('"+rst+"', '"+rst+"', -)."
+ a.append(lexa)
+ inverse=self.inverse
+ if title!=inverse:
+ sti=str(inverse)
+ rsti=slugify(sti)
+ if '-' in rsti:
+ ii=rsti.index('-')
+ ji=ii+1
+ li=len(rsti)
+ ssi=rsti[ji:li]
+ lexi="adj_tr('"+rsti+"', '"+rsti+"', "+ssi+")."
+ a.append(lexi)
+ lex_pi = "prep("+ssi+", "+ssi+")."
+ a.append(lex_pi)
+ else:
+ if rsti[-1] == 's':
+ rsti_sing = p.singular_noun(rsti)
+ lex_tvi = "tv_finsg("+rsti+", "+rsti_sing+")."
+ a.append(lex_tvi)
+ else:
+ lexi_a = "adj_tr('"+rsti+"', '"+rsti+"', -)."
+ a.append(lexi_a)
+ return a
+
+
+def get_lex_AT(self):
+ if self.ref.__class__.__name__ is 'Attributetype':
+ """Generates Lexicon entries for AT"""
+ a=[]
+ title = self.title
+ st=str(title)
+ rst=slugify(st)
+ singular="noun_sg("+rst+", "+rst+", neutr)."
+ a.append(singular)
+ alt=self.altnames
+ if alt:
+ st_a=str(alt)
+ rst_a=slugify(st_a)
+ singular_a="noun_sg("+rst_a+", "+rst_a+", neutr)."
+ a.append(singular_a)
+ return a
+
+
+def get_lex_MT(self):
+ if self.ref.__class__.__name__ is 'Metatype':
+ a=[]
+ from django.template.defaultfilters import slugify
+ title=self.title
+ title_slug=slugify(title)
+ plural=self.plural
+ plural_slug=slugify(plural)
+ alt=self.altnames
+ alt_slug=slugify(alt)
+ singular="noun_sg("+title_slug+", "+title_slug+", neutr)."
+ a.append(singular)
+ if plural:
+ pl="noun_pl("+str(plural_slug)+", "+str(title_slug)+", neutr)."
+ a.append(pl)
+ if alt:
+ alts="noun_sg("+str(alt_slug)+", "+str(alt_slug)+", neutr)."
+ a.append(alts)
+ return a
+
+
+
+def get_lex_OT(self):
+ """
+ Generating lexicon file for Objecttype-Noun singular, plural
+ """
+ a=[]
+ title=self.title
+ slug_title=slugify(title)
+ plural=self.plural
+ slug_plural=slugify(plural)
+ alt=self.altnames
+ slug_alt=slugify(alt)
+ singular="noun_sg("+slug_title+", "+slug_title+", neutr)."
+ a.append(singular)
+ if plural:
+ pl="noun_pl("+str(slug_plural)+", "+str(slug_title)+", neutr)."
+ a.append(pl)
+ if alt:
+ alts="noun_sg("+str(slug_alt)+", "+str(slug_alt)+", neutr)."
+ a.append(alts)
+
+ return a
diff --git a/gstudio/static/gstudio/js/orgitdown/orgitdown/sets/org/images/save.jpeg b/gstudio/static/gstudio/js/orgitdown/orgitdown/sets/org/images/save.jpeg
new file mode 100644
index 0000000..fb92d0b
--- /dev/null
+++ b/gstudio/static/gstudio/js/orgitdown/orgitdown/sets/org/images/save.jpeg
Binary files differ
diff --git a/gstudio/templates/gstudio/nodetype_detail.html b/gstudio/templates/gstudio/nodetype_detail.html
index ee7cfcb..c6b86eb 100644
--- a/gstudio/templates/gstudio/nodetype_detail.html
+++ b/gstudio/templates/gstudio/nodetype_detail.html
@@ -60,150 +60,156 @@
<!-- Neighbourhood listing starts -->
<!--Name,Plural Name , Alternate Name ,Type of -->
<b>Name:<nbsp></b> {{ object.title }} <br/>
+<!-- Include CNL -->
+ <b>CNL:<nbsp></b><br>
+ {% get_CNL object as cnlobj %}
+ {% for obj in cnlobj %}
+ {{obj}}<br>
+ {% endfor %}
- {% if object.get_rendered_nbh.plural %}
- <b> Plural Name:<nbsp></b>
- {{object.get_rendered_nbh.plural}} <br/>
- {% endif %}
- {% if object.get_rendered_nbh.altnames %}
- <b> Alternate names:<nbsp></b>
- {{object.get_rendered_nbh.altnames}} <br/>
- {% endif %}
- {% if object.get_rendered_nbh.type_of %}
- <b> Type of:<nbsp></b>
- {% for typekey,typevalue in object.get_rendered_nbh.type_of.items %}
- <a href="{{typevalue}}" title = "{{typekey}}">{{typekey}}</a>;
- {% endfor %}<br/>
- {% endif %}
+<!-- {% if object.get_rendered_nbh.plural %} -->
+<!-- <b> Plural Name:<nbsp></b> -->
+<!-- {{object.get_rendered_nbh.plural}} <br/> -->
+<!-- {% endif %} -->
+<!-- {% if object.get_rendered_nbh.altnames %} -->
+<!-- <b> Alternate names:<nbsp></b> -->
+<!-- {{object.get_rendered_nbh.altnames}} <br/> -->
+<!-- {% endif %} -->
+<!-- {% if object.get_rendered_nbh.type_of %} -->
+<!-- <b> Type of:<nbsp></b> -->
+<!-- {% for typekey,typevalue in object.get_rendered_nbh.type_of.items %} -->
+<!-- <a href="{{typevalue}}" title = "{{typekey}}">{{typekey}}</a>; -->
+<!-- {% endfor %}<br/> -->
+<!-- {% endif %} -->
-<!-- Member of metatypes -->
- {% if object.get_rendered_nbh.member_of_metatypes %}
+<!-- <\!-- Member of metatypes -\-> -->
+<!-- {% if object.get_rendered_nbh.member_of_metatypes %} -->
- <b> Member of Metatypes:<nbsp></b>
- {% for mkey,mvalue in object.get_rendered_nbh.member_of_metatypes.items %}
- <a href="{{mvalue}}" title = "{{mkey}}">{{mkey}}</a>;
- {% endfor %}<br/>
- {% endif %}
+<!-- <b> Member of Metatypes:<nbsp></b> -->
+<!-- {% for mkey,mvalue in object.get_rendered_nbh.member_of_metatypes.items %} -->
+<!-- <a href="{{mvalue}}" title = "{{mkey}}">{{mkey}}</a>; -->
+<!-- {% endfor %}<br/> -->
+<!-- {% endif %} -->
-<!-- Subtypes -->
- {% if object.get_rendered_nbh.contains_subtypes %}
- <b> Contains SubTypes:<nbsp></b>
- {% for stkey,stvalue in object.get_rendered_nbh.contains_subtypes.items %}
- <a href="{{stvalue}}" title = "{{stkey}}">{{stkey}}</a>;
- {% endfor %}<br/>
- {% endif %}
+<!-- <\!-- Subtypes -\-> -->
+<!-- {% if object.get_rendered_nbh.contains_subtypes %} -->
+<!-- <b> Contains SubTypes:<nbsp></b> -->
+<!-- {% for stkey,stvalue in object.get_rendered_nbh.contains_subtypes.items %} -->
+<!-- <a href="{{stvalue}}" title = "{{stkey}}">{{stkey}}</a>; -->
+<!-- {% endfor %}<br/> -->
+<!-- {% endif %} -->
-<!-- Members -->
- {% if object.get_rendered_nbh.contains_members %}
+<!-- <\!-- Members -\-> -->
+<!-- {% if object.get_rendered_nbh.contains_members %} -->
- <b>Contains Members:<nbsp></b>
- {% for mkey,mvalue in object.get_rendered_nbh.contains_members.items %}
- <a href="{{mvalue}}" title = "{{mkey}}">{{mkey}}</a>;
- {% endfor %}<br/>
- {% endif %}
+<!-- <b>Contains Members:<nbsp></b> -->
+<!-- {% for mkey,mvalue in object.get_rendered_nbh.contains_members.items %} -->
+<!-- <a href="{{mvalue}}" title = "{{mkey}}">{{mkey}}</a>; -->
+<!-- {% endfor %}<br/> -->
+<!-- {% endif %} -->
-<!-- Authors -->
- {% if object.get_rendered_nbh.authors %}
+<!-- <\!-- Authors -\-> -->
+<!-- {% if object.get_rendered_nbh.authors %} -->
- <b>Authors: <nbsp> </b>
+<!-- <b>Authors: <nbsp> </b> -->
- {% endif %}
+<!-- {% endif %} -->
- {% for author in object.authors.all %}
- <span class="vcard author">
- <a href="{% url gstudio_author_detail author %}" class="fn nickname url" rel="author"
- title="{% blocktrans with author as author %}Show {{ author }} nodetypes{% endblocktrans %}">{{ author }}</a>
- </span>{% if not forloop.last %}, {% endif %}
- {% endfor %} <br/>
+<!-- {% for author in object.authors.all %} -->
+<!-- <span class="vcard author"> -->
+<!-- <a href="{% url gstudio_author_detail author %}" class="fn nickname url" rel="author" -->
+<!-- title="{% blocktrans with author as author %}Show {{ author }} nodetypes{% endblocktrans %}">{{ author }}</a> -->
+<!-- </span>{% if not forloop.last %}, {% endif %} -->
+<!-- {% endfor %} <br/> -->
-<!-- Prior nodes -->
+<!-- <\!-- Prior nodes -\-> -->
- {% if object.get_rendered_nbh.priornodes %}
+<!-- {% if object.get_rendered_nbh.priornodes %} -->
- <b>Prior nodes:<nbsp></b>
- {% for mkey,mvalue in object.get_rendered_nbh.priornodes.items %}
- <a href="{{mvalue}}" title = "{{mkey}}">{{mkey}}</a>;
- {% endfor %}<br/>
- {% endif %}
-<!-- Posterior nodes -->
- {% if object.get_rendered_nbh.posteriornodes %}
+<!-- <b>Prior nodes:<nbsp></b> -->
+<!-- {% for mkey,mvalue in object.get_rendered_nbh.priornodes.items %} -->
+<!-- <a href="{{mvalue}}" title = "{{mkey}}">{{mkey}}</a>; -->
+<!-- {% endfor %}<br/> -->
+<!-- {% endif %} -->
+<!-- <\!-- Posterior nodes -\-> -->
+<!-- {% if object.get_rendered_nbh.posteriornodes %} -->
- <b>Posterior nodes:<nbsp></b>
- {% for mkey,mvalue in object.get_rendered_nbh.posteriornodes.items %}
- <a href="{{mvalue}}" title = "{{mkey}}">{{mkey}}</a>;
- {% endfor %}<br/>
- {% endif %}
-<!-- Relations -->
- {% if object.get_rendered_nbh.relations %}
+<!-- <b>Posterior nodes:<nbsp></b> -->
+<!-- {% for mkey,mvalue in object.get_rendered_nbh.posteriornodes.items %} -->
+<!-- <a href="{{mvalue}}" title = "{{mkey}}">{{mkey}}</a>; -->
+<!-- {% endfor %}<br/> -->
+<!-- {% endif %} -->
+<!-- <\!-- Relations -\-> -->
+<!-- {% if object.get_rendered_nbh.relations %} -->
- {% for relkey,relvalue in object.get_rendered_nbh.relations.items %}
- <b>{{relkey}}:<nbsp></b>
- {% for relk, relv in relvalue.items %}
- <a href="{{relv}}" title = "{{relk}}">{{relk}}</a>;
- {% endfor %}<br/>
- {% endfor %}
- {% endif %}
-<!-- Attributes -->
- {% if object.get_rendered_nbh.attributes %}
+<!-- {% for relkey,relvalue in object.get_rendered_nbh.relations.items %} -->
+<!-- <b>{{relkey}}:<nbsp></b> -->
+<!-- {% for relk, relv in relvalue.items %} -->
+<!-- <a href="{{relv}}" title = "{{relk}}">{{relk}}</a>; -->
+<!-- {% endfor %}<br/> -->
+<!-- {% endfor %} -->
+<!-- {% endif %} -->
+<!-- <\!-- Attributes -\-> -->
+<!-- {% if object.get_rendered_nbh.attributes %} -->
- {% for atkey,atvalue in object.get_rendered_nbh.attributes.items %}
- {% if atvalue %}
- <b>{{atkey}}:<nbsp> </b>
- {% for atr in atvalue %}
+<!-- {% for atkey,atvalue in object.get_rendered_nbh.attributes.items %} -->
+<!-- {% if atvalue %} -->
+<!-- <b>{{atkey}}:<nbsp> </b> -->
+<!-- {% for atr in atvalue %} -->
- {% for urlkey,urlvalue in object.get_edit_url_for_ats.items %}
+<!-- {% for urlkey,urlvalue in object.get_edit_url_for_ats.items %} -->
- {% ifequal atr urlvalue %}
- {{atr}}<a href="{{ urlkey}}" title = "edit">[edit]</a> ;
- {% endifequal %}
- {% endfor %}
- {% endfor %} <br/>
- {% endif %}
- {% endfor %}
- {% endif %}
-<!-- Left roles -->
- {% if object.get_rendered_nbh.leftroles %}
+<!-- {% ifequal atr urlvalue %} -->
+<!-- {{atr}}<a href="{{ urlkey}}" title = "edit">[edit]</a> ; -->
+<!-- {% endifequal %} -->
+<!-- {% endfor %} -->
+<!-- {% endfor %} <br/> -->
+<!-- {% endif %} -->
+<!-- {% endfor %} -->
+<!-- {% endif %} -->
+<!-- <\!-- Left roles -\-> -->
+<!-- {% if object.get_rendered_nbh.leftroles %} -->
- <b>Left roles:<nbsp> </b>
+<!-- <b>Left roles:<nbsp> </b> -->
- {% for lrkey,lrvalue in object.get_rendered_nbh.leftroles.items %}
- <a href="{{lrvalue}}" title = "{{lrkey}}">{{lrkey}}</a>;
- {% endfor %} <br/>
- {% endif %}
-<!-- Right roles -->
- {% if object.get_rendered_nbh.rightroles %}
+<!-- {% for lrkey,lrvalue in object.get_rendered_nbh.leftroles.items %} -->
+<!-- <a href="{{lrvalue}}" title = "{{lrkey}}">{{lrkey}}</a>; -->
+<!-- {% endfor %} <br/> -->
+<!-- {% endif %} -->
+<!-- <\!-- Right roles -\-> -->
+<!-- {% if object.get_rendered_nbh.rightroles %} -->
- <b>Right roles:<nbsp> </b>
+<!-- <b>Right roles:<nbsp> </b> -->
- {% for rrkey,rrvalue in object.get_rendered_nbh.rightroles.items %}
- <a href="{{rrvalue}}" title = "{{rrkey}}">{{rrkey}}</a>;
- {% endfor %} <br/>
- {% endif %}
-<!-- Attributes -->
+<!-- {% for rrkey,rrvalue in object.get_rendered_nbh.rightroles.items %} -->
+<!-- <a href="{{rrvalue}}" title = "{{rrkey}}">{{rrkey}}</a>; -->
+<!-- {% endfor %} <br/> -->
+<!-- {% endif %} -->
+<!-- <\!-- Attributes -\-> -->
- {% if object.get_rendered_nbh.ats %}
+<!-- {% if object.get_rendered_nbh.ats %} -->
- <b>Subjecttype of:<nbsp> </b>
+<!-- <b>Subjecttype of:<nbsp> </b> -->
- {% for atkey,atvalue in object.get_rendered_nbh.ats.items %}
- <a href="{{atvalue}}" title = "{{atkey}}">{{atkey}}</a>;
- {% endfor %} <br/>
- {% endif %}
+<!-- {% for atkey,atvalue in object.get_rendered_nbh.ats.items %} -->
+<!-- <a href="{{atvalue}}" title = "{{atkey}}">{{atkey}}</a>; -->
+<!-- {% endfor %} <br/> -->
+<!-- {% endif %} -->
-<!-- Content -->
+<!-- <\!-- Content -\-> -->
{% if object.content %}
<b>
Content:<nbsp>
diff --git a/gstudio/templatetags/gstudio_tags.py b/gstudio/templatetags/gstudio_tags.py
index 5c3c8a8..66b5f17 100644
--- a/gstudio/templatetags/gstudio_tags.py
+++ b/gstudio/templatetags/gstudio_tags.py
@@ -23,7 +23,7 @@ from datetime import datetime
from django.db.models import Q
from django.db import connection
-from django.template import Node
+from django.template import Node as nd
from django.template import Library
from django.template import TemplateSyntaxError
from django.contrib.comments.models import CommentFlag
@@ -46,6 +46,8 @@ from gstudio.comparison import pearson_score
from gstudio.templatetags.zcalendar import GstudioCalendar
from gstudio.templatetags.zbreadcrumbs import retrieve_breadcrumbs
+from gstudio.CNL import *
+
register = Library()
VECTORS = None
@@ -217,8 +219,16 @@ def get_calendar_nodetypes(context, year=None, month=None,
def get_recent_comments(number=5, template='gstudio/tags/recent_comments.html'):
"""Return the most recent comments"""
# Using map(smart_unicode... fix bug related to issue #8554
-
- comments = get_comment_model().objects.filter(is_public=True).order_by('-submit_date')[:number]
+ #Modified comments to include CNL
+ nodetype_published_pks = map(smart_unicode,
+ Nodetype.published.values_list('id', flat=True))
+ content_type = ContentType.objects.get_for_model(Nodetype)
+
+ comments = get_comment_model().objects.filter(
+ Q(flags=None) | Q(flags__flag=CommentFlag.MODERATOR_APPROVAL),
+ content_type=content_type, object_pk__in=nodetype_published_pks,
+ is_public=True).order_by('-submit_date')[:number]
+
return {'template': template,
'comments': comments}
@@ -330,15 +340,19 @@ def get_type(name):
return get_node(name)
-class TagsNode(Node):
+class TagsNode(nd):
def __init__(self, context_var):
self.context_var = context_var
-
def render(self, context):
context[self.context_var] = tags_published()
return ''
-
-
+#define get_CNL function
+@register.assignment_tag
+def get_CNL(no, takes_context = True):
+
+ l = get_CNL_list(no)
+ return l
+
@register.tag
def get_tags(parser, token):
"""{% get_tags as var %}"""
diff --git a/gstudio/update_lexicon.py b/gstudio/update_lexicon.py
new file mode 100644
index 0000000..8a4a359
--- /dev/null
+++ b/gstudio/update_lexicon.py
@@ -0,0 +1,100 @@
+from gstudio.lex import *
+
+def lex(self):
+ destination = open( "/home/user/gnowsys-studio/demo/aFile.pl", "a+" )
+ f = destination.read()
+ ##print "f---" ,f
+ b = []
+ c = []
+ r = []
+ source_r = []
+ """
+ strpos=f.find("one")
+ ##print strpos
+ """
+
+ #Updates lexicon file with each Objecttype as noun singular and plural
+ for each in Objecttype.objects.all():
+ source=get_lex_OT(each)
+ for e_i in source:
+ strpos=f.find(e_i)
+ #print strpos
+ if strpos == -1:
+ #print "Going to write --", e_i
+ destination.write(str(e_i) + '\n')
+ else:
+ pass
+
+ #Updates lexicon file with Gbobject and author of each Nodetype and stores them as Proper noun
+ for each in Nodetype.objects.all():
+ for a in get_lex_author(each):
+ b.append(a)
+
+
+ for each in Gbobject.objects.all():
+ for a in get_lex_GB(each):
+ b.append(a)
+
+
+ #Compares each of the entries of author & Gbobject, to make a unique list
+ for each in b:
+ if each not in c:
+ c.append(each)
+
+ for e_i in c:
+ strpos=f.find(e_i)
+ #print strpos
+ if strpos == -1:
+ #print "Going to write --", e_i
+ destination.write(str(e_i) + '\n')
+ else:
+ pass
+
+ #Updates lexicon file with each Relationtype as an intransitive adjective or transitive verb
+ for each in Relationtype.objects.all():
+ for e_i in get_lex_RT(each):
+ r.append(e_i)
+ ##print " r---(will contain all rts, may contain repetition of prepositions)"
+
+ #Compares each of the entries to ensure preposition entries are unique
+ for each_r in r:
+ if each_r not in source_r:
+ source_r.append(each_r)
+
+ ###print "source_r, should not contain any rep"
+
+ for e_ir in source_r:
+ strpos=f.find(e_ir)
+ #print strpos
+ if strpos == -1:
+ ##print "Going to write the above statement",e_i
+ destination.write(str(e_ir) + '\n')
+ else:
+ pass
+
+ #Updates lexicon file with each Metatype as noun singular and plural
+ for each in Metatype.objects.all():
+ source_m=get_lex_MT(each)
+ for e_im in source_m:
+ strpos=f.find(e_im)
+ #print strpos
+ if strpos == -1:
+ ##print "Going to write the above statement",e_i
+ destination.write(str(e_im) + '\n')
+ else:
+ pass
+
+ #Updates lexicon file with each Attributetype as noun singular and plural
+ for each in Attributetype.objects.all():
+ source_a=get_lex_AT(each)
+ for e_ia in source_a:
+ strpos=f.find(e_ia)
+ #print strpos
+ if strpos == -1:
+ ##print "Going to write the above statement",e_i
+ destination.write(str(e_ia) + '\n')
+ else:
+ pass
+
+
+ destination.close()
diff --git a/gstudio/views/ajaxviews.py b/gstudio/views/ajaxviews.py
index 45064a1..e763020 100644
--- a/gstudio/views/ajaxviews.py
+++ b/gstudio/views/ajaxviews.py
@@ -352,7 +352,6 @@ def AjaxAddContentOrg(request):
def AjaxCreateFile(request):
iden = request.GET["id"]
- # newtitle = request.GET["title"]
orgcontent = request.GET["content_org"]
myfile = open('/tmp/file.org', 'w')
myfile.write(orgcontent)
@@ -361,18 +360,10 @@ def AjaxCreateFile(request):
myfile.readline()
myfile = open('/tmp/file.org', 'a')
myfile.write("\n#+OPTIONS: timestamp:nil author:nil creator:nil H:3 num:nil toc:nil @:t ::t |:t ^:t -:t f:t *:t <:t")
- myfile.write("\n#+TITLE:nil ")
+ myfile.write("\n#+TITLE: ")
myfile = open('/tmp/file.org', 'r')
-
-# os.remove("/tmp/file.org")
return HttpResponse("test sucess")
-# def AjaxSetOption(request):
-# myfile = open('/tmp/file.org', 'a')
-# myfile.write("\n#+OPTIONS: timestamp:nil author:nil creator:nil H:3 num:t toc:nil @:t ::t |:t ^:t -:t f:t *:t <:t")
-# myfile = open('/tmp/file.org', 'r')
-# return HttpResponse("set option")
-
def AjaxCreateHtml(request):
stdout = os.popen(PYSCRIPT_URL_GSTUDIO)
output = stdout.read()
diff --git a/objectapp/cnlgb.py b/objectapp/cnlgb.py
new file mode 100644
index 0000000..5c0382c
--- /dev/null
+++ b/objectapp/cnlgb.py
@@ -0,0 +1,633 @@
+from objectapp.models import *
+from gstudio.models import *
+from django.template.defaultfilters import slugify
+import inflect
+
+def get_cnlgb_list(self):
+ z = []
+ k = get_lex_sentence(self)
+ if not k:
+ pass
+ else:
+ z.extend(k)
+ l = get_lex_sentence_optional(self)
+ if not l:
+ pass
+ else:
+ z.extend(l)
+ m = get_CNL_dependency(self)
+ if not m:
+ pass
+ else:
+ z.extend(m)
+ n = membership_sentence(self)
+ if not n:
+ pass
+ else:
+ z.extend(n)
+ o = get_attr_sentence(self)
+ if not o:
+ pass
+ else:
+ z.extend(o)
+ rel = get_rel(self)
+ if not rel:
+ pass
+ else:
+ z.extend(rel)
+ return z
+
+def advanced_cnlgb(self):
+ zz=[]
+ p = get_CNL_sentence_authors(self)
+ if not p:
+ pass
+ else:
+ zz.extend(p)
+ """Generates CNL sentence for RT/R"""
+ rt = get_RT_sentence(self)
+ if not rt:
+ pass
+ else:
+ zz.extend(rt)
+ return zz
+
+
+def get_lex_sentence(self):
+ if not self.ref.__class__.__name__ is 'Gbobject':
+ pass
+ else:
+ cns=self.get_nbh
+ d=[]
+ for k in cns:
+ if k=='title':
+ title = str(cns['title'])
+ title_slug = slugify(title)
+ if not cns[k]:
+ pass
+ else:
+ g=str(title_slug)+" is a proper-noun."
+ d.append(g.capitalize())
+ return d
+
+
+def get_lex_sentence_optional(self):
+ if not self.ref.__class__.__name__ is 'Gbobject':
+ pass
+ else:
+ cns=self.get_nbh
+ title = str(cns['title'])
+ title_slug = slugify(title)
+ d=[]
+ for k in cns:
+ if k =='altnames':
+ alt_name = str(cns['altnames'])
+ alt_slug = slugify(alt_name)
+ if not cns[k]:
+ pass
+ else:
+ i=str(cns[k])+" is an alternate name for "+str(title_slug)+"."
+ d.append(i.capitalize())
+
+ elif k == 'plural':
+ if not cns[k]:
+ pass
+ else:
+ pl = str(cns[k])
+ pl_slug = slugify(pl)
+ m = str(pl_slug)+" is a plural of "+str(title_slug)+"."
+ d.append(m.capitalize())
+ return d
+
+
+
+def get_CNL_sentence_authors(self):
+ if not self.ref.__class__.__name__ is 'Gbobject':
+ pass
+ else:
+ title = self.title
+ title_slug = slugify(title)
+ d=[]
+ if self.authors.all():
+ auth = []
+ auth = self.authors.all()
+ len_auth=len(auth)
+ if len_auth == 1:
+ for each in auth:
+ aut=slugify(each)
+ e=str(aut).title()+" is an author to "+str(title_slug).title()+"."
+ d.append(e)
+
+ else:
+ ##print "len not 1"
+ y=[]
+ for each in self.authors.all():
+ a=each
+ a_slug=slugify(a)
+ y.append(a_slug)
+ for e_i in y:
+ if y.index(e_i) == 0:
+ sen = str(e_i)
+ else:
+ sen = str(sen)+" and "+str(e_i)
+
+ e = str(sen).title()+" are all chosen authors to "+str(title_slug).title()+"."
+ d.append(e)
+
+ return d
+
+
+def get_CNL_dependency(self):
+ if not self.ref.__class__.__name__ is 'Gbobject':
+ pass
+ else:
+ title = self.title
+ title_slug = slugify(title)
+ d=[]
+ if self.prior_nodes.all():
+ p_n_a = []
+ p_n_a = self.prior_nodes.all()
+ len_pna=len(p_n_a)
+ if len_pna == 1:
+ for each in p_n_a:
+ pn=slugify(each)
+ h=str(pn).title()+" is a prior_node for "+str(title_slug).title()+"."+str(title_slug).title()+" depends upon "+str(pn).title()+"."
+ d.append(h)
+ else:
+ sen = dependency_plural(p_n_a)
+ h = str(sen)+". It is the prior_node and required for the meaning of "+str(title_slug).title()+"."
+ d.append(h)
+
+ if self.posterior_nodes.all():
+ p_n_a = []
+ p_n_a = self.posterior_nodes.all()
+ len_pna=len(p_n_a)
+ if len_pna == 1:
+ for each in p_n_a:
+ pn = slugify(each)
+ p = str(pn).title()+" is a posterior_node for "+str(title_slug).title()+"."+str(title_slug).title()+" is required for the meaning of "+str(pn).title()+"."
+ d.append(p)
+ else:
+ sen = dependency_plural(p_n_a)
+ p = str(sen)+". It is the posterior_node and depends on the meaning of "+str(title_slug).title()+"."
+ d.append(p)
+ return d
+
+#Generates dependency sentence for plural
+def dependency_plural(p_n_a):
+ for each in p_n_a:
+ a = each
+ each_r = each.ref.__class__.__name__
+
+ a_slug = slugify(a)
+ y=[]
+ for a_slug in p_n_a:
+ if len(y) == 0:
+ #print "If Y is empty, for first item"
+ if each_r == 'Relationtype':
+ b_slug = str(a_slug).title()+" is an adjective"
+ else:
+ b_slug = str(a_slug).title()+" is a proper-noun"
+ y.append(b_slug)
+ else:
+ if each_r != 'Relationtype':
+ #print "Its not a relation_type, but a proper-noun"
+ aa_slug = str(a_slug).title()+" is a proper-noun"
+ y.append(aa_slug)
+ else:
+ #print "It is a relationtype"
+ ab_slug = str(a_slug).title()+" is an adjective"
+ y.append(ab_slug)
+ for e_i in y:
+ if y.index(e_i) == 0:
+ sen = str(e_i)
+ else:
+ sen = str(sen)+" and "+str(e_i)
+ return sen
+
+
+
+def membership_sentence(self):
+ """Returns CNL sentences for membership"""
+ if not self.ref.__class__.__name__ is 'Gbobject':
+ pass
+ else:
+ cns=self.get_nbh
+ title = str(cns['title'])
+ title_slug = slugify(title)
+ d=[]
+ for k in cns:
+ if self.ref.__class__.__name__ is 'Gbobject':
+ if k=='member_of':
+ if not cns[k]:
+ pass
+ else:
+ cmm = []
+ cmm = self.objecttypes.all()
+ len_cmm=len(cmm)
+ if len_cmm == 1:
+ for each in cmm:
+ cm=slugify(each)
+ j=str(title_slug)+" is a member of a "+str(cm)+"."
+ d.append(j.capitalize())
+
+ else:
+ #print "len not 1"
+ y=[]
+ for each in self.objecttypes.all():
+ a=each
+ a_slug=slugify(a)
+ y.append(a_slug)
+ for e_i in y:
+ if y.index(e_i) == 0:
+ sen = str(e_i)
+ else:
+ sen = str(sen)+" and a "+str(e_i)
+
+ j= str(title_slug)+" is a member of a "+sen+"."
+ d.append(j.capitalize())
+
+ return d
+
+
+#Returns attributes for the given Gbobject
+def get_attr_sentence(self):
+ if not self.ref.__class__.__name__ is 'Gbobject':
+ pass
+ else:
+ at = Gbobject.get_attributes(self)
+ if at:
+ a = []
+ title = self.title
+ for k,v in at.iteritems():
+ attr = k
+ for each in v:
+ value = each
+ sen = "The "+str(attr)+" of "+str(title)+" is "+str(value)+"."
+ a.append(sen)
+ return a
+
+
+def get_list_relation(self, lr):
+ """Returns the list of relations"""
+ lst = []
+ gbr = self.get_relations1
+ if not gbr:
+ pass
+ else:
+ for k,v in gbr.iteritems():
+ if k == 'lrelations':
+ val_l = v
+ if k == 'rrelations':
+ val_r = v
+
+ if lr == 0:
+ return val_l
+ elif lr == 1:
+ return val_r
+
+
+def get_CNL_sentence_RT(self, lst, rst, detail_level):
+ if self.ref.__class__.__name__ is 'Relationtype':
+ core = [] #core data list
+ core_t = []
+ core_i = []
+ reflexive = []
+ adv = [] # advanced data list
+ title=self.title
+ title_slug=slugify(title)
+ inverse=self.inverse
+ inverse_slug=slugify(inverse)
+ is_symmetrical=self.is_symmetrical
+ is_reflexive=self.is_reflexive
+ llist = []
+ rlist = []
+ llist = lst
+ rlist = rst
+ #Flag variable that checks if plural-left,right
+ plural_l = 0
+ plural_r = 0
+ if isinstance(llist,list):
+ """If llist is a list"""
+ ll = []
+ for each in llist:
+ if each.ref.__class__.__name__ is not 'Gbobject':
+ """Common-noun"""
+ lst = "a "+str(each).lower()
+ else:
+ """Proper-noun"""
+ lst = str(each).title()
+ ll.append(lst)
+ if len(ll) == 1:
+ for e in ll:
+ left_subtype = e
+ else:
+ """Since left-ST is plural, flag value assigned 1 """
+ plural_l = 1
+ for e in ll:
+ if ll.index(e)==0:
+ sen = str(e)
+ else:
+ sen = str(sen)+" and "+str(e)
+ left_subtype = sen
+ else:
+ """If llist is not a list"""
+ if lst.ref.__class__.__name__ is 'Gbobject':
+ left_subtype = lst
+ else:
+ left_subtype = "a "+str(lst)
+
+ if isinstance(rlist,list):
+ """If rlist is a list"""
+ rl = []
+ #print "Is a list"
+ for each in rlist:
+ if each.ref.__class__.__name__ is not 'Gbobject':
+ """Common-noun"""
+ rst = "a "+str(each)
+ else:
+ rst = each
+ rl.append(rst)
+
+ if len(rl) == 1:
+ for e in rl:
+ right_subtype = e
+ else:
+ """Since right-ST is plural, flag value assigned 1 """
+ plural_r = 1
+ for e in rl:
+ if rl.index(e)==0:
+ sen = str(e)
+ else:
+ sen = str(sen)+" and "+str(e)
+ right_subtype = sen
+
+ else:
+ """If Rlist is not a list"""
+ if rst.ref.__class__.__name__ is 'Gbobject':
+ right_subtype = rst
+ else:
+ right_subtype = "a "+str(rst)
+
+ #Core sentence - title
+
+ rel = rel_CNL(self, left_subtype, right_subtype, plural_l)
+ core_t.extend(rel)
+
+ rlex = rel_lex_sentence(self)
+ adv.extend(rlex)
+
+ app_NT = get_app_NT(self)
+ adv.extend(app_NT)
+
+ st = get_RT_subjecttype(self, left_subtype, right_subtype)
+ adv.extend(st)
+
+ #Is symmetrical
+ if is_symmetrical:
+ symm = is_symmetrical_RT(self, left_subtype, right_subtype, plural_r)
+ core_i.extend(symm)
+ else:
+ asymm = is_asymmetrical_RT(self, left_subtype, right_subtype, plural_r)
+ core_i.extend(asymm)
+ #Is reflexive
+ if not is_reflexive:
+ pass
+ else:
+ if detail_level == 1 or plural_l == 1:
+ st = right_subtype
+ else:
+ st = left_subtype
+ is_refl = is_reflexive_sentence(self, st)
+ reflexive.extend(is_refl)
+
+ if detail_level==0:
+ #Title,Reflexive
+ for e in core_t:
+ a = e
+ reflexive.insert(0, a)
+ return reflexive
+ elif detail_level==1:
+ #Inverse,reflexive
+ for e in core_i:
+ a = e
+ reflexive.insert(0, a)
+ return reflexive
+ elif detail_level==2:
+ #Title, Inverse & Reflexive
+ core.extend(core_t)
+ core.extend(core_i)
+ core.extend(reflexive)
+ return core
+ elif detail_level==3:
+ #Return advanced grammatical information
+ return adv
+ elif detail_level==4:
+ #Return all info - Core & Advanced Info
+ newlist = []
+ newlist.extend(core)
+ newlist.extend(adv)
+ return newlist
+
+
+
+#Checks if RT-title is a transitive verb finite singular or an iterative adjective
+def istv_title(self):
+ p = inflect.engine()
+ from django.template.defaultfilters import slugify
+ destination = open( "/home/user/gnowsys-studio/demo/aFile.pl", "r+" )
+ f = destination.read()
+ a_t = self.title
+ a = slugify(a_t)
+ if '-' not in a:
+ if a[-1] == 's':
+ a_s = p.singular_noun(a)
+ a_lex = "tv_finsg("+a+", "+str(a_s)+")."
+ strpos = f.find(a_lex)
+ if strpos != -1:
+ return True
+ else:
+ return False
+
+#Checks if RT-inverse is a transitive verb finite singular or an iterative adjective
+def istv_inverse(self):
+ p = inflect.engine()
+ destination = open( "/home/user/gnowsys-studio/demo/aFile.pl", "r+" )
+ f = destination.read()
+ a_t = self.inverse
+ a = slugify(a_t)
+ if '-' not in a:
+ if a[-1] == 's':
+ a_s = p.singular_noun(a)
+ a_lex = "tv_finsg("+a+", "+str(a_s)+")."
+ strpos = f.find(a_lex)
+ if strpos != -1:
+ return True
+ else:
+ return False
+
+
+
+def rel_CNL(self, left_subtype, right_subtype, plural_l):
+ """To generate sentence for relation"""
+ title = self.title
+ title_slug = slugify(title)
+ if self.ref.__class__.__name__ is 'Relationtype':
+ rel = []
+ if istv_title(self):
+ st = str(left_subtype)+" "+str(title).lower()+" "+str(right_subtype)+"."
+ else:
+ if plural_l == 0:
+ st = str(left_subtype)+" is "+str(title).lower()+" "+str(right_subtype)+"."
+ elif plural_l == 1:
+ st = str(left_subtype)+" are "+str(title).lower()+" "+str(right_subtype)+"."
+ rel.append(st)
+ return rel
+
+
+def is_reflexive_sentence(self, st):
+ """Generates reflexive sentence"""
+ refl = []
+ title = self.title
+ title_slug = slugify(title)
+ if istv_title(self):
+ j= "It is a reflexive sentence. "+str(st).title()+" "+str(title)+" "+str(st)+"."
+ else:
+ j= "It is a reflexive sentence. "+str(st).title()+" is "+str(title)+" "+str(st)+"."
+ refl.append(j)
+ return refl
+
+def is_symmetrical_RT(self, left_subtype, right_subtype, plural_r):
+ """Generates CNL Sentence for Relation/RT if symmetrical"""
+ symm = []
+ title = self.title
+ title_slug = slugify(title)
+ #if (type_lst == 'Gbobject' and type_rst == 'Gbobject'):
+ if istv_title(self):
+ g = str(right_subtype).title()+" "+str(title)+" "+str(left_subtype).title()+"."
+ else:
+ if plural_r == 0:
+ g = str(right_subtype).title()+" is "+str(title)+" "+str(left_subtype).title()+"."
+ else:
+ g = str(right_subtype).title()+" are "+str(title)+" "+str(left_subtype).title()+"."
+ symm.append(g)
+ return symm
+
+def is_asymmetrical_RT(self, left_subtype, right_subtype, plural_r):
+ """Generates CNL Sentence for Relation/RT if symmetrical"""
+ asymm = []
+ inverse = self.inverse
+ inverse_slug = slugify(inverse)
+ if istv_inverse(self):
+ g = str(right_subtype).title()+" "+str(inverse)+" "+str(left_subtype).title()+"."
+ else:
+ if plural_r == 0:
+ g = str(right_subtype).title()+" is "+str(inverse)+" "+str(left_subtype).title()+"."
+ elif plural_r == 1:
+ g = str(right_subtype).title()+" is "+str(inverse)+" "+str(left_subtype).title()+"."
+ asymm.append(g)
+ return asymm
+
+
+def rel_lex_sentence(self):
+ """Generates RT's title & inverse sentence"""
+ if self.ref.__class__.__name__ is 'Relationtype':
+ rlex = []
+ title=self.title
+ title_slug=slugify(title)
+ inverse=self.inverse
+ inverse_slug=slugify(inverse)
+ h="A relation_type's title is "+str(title_slug)+"."
+ rlex.append(h.capitalize())
+
+ if (title==inverse):
+ b="Its title and its inverse are equal."
+ else:
+ b="Its inverse is "+str(inverse_slug)+"."
+ rlex.append(b.capitalize())
+ return rlex
+
+
+def get_app_NT(self):
+ """Generates CNL Sentences for left & right applicable NT for RT"""
+ if self.ref.__class__.__name__ is 'Relationtype':
+ a = []
+ l_app = self.left_applicable_nodetypes
+ r_app=self.right_applicable_nodetypes
+ e = "Its left_applicable_nodetype is "+str(l_app).upper()+"."
+ a.append(e)
+
+ f = "Its right_applicable_nodetype is "+str(r_app).upper()+"."
+ a.append(f)
+ return a
+
+
+
+def get_RT_sentence(self):
+ #Generates CNL Sentences in RT in detail
+ if self.ref.__class__.__name__ is 'Relationtype':
+ sentence = get_CNL_sentence_RT(self, self.left_subjecttype, self.right_subjecttype, 4)
+ return sentence
+
+ #Generates CNL sentences in Relation in detail
+ elif self.ref.__class__.__name__ is 'Relation':
+ sentence = get_CNL_sentence_RT(self.relationtype, self.left_subject, self.right_subject, 4)
+ return sentence
+
+
+
+
+#Get relations for the Gbobject:Singular, plural
+def get_rel(self):
+ sen = []
+ sentence = []
+ lr = Relation.objects.filter(left_subject = self.id)
+ rr = Relation.objects.filter(right_subject = self.id)
+
+
+ if lr:
+ """List which stores each right subject"""
+ lst = get_list_relation(self, 0)
+
+ for k,v in lst.iteritems():
+ rel = Relationtype.objects.filter(title = k)
+ val = v
+ for rt in rel:
+ sen = get_CNL_sentence_RT(rt, self, val, 0)
+ sentence.extend(sen)
+
+ if rr:
+ """List which stores each left subject"""
+ lst = get_list_relation(self, 1)
+
+ for k,v in lst.iteritems():
+ rel = Relationtype.objects.filter(inverse = k)
+ val = v
+ for rt in rel:
+ sen = get_CNL_sentence_RT(rt, val, self,1)
+ sentence.extend(sen)
+ return sentence
+
+
+
+def get_RT_subjecttype(self, left_subtype, right_subtype):
+ """Returns CNL sentence of left & right subject type of RT"""
+ if self.ref.__class__.__name__ is 'Relationtype':
+ st = []
+ ce = "Its left_subjecttype is "+str(left_subtype)+"."
+ c = ce.capitalize()
+ st.append(c)
+
+ de = "Its right_subjecttype is "+str(right_subtype)+"."
+ d = de.capitalize()
+ st.append(d)
+ return st
+ else:
+ pass
+
+
+
+
+
+
+
diff --git a/objectapp/templates/objectapp/skeleton.html b/objectapp/templates/objectapp/skeleton.html
index 76cd820..4da343e 100644
--- a/objectapp/templates/objectapp/skeleton.html
+++ b/objectapp/templates/objectapp/skeleton.html
@@ -359,8 +359,9 @@
{% endblock %}
</div>
<div id="graphcss">
- <div id="gnoweditor">
- </div>
+ <textarea id="gnoweditor" style="visibility:hidden;">
+ </textarea>
+
<div id="chart">
diff --git a/objectapp/views/ajaxviews.py b/objectapp/views/ajaxviews.py
index ba701a4..6d6e63e 100644
--- a/objectapp/views/ajaxviews.py
+++ b/objectapp/views/ajaxviews.py
@@ -44,6 +44,7 @@ def AjaxCreateFile(request):
myfile.readline()
myfile = open('/tmp/file.org', 'a')
myfile.write("\n#+OPTIONS: timestamp:nil author:nil creator:nil H:3 num:t toc:nil @:t ::t |:t ^:t -:t f:t *:t <:t")
+ myfile.write("\n#+TITLE: ")
myfile = open('/tmp/file.org', 'r')
return HttpResponse("test sucess")