5 Importing and Exporting
Although it is possible to create objects from scratch as shown in
Section 6, it is often useful that objects of the context
reflect objects existing outside of Camelis contexts, i.e. files
or parts of files residing in the file system or URLs
(Section 5.1). Reciprocally it is also useful to make
sets of objects be reflected by files, e.g. playlists for music or
slide shows for pictures (Section 5.2). In addition to
files, it is possible to import/export contexts (or parts of contexts)
in order to share them with other users or applications
(Section 5.3). Import and export commands are
available from the menu File.
5.1 Importing Files and Directories
Directories, files, and URLs can be imported into a context by
activating the menu command File > Import > Import file....
Directories and files can be specified as local path or as web
locations. This command opens a dialog where a file or a directory
must be selected, and that offers a few options:
-
recursive traversal of directories (on): if a directory is selected, recursively traverses the tree structure below it.
- extract file parts when applicable (off): extract relevant file parts as objects. For instance a bookmarks file can be seen as one object representing the file, or as a set of objects representing URLs in addition to the object representing the file.
- filter files from their suffix (off): when recursively traversing directories, import only files whose extension match one the given suffixes.
- put objects in the current query (off): use the current query as an initial update for objects produced by the selected files.
Once a file has been imported it becomes a registered source of
the current context. The kind of files (and directories) that can be
imported, and the way a set of objects is produced and logically
described from these files, depend on the Camelis application,
and more precisely on the chosen source modules. An example Camelis application is detailed in Section 9.
The effect of registering a new source can be seen as the top right
little text entry contains the number of elementary updates that
remain to be performed: the update count. When this count
reaches 0, the navigation and extent windows are refreshed in order to
reflect changes in the context. However it is possible to refresh
these windows at any time by pushing the button Refresh.
The registered sources can be displayed as a dialog window by the menu
command File > Import > List sources.... It contains the tree of
source locations and a list of action buttons. A source is red-colored
when its location does not exists anymore, and green-colored
otherwise. The buttons have the following effect:
-
Refresh: refresh the tree of source locations,
- Add: add a new source like the command File > Import > Import file...,
- Move: relocate the selected source by specifying a new path in the file system,
- Paste: update the query associated to the selected sources (detailed in Section 6),
- Delete: delete the selected sources as well as all objects produced from them,
- Clear: deleter all sources whose location is lost (red-colored sources),
- Update: update the context w.r.t. the selected sources when they have changed,
- Close: close the source tree window.
Two shorthands for updating all sources are the menu command File
> Import > Update all, and the button Update. The update count
at the top right of the main window reflects the number of elementary
updates to be performed.
5.2 Exporting Extents as Files
A set of objects can be exported as a file provided it is the extent
of some query. Indeed it is more meaningful to specify an export by a
query, i.e. a combination of features, than by an explicit set of
objects. In this way each time an object appears or disappears from
the extent of the query, the file is updated accordingly. For
registering an export file, first set the current query to the desired
one, then activate the menu command File > Export > Export
file..., and select a path in the file system. This file is then
registered as a well. The way a query extent is converted into a
file depends on the Camelis application, and more precisely on
the chosen well modules. An example Camelis application is
detailed in Section 9.
The registered wells can be displayed as a dialog window by
the menu command File > Export > List wells.... It contains
the tree of wells (location and query) and a list of action buttons:
-
Refresh: refresh the tree of wells,
- Add: add a new well like with command Export file...,
- Move: relocate the selected well by specifying a new path in the file system,
- Paste: replace the query associated to the selected wells by the current query,
- Delete: delete the selected wells (this may delete the associated files),
- Close: close the well tree window.
5.3 Importing and Exporting Contexts
As explained in Section 8 all elements of a context (objects,
sources, wells, etc.) are saved in one large binary file. This makes
it difficult to share data from one context to another. For instance
if someone has spent time defining a taxonomy of terms with axioms
(e.g. music genres), it may be useful to reuse it on different but
similar data. This is solved by exporting and importing context data
through textual files with extension .ctx.
These context files are simply lists of commands, one per line, and
can convey any element of a context. These elements are separated in
several categories:
-
other .ctx files (command include),
- sources (command src),
- axioms (command axiom),
- extrinsic data on objects (commands mk, and mv),
- features visible in the navigation tree (commands show, and hide),
- wells (command wll),
- update rules (command rule, see Section 6),
- actions (command action, see Section 7).
When importing or exporting in a context, any of these categories can
be unselected in order to control what kind of data is shared. Another
way to control the scope of exporting a context is the current query
as only objects in the current extent are considered for the export of
extrinsic data. These operations are available in the menu File.
In the case where the current query is all, and all categories
are selected, the full context can be exported and regenerated by
importing the context file in a new context. This is useful to
transfer a context between 2 different Camelis applications or
versions whose binary formats are incompatible.
There is also the command File > Export > Export context in
Burmeister format that exports the context in a format that is
readable by some FCA tools (e.g., ToscanaJ, ConExp). These tools can
be used for instance to compute and draw concept lattices. The formal
context that is exported is restricted to the objects in the current
extent, and to the features that are selected in the navigation
window.