Skip to content

Miscellaneous

TF.version
Description

Contains the version number of the Text-Fabric library.

TF.banner
Description

Contains the name and the version of the Text-Fabric library.

Messaging

Timed messages

Error and informational messages can be issued, with a time indication.

silentOn(), silentOff(), isSilent(), setSilent()

Suppress or enable informational messages, i.e. messages issued through info() below.

This is no influence on error messages, i.e. messages issued through error() below.

1
silentOn(deep=False)

Suppress informational messages. If deep=True also suppresses warnings.

1
silentOff()

Enable informational messages.

1
setSilent(flag)

e.g.

1
2
3
setSilent(False)
setSilent(True)
setSilent('deep')

Enable or suppress informational/warning messages dependent on flag.

1
isSilent()

Whether informational messages are currently suppressed or not.

info(), warning(), error()
1
2
3
info(msg, tm=True, nl=True)
warning(msg, tm=True, nl=True)
error(msg, tm=True, nl=True)
Description

Sends a message to standard output, possibly with time and newline.

  • if info() is being used, the message is suppressed if the silent mode is currently on;
  • if the silent mode is not True but 'deep', warnings() will also be suppressed;
  • error() messages always come through;
  • if info() or warning is being used, the message is sent to stdout;
  • if error() is being used, the message is sent to stderr;

In a Jupyter notebook, the standard error is displayed with a reddish background colour.

tm

If True, an indicator of the elapsed time will be prepended to the message.

nl

If True a newline will be appended.

indent()
1
indent(level=None, reset=False)
Description

Changes the level of indentation of messages and possibly resets the time.

level

The level of indentation, an integer. Subsequent info() and error() will display their messages with this indent.

reset

If True, the elapsed time to will be reset to 0 at the given level. Timers at different levels are independent of each other.

Clearing the cache

clearCache()
1
TF.clearCache()
Description

Text-Fabric precomputes data for you, so that it can be loaded faster. If the original data is updated, Text-Fabric detects it, and will recompute that data.

But there are cases, when the algorithms of Text-Fabric have changed, without any changes in the data, where you might want to clear the cache of precomputed results.

Calling this function just does it, and it is equivalent with manually removing all .tfx files inside the hidden .tf directory inside your dataset.

See also clean() below

From version 7.7.7 onwards, Text-Fabric uses a parameter called PACK_VERSION to mark the stored pre-computed data. Whenever there are incompatible changes in the packed data format, this version number will be increased and Text-Fabric will not attempt to load the older pre-computed data.

The older data will not be removed, however. Use the function clean() below to get rid of pre-computed data that you no longer need.

No need to load

It is not needed to execute a TF.load() first.

clean()
1
2
from tf.clean import clean
clean(tfd=True, gh=False, dry=False, specific=None, current=False)
Description

Removes all precomputed data resulting from other PACK_VERSIONs than the one currently used by Text-Fabric.

You find the current pack version in the parameters file.

tfd

By default, your ~/text-fabric-data is traversed and cleaned, but if you pass tfd=False it will be skipped.

gh

By default, your ~/github will be skipped, but if you pass gh=True it will be traversed and cleaned.

specific

You can pass a specific directory here. The standard directories ~/github and ~/text-fabric-data will not be used, only the directory you pass here. ~ will be expanded to your home directory.

current

If current=True, also the precomputed results of the current version will be removed.

dry

By default, nothing will be deleted, and you only get a list of what will be deleted if it were not a dry run. If you pass dry=False the delete actions will really be executed.