Giter VIP home page Giter VIP logo

glf_kernel's Introduction

NOTE

The GLF kernel has been extended by an inference component, and is now called GLIF kernel. You may want to check out the GLIF kernel's repository, as its functionality subsumes the GLF kernel.

You can test the GLIF kernel online at at mybinder.org: https://mybinder.org/v2/gh/jfschaefer/GlifBinder/master. Note that it may take a minute to launch.

You can also try to run the kernel locally via docker. By default, you get the Jupyter Lab interface.

docker run -p 8888:8888 jfschaefer/glif:1.0

GLF Kernel

glf_kernel is a kernel for Jupyter that combines functionalities of GF and MMT. It is based on the GF Kernel, which only supports GF.

GLF is intended as a framework for natural language understanding (NLU) experiments. GF can be used to quickly write grammars for natural language fragments. MMT can be used to describe a logic and the translation from GF's parse trees into that logic, which is called semantics construction. This way, the GLF kernel can be used to quickly implement the entire pipeline from natural language strings to a logical expression.

If you want to read more about GLF, you may be interested in this paper.

You can also take a look at the tutorial notebook.

Prerequisites

Python

This package requires Python 3.8 (or newer) and this README assumes that this is the default python version. If in doubt, use python3 instead of python and python3 -m pip instead of pip.

Additionally, setuptools is required to install this package. This likely came with your Python distribution, but in case it did not use pip install setuptools to install it.

GF

If you haven't installed GF already, get it from the official download website.

MMT

You can find installation instructions for MMT here. Please note that as of now (November 2019), GLF uses some not-yet released features of MMT. So you will have to either talk to us (probably the best idea) or try building MMT yourself from the devel branch of the git repository. If you only want to use MMT for the glf_kernel, you don't have to install an MMT development IDE (in a way, the notebooks will be your IDE).

Optional: Graphviz

For graph visualization GF uses Graphviz. Under Ubuntu etc. you can install it with

sudo apt install graphviz

or under Mac OS X with homebrew:

brew install graphviz

Remarks for Windows Users

The glf_kernel has been succesfully installed on Windows as well. There are two ways you can go about it, and it is not clear which one is better/easier/more likely to work:

Using the Windows Subsystem for Linux (WSL)

In this case you can basically follow the installation instructions for linux. Since Jupyter simply runs a server you can use your notebooks from a browser that is not part of the WSL. These remarks on Jupyter notebooks in WSL may be helpful.

Installing it directly in Windows

In this case you have to add GF and Graphviz (in particular dot) to the PATH variable.

Installation

You can either install the kernel from the source repository:

git clone 'insert right URL here'
cd glf_kernel
pip install .

or install it directly from pip:

pip install glf-kernel

Afterwards, install the kernel module with:

python -m glf_kernel.install

Usage

You're now ready to go and can start a Jupyter notebook with:

jupyter notebook

Alternatively you can also use this Kernel in Jupyter Lab

jupyter lab

If you intend on using the visulaization capabilities of the kernel please make sure you have widgets enabled in your Jupyter Lab.

conda install -c conda-forge nodejs
jupyter labextension install @jupyter-widgets/jupyterlab-manager

Select the glf_kernel as kernel in your notebook. The kernel supports all of the GF shell commands. Output files produced by these commands will be placed into the current directory.

The kernel can also be used to define new grammars, which are immediately imported for usage upon defining. If you would like to have line numbers for editing your code you can use the Juypter shortcut Esc+L to enable them.

In addition to the GF shell commands the kernel supports the following commands:

  • show : show the graph(s). Usage: [graph | graph generating command] | show. (e.g. parse "John loves Mary" | vt | show)
  • help : shows the help message
  • export : saves the specified grammar in the current diretory
  • clean : removes all .dot, .png and .gfo files from the current directory

It also supports MMT specific functionalities like:

  • archive: creates the specified archive. If it already exists this archive will be set as the working archive. If no arguments are supplied this will display the current working archive. Also also allows creation of nested archives. (e.g. archive comma/jupyter)
  • subdir: used to create or switch subfolders in the current working archives source folder. It is used just like the archive command.
  • construct: sends a construct request to MMT and displays the result.
  • You can use the kernel to define new theories or views just like you would do with grammars. For this the kernel also supports Tab completion of some Unicode characters. (e.g. \rightarrow + Tab will give you โ†’. \MD + Tab, \OD + Tab and \DD + Tab will give you module, object and declaration delimiters respectively).
  • experimental: you can generate stubs for concrete syntaxes and semantics construction views from abstract syntax. Let's say you have defined an abstract syntax MyGrammar. Then you can generate a concrete syntax for e.g. English by entering MyGrammarEng and pressing Tab (stub-generation is autocompletion). Similarly, you can enter MyGrammarSemantics to generate a stub for the semantics-construction view. This only works, if our Python parse for GF can handle the abstract syntax (and it's still more of a prototype, so it can't handle e.g. dependent types).

glf_kernel's People

Contributors

jfschaefer avatar kaiamann avatar tkw1536 avatar

Watchers

 avatar  avatar  avatar

Forkers

jfschaefer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.