Skip to content

Latest commit

 

History

History
202 lines (134 loc) · 7.38 KB

README.md

File metadata and controls

202 lines (134 loc) · 7.38 KB

TAMGU (탐구): A FIL Language

TAMGU is a FIL programming language: Functional, Imperative and Logical.

TAMGU is a multithreaded programming language that provides:

  • an imperative formalism close to Python, but with a strong and powerful type system.
  • a functional formalism inspired by Haskell, which can freely mix with the imperative paradigm
  • a logical formalism inspired by Prolog, which can freely mix with the imperative and functional paradigms

For each specific problem in your programming, choose the most appropriate formalism and freely mix functional, imperative and logical approaches to implement the most expressive but also the most compact code possible.

Annotation

TAMGU provides also an annotation language implementation (see below for an example), which allows for an efficient way to detect complex patterns in text.

The language provides many features but also many libraries, which helps design and implement annotation schemes for complex documents.

Code Example

Below is an example of the kind of code that you can implement with Tamgu.

//An imperative language

int i=10;
string s="20";
------------------------------------------------------------------------------------
//Containers

map m = {'a':1, 'b':2}; //all sorts of containers
treemap t = {"u":10, 'v':'toto'};
vector v = [1,2,3,"a","b"];
ivector iv = [1..10]; //iv = [1,2,3,4,5,6,7,8,9,10]
iv = [1,3..10]; //iv = [1,3,5,9]
------------------------------------------------------------------------------------
//Functions, threads and frames

function mycall(int i, string s) {...} //functions
thread mythread(int i, string s) {...} //threads
frame myclass {...} //class definition
------------------------------------------------------------------------------------
//Native Korean string support

s="에버랜드 알쏭달쏭 Quiz";
if (s[0].ishangul()) println("Ok");
uvector dec = s.jamo(); //['ᄋ','ᅦ','ᄇ','ᅥ','ᄅ','ᅢ','ᆫ','ᄃ','ᅳ'...]
dec = s.romanization(); //['-/ng','e','b','eo','r/l','ae','n','d',...]
------------------------------------------------------------------------------------
//Functional approach based on Haskell

ivector iv = [1..20]; //a list of integers between 1 and 20
iv.shuffle(); //The order of the elements is now random.

<fastsort([]) = []>;  //if the list is empty, we return an empty "list"
<fastsort([fv:v]) =  minlist &&& fv &&& maxlist where //we merge the different list...
    let minlist = fastsort(<filter (<=fv) v>), //we sort the list with elements smaller than fv
    let maxlist = fastsort(<filter (>fv) v>)>; //we sort the list with elements larger than fv

//we can call a functional definition as regular code
v=fastsort(iv); 

------------------------------------------------------------------------------------
//Predicates

concat([],?X,?X).
concat([?H|?T],?Y, [?H|?Z]) :- concat(?T,?Y,?Z).

//You can mix freely your predicate definition with some regular tamgu code
v=concat(["english",'russian',"french"],['spanish'],?L);
println(v); //["english",'russian',"french","spanish"]

Annotation Example

Tamgu also provides an integrated rule mechanism, which combines both lexicons and rules to detect complex patterns in texts.

//We define some lexical rules (starting with a "@")
@food <- burger.
@food <- tartare.


//Our rule: if "the food" word is found in a sentence, then we return a "meal" label 
meal <- "the", #food.

//We need a specific object to scan a sentence
annotator r;

//a sentence
string sentence="Here, the burger and the tartare are delicious.";
vector v = r.parse(sentence); 

//Result: v =  [['meal',[10,16]],['meal',[25,32]]]
//It reads: two 'meal' were found at position 10-16 and position 25-32...

Documentation

English Documentation

한국어 문서

Documentation en français

Documentación en español

Ελληνική τεκμηρίωση

Pre-compiled Releases

Note: Releases for Windows, Mac OS and Linux are available at: https://github.com/naver/tamgu/releases

Docker

We also provide a Dockerfile, together with precompiled versions of Tamgu and its libraries for Ubuntu 22.04.

Move into the docker directory. You can then create your own docker image with the command:

docker build -t tamgu-interpreter .

To execute the docker:

docker run -it tamgu-interpreter

Examples

Examples are available both as a folder: https://github.com/naver/tamgu/tree/master/examples or as an archive in: https://github.com/naver/tamgu/releases/tag/tamgu.examples.

Compiling

The TAMGU project has been implemented in C++. It can be compiled on most platforms:

Libraries

Tamgu also provides different libraries:

Compiling libraries: https://github.com/naver/tamgu/wiki/1.4-Compiling-libraries-(Linux-&-Mac-OS)

Windows requirements for: libsound and libwapti

These two libraries need the following DLL on Windows, which you can obtained from: http://www.mingw.org

libgcc_s_sjlj-1.dll
libltdl-7.dll
libstdc++-6.dll
libwinpthread-1.dll

Python

Furthermore, Tamgu provides a bi-directional library, which can be used to execute Tamgu code from Python (and conversely, Python code in Tamgu)

See: https://github.com/naver/tamgu/wiki/1.5-Compiling-Python for more information

License

BSD 3-Clause License

Copyright (c) 2019-present NAVER Corp.
All rights reserved.

Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this 
   list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, 
   this list of conditions and the following disclaimer in the documentation 
   and/or other materials provided with the distribution.

3. Neither the name of Naver Corporation nor the names of its 
   contributors may be used to endorse or promote products derived from 
   this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.