pysumo and pySUMOQt

Introduction

Welcome to pySUMOs documentation. We hope you will find any information you need to use or develop pySUMO. If you have any questions after reading this, feel free to contact us via email at pysumo@lists.kit.edu.

First, a short excursion to the “Model View Controller” design pattern is made.

Subsequently, our Class Diagram, which is structured according to the Model View Controller (MVC) design.

Afterwards, several sequence diagrams which show a timeline of typical actions are presented.

Furthermore, there are a couple of activity diagrams showcasing both a casual pySUMO workflow as well as what pySUMO does in the background to support your workflow.

Thereafter the individual classes are introduced in more detail. This is followed up by a list of errors that pySUMO can throw and a list of external libraries used to develop pySUMO.

Structure

graph {
rankdir=LT;

subgraph clusterView {
	label="View";
	MainWindow -- Widgets
	MainWindow -- Toolbar
	MainWindow -- Status
	MainWindow -- Menu
	Menu -- Update
	RWidget -- Hierarchie
	Widgets -- RWidget
	Widgets -- RWWidget
	RWWidget -- "Graph"	
	RWWidget -- Text
	RWidget -- Documentation 
	Menu -- OptionDialog
	OptionDialog -- HelpDialog
	OptionDialog -- PluginManager
	OptionDialog -- Shortcuts
	Text -- CodeC
	Text -- Syntax;
}
subgraph clusterController {
	node [style=filled];
	color=blue;
	label="Controller";
	SyntaxController -- IndexAbstractor
	SyntaxController -- Logger
	IndexAbstractor -- Logger;
	V1[style=invis];
	V2[style=invis];
	IndexAbstractor -- V1 -- V2[style=invis];
	IndexAbstractor --WordNet --V4[style=invis];
}
subgraph clusterModel {
	label="Model";
	Parser -- Lexer
	Parser -- AST
	AST -- Index
	Lexer -- Serialize
	Parser -- KIF
	KIF -- Updater
	KIF -- Serialize;
	V3[style=invis];
	V4[style=invis];
	Index--V3--V4[style=invis];
}
edge[constraint=false,style=dotted];
Widgets -- IndexAbstractor
"Graph" -- IndexAbstractor
RWWidget -- SyntaxController
Status -- Logger
SyntaxController -- Parser
SyntaxController -- Serialize
IndexAbstractor -- AST
IndexAbstractor -- WordNet
IndexAbstractor -- Index;

SyntaxController[label="SyntaxController"]
IndexAbstractor[label="IndexAbstractor"]
KIF[label="KIF"]
AST[label="AST"]
Parser[label="Parser"]
Text[label="Text"]
"Graph"[label="Graph"]
Updater[label="Updater"]
Documentation[label="Documentation"]
Hierarchie[label="Hierarchie"]
MainWindow[label="MainWindow"]
Widgets[label="Widgets"]
Status[label="Status"]
OptionDialog[label="OptionDialog"]
WordNet[label="WordNet"]
Logger[label="Logger"]
HelpDialog[label="HelpDialog"]
}

The program is structured around the MVC-architecture. The partitioning into Model, View and Controller makes modification of Program code easier and also allows the lib to be used independently of the GUI.

For more information see

Model

The model contains both the Parser and the Abstract Syntax Tree (AST) generated by the Parser.
The AST stores the Ontology in memory and allows modifications thereof.
The Parser provides both a kif-parser and serializer as well as a parser for the SUMO-WordNet mapping.

Controller

The controller contains all base functionality of the program. It mediates all accesses to the AST, creates and maintains an index and handles interactions with WordNet. The controller also handles all other core functionality of pySUMO such as undo and redo.

View

The view consists of all the graphical elements of pySUMO including, but not limited to the Qt GUI.

UML Diagrams:

Sequence diagram

Adding graph node

!include ./UML/graph_node_add.iuml

This diagram displays how the GraphWidget responds to user input and adds new nodes to the Ontology. Note that all operations that might change the Ontology pass through the SyntaxController and all operations that read from the loaded Ontologies pass through the IndexAbstractor.

Searching in the index

!include ./UML/search.iuml

This diagram displays a simple abstraction of how the DocumentationWidget responds to a user search request. Note that it does not include any IndexAbstractor internal operations such as building and maintaining the Index.

Activity diagram

Graph widget input loop

!include ./UML/graphactivity.iuml

This diagram displays the activity diagram used by the GraphWidget when a user adds a node to the graph. Of special note is that the parsing of the new graph is done in the background so that the user can still interact with the GraphWidget while it is updating the Ontology.

Text editor input loop

!include ./UML/textactivity.iuml

This diagram displays the activity diagram used by the TextWidget while the user is typing. Once the user pauses typing, the text editor checks whether the parenthetical syntax is correct, and if it passes a simple syntax check, the text is passed to the parser. The parser then checks syntax and semantics and returns accordingly. If errors occur during parsing, they are displayed in the editor.

Common workflow

!include ./UML/activity_1.iuml

This diagram displays an abstract view of a common User-interaction with the program. The user starts the program adds a .kif-File, searches in WordNet and finally adds a relation through the GraphWidget. PySUMO automatically converts the relation to kif and appends it to the ontology source.

Exit process

!include ./UML/activity_2.iuml

This diagram displays an abstract view of the activity diagram when a user wants to exit the program. This is done when the user clicks on the close icon in the title bar of the main window of pySUMO or on ‘Exit’ in the menu ‘File’. The program makes sure that there are no unsaved changes in open ontologies and if there are changes, prompts if they should be saved. If the user doesn’t save them, the modifications will be lost. Note that the program also saves session layouting preferences of the GUI so they can be restored in the next pySUMO session. These preferences include, for example, the position of widgets in the main window.

Overview: Class Diagram of pySUMO

!include ./UML/main.pu

Detail: Modules

pysumo package

This section describes the backing pysumorary of pySUMO. It contains listings and descriptions of all the modules and classes in the pySUMO core. The pysumo conforms to PEP 008.

!include ./UML/pysumo/package_pysumo.iuml

Module contents

The pySUMO library package. This package contains the core functionality of pySUMO. It not only provides the GUI with a feature-rich API, but also validates input and keeps the Ontologies in a consistent state.

Subpackages

pysumo.logger package

Module contents

The pySUMO logging interface.

This package contains 2 modules:

  • infolog: A singleton called from the entry point to initialize the python logging framework and set the loglevel.
  • actionlog: Stores a list of all write operations on the Ontology and provides undo and redo functionality.
Submodules
pysumo.logger.actionlog module

!include ./UML/pysumo/logger/Actionlog.iuml


The pySUMO action log handler. This module handles undo and redo operations.

This module contains:

  • ActionLog: The action log handler.
  • LogIO: The action log io interface.
class pysumo.logger.actionlog.ActionLog(name, path=None)[source]

Bases: builtins.object

The pySUMO action log. The SyntaxController queues a new log entry before every operation that makes changes to an Ontology, if the change is successful it OKs the entry in the log queue and the entry is written out. Log entries that are not OKed time out and are removed from the queue.

Variables:

  • log_io: The io object for this log.
  • queue: A queue of actions that have not yet successfully completed.
  • actionlog: A list of actions that have completed successfully.
  • redolog: A list of actions that have been undone successfully.
  • current: The current state of the Ontology.

Methods:

  • queue_log: Create a log entry and append it to the log queue.
  • ok_log_item: Move log entry from log queue to actual log.
  • undo: Undoes the last action.
  • redo: Redoes the last undone action.
ok_log_item(log_queue_ok_num)[source]

Appends the item in self.queue with log_queue_ok_num to self.actionlog and calls self.log_io.append_write_queue on it.

Args:

  • log_queue_ok_num: the number of the queue item to okay

Raises:

  • KeyError
queue_log(data)[source]

Create a log entry and queue it for addition to self.actionlog.

Args:

  • data: the data to be placed in the log

Returns:

  • int. The log_queue_ok_num
redo()[source]

Redoes the last undone action, appends it to self.undolog and removes it from self.redolog.

undo()[source]

Undoes the last action and appends it to self.redolog.

class pysumo.logger.actionlog.LogIO(name, path='/home/docs/.pysumo/actionlog')[source]

Bases: builtins.object

The IO interface for the pySUMO action log. This class provides a storage backend for the Action Log. Entries in the write queue are written to disk after a timeout, or when the write queue reaches a maximum size.

Variables:

  • default_path: The default log path.
  • timeout: The time period after which if no new packets have entered the queue, the queue is flushed.
  • max_size: The maximum number of actions in the write queue after which when another packet enters the queue, the queue is flushed.
  • max_diffs: When the number of stored diffs exceeds max_diffs, old diffs will be deleted.
  • path: The log path (defaults to default_path).
  • name: The name of the Ontology.
  • current: The path to the current state of the Ontology.
  • uwrite_queue: The queue in which undo actions are stored before being written to disk.
  • rwrite_queue: The queue in which redo actions are stored before being written to disk.

Methods:

  • diff: Creates a diff between 2 Files
  • read: Instantiates an Action Log with the data in the stored log at path.
  • flush_write_queues: Appends all entries in the write queue to the log file.
  • clear: Clears a queue in memory and on disk.
  • pop: Removes the last entry from a queue.
  • undo: Appends an entry to the redo write queue.
  • redo: Appends an entry to the undo write queue.
clear(queue)[source]

Clears queue both in memory and on disk.

default_path = '/home/docs/.pysumo/actionlog'
diff(current, new)[source]

Returns a diff between current and new.

flush_write_queues(_=None, __=None)[source]

Flush self.rwrite_queue and self.uwrite_queue to disk.

max_diffs = 100
max_size = 10
pop(queue)[source]

Removes the last entry in queue.

read()[source]

Reads the log at self.path into log.

redo(current, entry, clean=False)[source]

Append entry to self.uwrite_queue. If clean is True, pop an object from the redo queue.

timeout = 10
undo(current, entry)[source]

Append entry to self.rwrite_queue.

pysumo.logger.infolog module

!include ./UML/pysumo/logger/InfoLog.iuml


The pySUMO informational log handler. Acts as an initializer for the python logging framework and defines several convenience functions for working with it.

This module contains:

  • InfoLog: The informational log handler.
class pysumo.logger.infolog.InfoLog(loglevel='WARNING', filename='/home/docs/.pysumo/log', socket_path='/home/docs/.pysumo/status')[source]

Bases: builtins.object

The informational log handler for pySUMO. Initializes the python logging framework and contains several convenience functions. Instantiated only from the entry point.

Variables:

  • default_log_path: The default path where the infolog will be stored.
  • default_socket_path: The default socket to which >=INFO logs will be sent.
  • filename: The location at which the infolog will be stored.
  • root_logger: The root logging object of which all other loggers are children.
  • f_handler: Sends messages to a file and rotates it when it becomes too large.
  • s_handler: Sends messages to a Unix socket.

Methods:

  • set_loglevel: Sets the loglevel above which to log messages.
default_log_path = '/home/docs/.pysumo/log'
default_socket_path = '/home/docs/.pysumo/status'
set_loglevel(loglevel)[source]

Sets the loglevel above which to log messages.

Submodules

pysumo.indexabstractor module

!include ./UML/pysumo/IndexAbstractor.iuml


This module abstracts all operations on the Ontology index. It is used for every read operation on the Ontology. It eases access to the Ontology and protects the data structures from direct user access.

This module contains:

  • IndexAbstractor: The interface to the Ontology index.
  • AbstractGraph: An object containing selected graph nodes and relations.
  • AbstractGraphNode: A node in a AbstractGraph
  • DotGraph: A Graphical representation of an AbstractGraph with DOT
class pysumo.indexabstractor.AbstractGraph(variant, major, minor, root, depth, info)[source]

Bases: builtins.object

An abstract representation of a subset of an Ontology as a collection of nodes and relations.

Variables:

  • nodes: The list of graph nodes.
  • relations: An adjacency matrix of all the paths in the graph.
class pysumo.indexabstractor.AbstractGraphNode(name)[source]

Bases: builtins.object

A node in an AbstractGraph. Contains information necessary to recreate an AbstractSyntaxTree from an AbstractGraph.

Varibles:

  • name: The name of the AbstractGraphNode.
class pysumo.indexabstractor.IndexAbstractor[source]

Bases: builtins.object

The IndexAbstractor provides a high-level index of the AbstractSyntaxTree. Each Ontology is represented by a hashmap, the list of these hashmaps is the index. Average access time is in O(n) where n is the number of loaded Ontologies.

Variables:

  • root: The root AbstractSyntaxTree node.
  • ontologies: The list of currently active Ontologies.
  • index: The index of all terms in the currently active Ontologies.
  • wordnet: A reference to the Object containing the SUMO-WordNet mapping.

Methods:

  • init_wordnet: Initializes the WordNet mapping.
  • update_index: Updates the index.
  • search: Searches for a term in the Ontology.
  • get_ontology_file: Return an in-memory file object for an Ontology.
  • get_completions: Return a list of possible completions for the current index.
  • get_graph: Creates an abstract graph containing a view of the Ontology.
  • wordnet_locate: Returns information about a term from WordNet.
get_completions()[source]

Returns a list of possible completions for the currently loaded ontologies.

get_graph(variant, major=2, minor=1, root=None, depth=None)[source]

Returns a hierarchical view of the Ontology.

Arguments:

  • variant: The list of terms against which the resulting AbstractGraph matches.
  • major: The position of the parent element.
  • minor: The position of the child element.
  • root: The root node to which all other nodes are related.
  • depth: The recursion depth.

Returns:

  • AbstractGraph

Raises:

  • KeyError
get_ontology_file(ontology)[source]

Returns an in-memory file object for the Kif representation of ontology.

init_wordnet()[source]

Initializes the SUMO mapping to WordNet.

search(term)[source]

Search for term in the in-memory Ontology. Returns all objects that match the search.

Returns:

  • {Ontology : (String, int)[]}
update_index(ast)[source]

Updates the index with all new AST nodes in ast.

wordnet_locate(term)[source]

Use the mapping from SUMO to WordNet to retrieve information about a term.

Arguments:

  • term: the term to locate

Returns:

  • String[]

Raises:

  • KeyError
pysumo.indexabstractor.normalize(term)[source]

Normalizes term to aid in searching.

pysumo.wordnet module

!include ./UML/pysumo/WordNet.iuml


The interface to WordNet.

This module contains:

  • WordNet: An interface to the WordNet online English lexical database.
class pysumo.wordnet.WordNet[source]

Bases: builtins.object

An interface to locate and search for items in WordNet. Searches WordNet for information about terms in the Ontology, to find colloquial variations of term names and to find terms that are synonyms of a word.

Methods:

  • locate_term: Locates a term in WordNet.
  • find_synonym: Finds possibly synonyms for a word.
find_synonym(word)[source]

Searches WordNet for possible synonyms for word.

Returns:

  • String[]
locate_term(term)[source]

Use the mapping from SUMO to WordNet to retrieve information about a term.

Kwargs:

  • term: the term to locate

Returns:

  • (name : String, type : SSType, gloss : String)[]

pysumo.parser module

!include ./UML/pysumo/Parser.iuml


The pySUMO parsing module. It contains functions to parse and serialize kif-files. It also handles the Ontology’s data structure and parses the mapping of SUMO terms to WordNet.

This module contains:

  • AbstractSyntaxTree: The in-memory representation of an Ontology.
  • Ontology: Contains basic information about an Ontology.
class pysumo.parser.AbstractSyntaxTree(ontology, parent=None, line=-1)[source]

Bases: builtins.object

The AbstractSyntaxTree is a node in the abstract syntax tree. The abstract syntax tree is defined by a root node and its children. The AbstractSyntaxTree is the in-memory representation of the loaded Ontologies for internal purposes only and should never be passed outside of the lib.

Variables:

  • parent: The parent node
  • children: A list of child nodes.
  • name: The name of the AbstractSyntaxTree object.
  • element_type: The type of the node element.
  • ontology: The Ontology object to which this node corresponds.
  • is_indexed: Whether or not this node is indexed.

Methods:

  • add_child: Adds a child node.
  • remove_child: Removes a child node.
add_child(entry)[source]

Adds entry as a child to self.

parse(tokens)[source]
remove_child(entry)[source]

Removes entry from the node’s children.

exception pysumo.parser.ParseError(line, linenumber)[source]

Bases: builtins.Exception

class pysumo.parser.Pos[source]

Bases: enum.Enum

class pysumo.parser.SSType[source]

Bases: enum.Enum

class pysumo.parser.SUMOConceptWordNetItem(sumo_concept, suffix, synset_offset, lex_filenum, ss_type, synset, ptr_list, frames, gloss)[source]

Bases: builtins.object

The object returned from _wtokenize containing info on the SUMO-WordNet mapping.

pysumo.parser.astmerge(trees)[source]

Merge two Abstract Syntax Trees

Args:

  • trees: a tuple of 2 AST objects

Returns:

  • AbstractSyntaxTree
pysumo.parser.kifparse(infile, ontology, ast=None)[source]

Parse an ontology and return an AbstractSyntaxTree.

Args:

  • ontology: the ontology to parse
  • graph: a modified graph of this ontology
  • ast: the AST of ontologies which are needed from this ontology
  • infile: the file object to parse

Returns:

  • AbstractSyntaxTree
pysumo.parser.kifserialize(ast, ontology, out)[source]

Writes ontology to disk as kif. Parses ast and writes out all nodes that belong to ontology.

Args:

  • ast: the Abstract Syntax Tree
  • ontology: The specific ontology with is written to disk
  • f: The file object witch written in

Raises:

  • OSError
pysumo.parser.wparse(datafiles)[source]

Parses the file containing the SUMO-WordNet mapping.

Args:

  • path: The path to the SUMO-WordNet mapping files

Returns:

  • Dictionary

pysumo.syntaxcontroller module

!include ./UML/pysumo/SyntaxController.iuml


Handles all write accesses to the Ontologies and kif files. The SyntaxController’s main purpose is to act as an intermediary between the user and the Ontology.

This module contains:

  • SyntaxController: The interface to the parser/serializer.
class pysumo.syntaxcontroller.Ontology(path, name=None, url=None, lpath=None)[source]

Bases: builtins.object

Contains basic information about a KIF file. This class is used to maintain separation between different Ontology-files so the user can choose which are active and where each Ontology should be saved.

Variables:

  • name: The name of the Ontology.
  • path: The location of the Ontology in the filesystem.
  • url: The URL from which the Ontology can be updated.
  • active: Whether or not the Ontology is currently loaded.
save()[source]

Saves all pending changes in self to self.path.

class pysumo.syntaxcontroller.SyntaxController(index)[source]

Bases: builtins.object

The high-level class containing the interface to all parsing/serialization operations. All operations that can modify the Ontology or kif-file are passed through the SyntaxController. The SyntaxController acts as a moderator between user-side widgets and the low-level API ensuring that all requests are correct, that higher objects never gain direct access to internal objects and that all changes to the Ontology are atomic.

Methods:

  • parse_partial: Checks a code block for syntax errors.
  • parse_patch: Checks a code for correctness and adds it to the Ontology.
  • add_ontology: Adds an Ontology to the in-memory Ontology.
  • remove_ontology: Removes an Ontology from the in-memory Ontology.
  • undo: Undoes the most recent change to the ontology.
  • redo: Redoes the most recent change to the ontology.
add_ontology(ontology, newversion=None)[source]

Adds ontology to the current in-memory Ontology.

Arguments:

  • ontology: the ontology that will be added
  • newversion: a string witch represent the new verison of the ontology

Raises:

  • ParseError
parse_partial(code_block, ontology=None)[source]

Tells self.parser to check code_block for syntactical correctness.

Arguments:

  • code_block: the partial code block that will be checked

Raises:

  • ParseError
parse_patch(ontology, patch)[source]

Apply a patch to the last version of the ontology and parse this new version

Arguments:

  • ontology: the ontlogy which is patched
  • patch: the patch to add to the ontology

Raises:

  • ParseError
redo(ontology)[source]

Redoes the last action in ontology

remove_ontology(ontology)[source]

Removes ontology from the current in-memory Ontology.

Arguments:

  • ontology: the ontology that will be removed

Raises:

  • NoSuchOntologyError
undo(ontology)[source]

Undoes the last action in ontology

pysumo.syntaxcontroller.get_ontologies(lpath=None)[source]

Returns a set of all ontologies provided by pysumo as well as local ontologies.

pysumo.updater module

!include ./UML/pysumo/Updater.iuml


Module which handles updating of Ontologies. It use PycURL to check if any updates are avalible. The URLs for the ontlogies are safe in the ontology so the user can easy add an URL for a new ontlogy.

pysumo.updater.check_for_updates(ontology, function=<function <lambda> at 0x7f4fc7ccde18>)[source]

Check if there are updates for ontology. If an update is available, executes function. Function receives the new ontology file as the first positional argument.

Returns:

  • Boolean

Raises:

  • HTTPError
pysumo.updater.update(ontology, function=<function <lambda> at 0x7f4fc7ccd400>)[source]

Checks for updates to ontology and if available downloads them. If the update succeeds, executes function after the download completes. Function receives the path to the downloaded ontology as the first positional argument, and ontology as the second.

Raises:

  • HTTPError

pySUMOQt package

This section describes the graphical user interface of pySUMO. It will list all modules and classes which are necessary to connect the functionality of the pySUMO’s lib with the view and usability of a great editor. For details on this concept see the section about MVC-Structure. Note that the core work is done by Qt and the Qt Designer, so almost all classes will inherit a class designed by Qt Designer and compiled by PySide.

!include ./UML/pySUMOQt/package_pySUMOQt.iuml

Module contents

The pySUMO Qt-GUI package. This package contains all classes and widgets needed to display the pySUMO editor. There are also classes created by Qt Designer which are inherited from in the ‘coded’ classes.

Subpackages

pySUMOQt.Widget package

Module contents

The pySUMO package containing all widgets that interface with the Ontology through the IndexAbstractor and/or the SyntaxController.

Submodules
pySUMOQt.Widget.GraphWidget module

!include ./UML/pySUMOQt/Widget/GraphWidget.iuml


pySUMOQt.Widget.HierarchyWidget module

!include ./UML/pySUMOQt/Widget/HierarchyWidget.iuml


pySUMOQt.Widget.TextEditor module

!include ./UML/pySUMOQt/Widget/TextEditor.iuml


pySUMOQt.Widget.Widget module

!include ./UML/pySUMOQt/Widget/Widget.iuml


pySUMOQt.Widget.DocumentationWidget module

!include ./UML/pySUMOQt/Widget/DocumentationWidget.iuml


Submodules

pySUMOQt.MainWindow module

!include ./UML/pySUMOQt/MainWindow.iuml


pySUMOQt.Settings module

!include ./UML/pySUMOQt/Settings.iuml


pySUMO in usage

For screenshots of pysumo while using it, go here

PySUMO in Use

Some screenshots while testing functionality of pySUMO or just klicking around.

Possible output when using widgets

Widgets ordering.

Documentation widget during test

Documentation widget after step 6.

Docwidget after doing test

Docwidget after doing test.

Graphwidget during test

Graphwidget after step 6.

Graphwidget after doing test

Graphwidget after step 11.

Hierarchywidget after doing test

Hierarchywidget after doing test.

Texteditor after doing test

Texteditor after doing test.

Changes in Version 1.0

pysumo

  • Rename lib to pysumo.

IndexAbstractor

  • Delete DotGraph.
  • Make root and depth keyword arguments defaulting to None
  • Turn index into a simple dict. Makes index access easier and faster.
  • Add init_wordnet() to initialize the WordNet mapping
  • Add update_index() to build the index
  • wordnet_locate() returns a list of strings
  • IA now also stores the root AST node and a list of ontologies
  • Change get_graph arguments to allow for more complex matching.
  • Add normalize method for normalizing string arguments.
  • Add function to return list of possible completions.

AbstractGraph

  • Change init to reflect new get_graph API.
  • Change variant to String from Enum and root to String from AbstractGraphNode
  • Add info argument to __init__. Allows passing the Index/List of Ontologies

WordNet

  • change argument of wparse() from a mapping file to a directory containing the mapping files and the rest of the wordnet database - avoid merging mapping files
  • completely get rid of all dependencies on NLToolkit - extending upon it is a nightmare
  • locate_term() returns a tuple of String, SSType, String

SyntaxController

  • Add an optional argument newversion to add_ontology()
  • Remove parse_graph(), the user now has to edit the file self
  • Remove parse_add(), we can use add_ontology() now
  • Moved Ontology to syntaxcontroller module

Logger

ActionLog

  • Add name argument to init.
  • undo/redo now return self.current.
  • Make ActionLog work with objects that provide a buffer interface via the getbuffer() function.
  • Add functions for pop and clear.

LogIO

  • Add default_path variable.

InfoLog

  • Add socket interface for StatusBar
  • Add default_{log_path,socket_path} variables.
  • init now receives a string detailing the loglevel instead of an int.

pySUMOQt

  • Rename ui to pySUMOQt.

TextEditor

  • remove show autocomplete – Qt does this on its own

  • Added
    • setTextChanged()
    • _initNumberBar()
    • _updateOntologySelector()
    • _hideLines(lines)
    • _showLines(lines)
    • _zoomOut_()
    • _zoomIn_()
    • showOtherOntology(ontologyname)
    • expandIfBracketRemoved()
    • increaseSize()
    • decreaseSize()
    • expandAll()
    • hideAll()
    • getLayoutWidget()
    • numberbarPaint(number_bar, event)
    • initAutocomplete()
    • searchCompletion()
    • toggleVisibility(line)
    • hideFrom(line)
    • insertCompletion(completion)
    • commit()

Introduce SyntaxHighlightSetting to handle user defined Syntax Highlight Rules

class SyntaxHighlightSetting() __init__( expression, font_weight, font_color, expression_end=’‘) createFormat() get_format() getValues() serialize() deserialize( string)

Introduce class SyntaxHighlighter class SyntaxHighlighter __init__( document) highlightBlock( text)

Introduce Numberbar because Qt does not do this on his own class NumberBar(QWidget) __init__( edit) paintEvent( event) adjustWidth( count) updateContents( rect, scroll) mouseDoubleClickEvent( event)

GraphWidget

Komplette Änderung der API, um an pygraphviz anzupassen

MainWindow

  • Added
    • _showOptionDialog_()
    • _addWidget_(widgetType, widgetMenu)
    • createPySumoWidget(widgetType, widgetMenu)
    • addDeleteWidgetAction(widget)
    • addOrRestoreWidget(widget, menu, directAdd=False)
    • closeEvent(event)
    • createStatusBar()
    • setupStatusConnection()
    • displayLog(socket)
    • _updateStatusbar_(wrappedWidget=None)
    • _deleteWidget_(widget)
    • connectWidget(widget)
    • disconnectWidget(widget, callback=None)
    • getDefaultOutputPath()
    • _newOntology_()
    • _openLocalOntology_()
    • _openRemoteOntology_()
    • addOntology(ontology, newversion=None)
    • notifyOntologyAdded(ontology)
    • _ClearRecentOntologiesHistory_()
    • _deleteOntology_(ontology)
    • _updateOntology_(ontology)
    • _revertOntology_(ontology)
    • _showOntologyProperties_(ontology)
    • _closeOntology(ontology)
  • Added quit_handler(signum, frame) to capture SIGINT signal.

  • Introduced class PySUMOWidget which wrappes the application widgets.

  • Removed class Statusbar, it became useless towards createStatusBar in MainWindow.

  • Removed class Menubar, because the menu bar is already created by the designer.

  • Removed class Toolbar, because the tool bar is already created by the designer.

  • Moved class HelpDialog to module Dialog

Settings

  • Introduced class LayoutManager.
  • Introduced class PySumoSettings.
  • Removed class PluginManager.
  • Removed class WSettings.
  • Moved class OptionDialog to module Dialog.

OptionDialog

  • Remove createView() and load(path) methods.
  • Added other methods to the OptionDialog.

Feature Request

Feature Requests

  • Search in Text Editor
  • Hyperlinks to TextEditor from GraphWidget, Hierachy, Documentation
  • Better position for GraphNode
  • Documentation Widget to Graph Widget Links
  • GraphWidget zoom to fit
  • Documentation strings links
  • Remote ontology: choose name automatically
  • GraphWidget keep root node after refresh (e.g. after adding a node)
  • GraphWidget set to new father or children

Tests

A list of your tests, to make sure pysumo is correct working. If you find a feature that is not tested by us, or you found a bug feel free to contact us.

Library

ActionLog

  • Queue the addition of an ontology to the A0ctionLog * Initialize an ActionLog with an ontology * Modify an ontology and store the changes * Assert that undoing the last action returns the previous state * Assert that undo/redo is invariant * Make sure the queue auto-flushes when exceeding size * Check that addition queue is overwritten when new changes are added and the old changes have not been OK’d. * Assert the invariance of excessive undoes * Assert the invariance of excessive redoes
  • Check that ActionLog copes with high workloads

IndexAbstractor

  • Assert than normalize() normalizes terms correctly.
  • Assert that the index is built correctly.
  • Test search on various terms
  • Test WordNet search and self-initialization.
  • Build several AbstractGraphs and check their contents
  • Test that get_ontology_file returns the correct kif
  • Test that adding multiple ontologies works
  • Test that get_completions returns a correct list of terms

Parser

wParse

  • Check that Tokenizer works on single lines
  • Check that whole WordNet parses successfully

kifParse

  • Check invariance of kifparse/kifserialize
  • Test that parsing Government.kif works

SyntaxController

  • Assert that add_ontology() adds an AST equivalent to the one produced by kifparse()
  • Assert the invariance of redundant adds
  • Assert that adding and then deleting an ontology is invariant
  • Check that adding two ontologies works correctly
  • Assert that get_ontologies() lists the correct ontologies
  • Assert that modifying the ontology works correctly
  • Assert that parsing diffs works correctly
  • Assert that undo/redo work correctl

WordNet

  • Check functionality of locate_term
  • Check functionality of find_synonym

GUI

Text Editor

Texteditor after doing test

Texteditor after doing test.

  1. Open pySUMO
  2. Open TextEditor
  3. Open Merge.kif
  4. Choose Merge.kif
  5. Collapse Line 288
  6. Collapse Line 136
  7. Collapse Line 134
  8. Uncollapse Line 134
  9. Uncollapse Line 288
  10. Collapse all
  11. Expand all

Graphical Settings

  1. Open pySUMO
  2. Open TextEditor
  3. Open Merge.kif
  4. Choose Merge.kif
  5. Open GraphWidget
  6. Open DocumentationWidget
  7. Open Hierarchy Widget
  8. Open TextEdiorWidget

Hierarchy Widget

Hierarchywidget after doing test

Hierarchywidget after doing test.

Graph Widget

Graphwidget during test

Graphwidget after step 6.

Graphwidget after doing test

Graphwidget after step 11.

  1. Open pySUMO
  2. Open GraphWidget
  3. Open Merge.kif
  4. Select instance on Variant selector
  5. Select a root node
  6. Select a depth (1)
  7. Open a new ontology to write temporary content to.
  8. Add a node “bla” in Graph Widget
  9. Add a node “bla2”
  10. Add a node “bla” (error)
  11. Add a relation instance between “bla” and “bla2” (error)
  12. Change scale
  13. Choose a valid selector (there was a messagebox)
  14. Add a relation instance between “bla” and “bla2”
  15. Undo
  16. Redo

Documentation Widget

Documentation widget during test

Documentation widget after step 6.

Docwidget after doing test

Docwidget after doing test.

  1. Open pySUMO
  2. Open Merge.kif
  3. Open DocumentationWidget
  4. Switch to the Ontology tab in the DocumentationWidget
  5. Type subrelation into the search field
  6. Press Enter
  7. Open TextEditor
  8. Select Merge.kif in TextEditor
  9. Press one of the links listed under “Merge”
  10. Switch to the WordNet tab in the DocumentationWidget
  11. Search for ‘Object’
  12. Search for ‘Table’

MainWindow

Possible output when using widgets

Widgets ordering.

  1. Open pySUMO
  2. Open a new Ontology named “Mondial”
  3. Open a remote ontology named “Mondial” at location: http://sigmakee.cvs.sourceforge.net/viewvc/sigmakee/KBs/mondial.kif
  4. Close the ontology named “Mondial” with save and reopen it as local file.
  5. Add Text Editor Widget
  6. Add Documentation Widget
  7. Add Graph Widget
  8. Add Hierarchy Widget
  9. Reorder Widgets
  10. Make a print preview of the ontology “Mondial” from the Text Editor Widget
  11. Delete the Text Editor Widget
  12. Make a print preview of the ontology “Mondial” from the Graph Widget
  13. Add a node and a relation in Graph widget
  14. Delete the Graph Widget
  15. Try to update the ontology “Mondial”
  16. Open ontology properties dialog for “Mondial” and then close it.
  17. Open Option Dialog and then close it
  18. Revert the ontology “Mondial”
  19. Quit pySUMO

Test Results

Statement Coverage of pysumo and pySUMOQt

Name Stmts Miss Cover
src/pySUMOQt/Designer/DocumentationWidget 48 0 100%
src/pySUMOQt/Designer/GraphWidget 82 0 100%
src/pySUMOQt/Designer/HierarchyWidget 68 0 100%
src/pySUMOQt/Designer/MainWindow 486 0 100%
src/pySUMOQt/Designer/NewOntologyDialog 50 0 100%
src/pySUMOQt/Designer/OntologyPropertyDialog 85 0 100%
src/pySUMOQt/Designer/OpenRemoteOntologyDialog 53 0 100%
src/pySUMOQt/Designer/OptionDialog 689 0 100%
src/pySUMOQt/Designer/TextEditor 30 0 100%
src/pySUMOQt/Designer/__init__ 0 0 100%
src/pySUMOQt/Designer/css_rc 9 1 89%
src/pySUMOQt/Designer/gfx_rc 9 1 89%
src/pySUMOQt/Dialog 264 59 78%
src/pySUMOQt/MainWindow 454 48 89%
src/pySUMOQt/Settings 202 8 96%
src/pySUMOQt/Widget/DocumentationWidget 64 10 84%
src/pySUMOQt/Widget/GraphWidget 255 15 94%
src/pySUMOQt/Widget/HierarchyWidget 103 5 95%
src/pySUMOQt/Widget/TextEditor 476 85 82%
src/pySUMOQt/Widget/Widget 68 18 74%
src/pySUMOQt/Widget/__init__ 0 0 100%
src/pySUMOQt/__init__ 0 0 100%
src/pysumo/__init__ 2 0 100%
src/pysumo/indexabstractor 147 9 94%
src/pysumo/logger/__init__ 1 0 100%
src/pysumo/logger/actionlog 181 4 98%
src/pysumo/logger/infolog 33 7 79%
src/pysumo/parser 219 4 98%
src/pysumo/syntaxcontroller 118 4 97%
src/pysumo/updater 12 1 92%
src/pysumo/wordnet 19 0 100%
TOTAL 4227 279 93%

For a more detailled view on our testing please visit our github Page

Errors

Errors Cause[s]
HTTPError An HTTP connection failed
IOError An IO operation failed
KeyError The specified key does not exist in the dict
NoSuchOntologyError The specified Ontology does not exist
NoSuchTermError The specified Term does not exist
ParseError The specified Ontology is not valid

External Libraries

PySide Python bindings for Qt
PyGraphviz Python bindings for Graphviz

Indices and tables