Coder Social home page Coder Social logo

grammaticalframework / gf Goto Github PK

View Code? Open in Web Editor NEW
190.0 42.0 51.0 1.39 GB

Archive of monolithic GF repository until 2018-07-25

Home Page: http://www.grammaticalframework.org/

License: Other

Makefile 0.02% Haskell 1.62% Shell 0.01% CSS 0.03% HTML 1.12% JavaScript 0.31% Grammatical Framework 94.13% C 2.35% C++ 0.01% Objective-C 0.05% Java 0.26% Python 0.04% Prolog 0.01% Emacs Lisp 0.01% Perl 0.01% Swift 0.02% Batchfile 0.01% Yacc 0.01% Ruby 0.01% M4 0.01%
grammatical-framework

gf's People

Contributors

aarneranta avatar adamslaski avatar ayberkt avatar bringert avatar cunger avatar danadannells avatar gdetrez avatar heatherleaf avatar hleiss avatar inariksit avatar johnjcamilleri avatar kaljurand avatar kkofler avatar krangelov avatar lizazim avatar malinahlberg avatar mbrock avatar mengwong avatar mkmks avatar normundsg avatar odanoburu avatar olgacaprotti avatar pkolachi avatar ppski avatar prasanthk-ms09 avatar ramonique avatar saludes avatar scharolta avatar shafqatvirk avatar thomas-h avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gf's Issues

GF as additional source in Cabal sandbox gives error about sdist

I use a Cabal sandbox for my project, which requires the PGF library. I want to use my local copy of the GF repo, not the release from Hackage. So I do the following:

$ cabal sandbox init
$ cabal sandbox add-source path/to/GF
$ cabal install GF

This works. But now I'm not able to install anything else from Hackage into my sandbox:

$ cabal install text
setup: Error: Use `make sdist` to create the source distribution file

This message comes from Setup.hs:190.
I try make sdist in the GF repo, but get:

Unable to "darcs dist" here.
You need to be in a repository directory to run this command.

Which makes sense this is no longer a darcs repository.
I also tried replacing line 190 with this:

sdistError _ _ _ _ = return ()

But then I get this:

$ cabal install text
Warning: Could not list sources of the package 'gf'.
Warning: Exception was:
/var/folders/j9/5l774vxs023cxbhq548sg8g80000gn/T/cabal-list-sources.-32306/cabal-sdist-list-sources:
openFile: does not exist (No such file or directory)
Resolving dependencies...
All the requested packages are already installed:
text-1.2.3.0
Use --reinstall if you want to reinstall anyway.

Which I think means that the cabal install command worked, even if some error was thrown from GF's setup.

Cleanest solution

If I temporarily remove the sandbox source when installing the package, it works:

$ cabal sandbox remove-source path/to/GF
$ cabal install text
$ cabal sandbox add-source path/to/GF

This is probably a remnant of the darcs-to-git conversion. It would be great if this was fixed, but at least if someone else has the same problem then maybe this will help them.

Parsing multiple phrases into the same AST

Apples are a type of fruit
Apples are a kind of fruit
Apples are fruits

...should all be parsed to TypeOf Apple Fruit
I've tried doing this with oper overloading but I'm struggling.
I'm using the resource library.
Any ideas?

A command for asserting linearizations

As I'm making changes to the Turkish resource grammar, I am starting to doubt if the changes I'm making are messing with the stuff I have implemented before.

When I consulted @inariksit, she told that the current practice is to use resource.gfs and to have a “gold standard” against which its linearization is diffed.

I think it would be much better have a built-in solution for this like anassertLin command that takes in an abstract expression, a concrete grammar name, and an expected output and checks the linearization for equality to the expected output. Then we could have -test flag for gf that, so that when we run on a gf -run tests.gfs, prints out all the assertLins coming from tests.gfs nicely and tells whether all tests have succeeded or not.

Though this doesn't have substantial benefits compared to file-diffing, it could be one step towards a unified practice of testing resource grammars which seems to be nonexistent at this point.

If I'm not missing anything, this should also be easy to implement.

Thoughts or comments? @inariksit @krangelov

Int vs Integer

reading the docs I found the following:

The type name Integer replaces in GF 3.0 the name Int, to avoid confusion with the abstract syntax type and to be analogous with the Str vs. String distinction.

so we seem to have moved from Int to Integer, but throughout the documentation (1 2 3) I find different references as to whether the correct type for integers is Int or Integer, and in the source code I looked at (e.g., /lib/src/prelude/Predef.gf) the type seems to be Int still.

I must have missed something, so I wanted to ask what is the correct type after all!

To get the code for writing input text files to excel file

Can u please help me to get the code for writing the given input text files and it should be written to an Excel file.Text file to Excel file is the simplest question of mine.I have give certain codes to get but it not works properly.Below I will copy my written coding.

package utils;

import android.database.Cursor;
import android.os.Environment;
import android.util.Log;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Locale;

import jxl.CellView;
import jxl.Workbook;
import jxl.WorkbookSettings;
import jxl.format.UnderlineStyle;
import jxl.read.biff.File;
import jxl.write.Formula;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import java.io.*;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;

public class WriteExcel {
String input,output,engine,from,to;
ArrayList al= new ArrayList();

public boolean createfile(String input,String output,String engine,String from, String to) {
    this.input=input;
    this.output=output;
    this.engine=engine;
    this.from=from;
    this.to=to;

    Excelget write1 =new Excelget();
    write1.setInput(input);
    write1.setOutput(output);
    write1.setEngine(engine);
    write1.setFrom(from);
    write1.setTo(to);

        al.add(write1);





    try {

        String fpath = "/sdcard/" + "output" + ".xls";

        java.io.File file1 = new java.io.File(fpath);
        createExcelSheet(file1);


        // If file does not exists, then create it
        if (!file1.exists()) {
            file1.createNewFile();
        }





        return true;

    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }

}
java.io.File file;
WritableWorkbook workbook;

    public void createExcelSheet(java.io.File file) {

        this.file=file;
                    WorkbookSettings wbSettings = new WorkbookSettings();
        wbSettings.setLocale(new Locale("en", "EN"));
        try {
            workbook = Workbook.createWorkbook(file, wbSettings);
            createFirstSheet();
            //closing cursor
            workbook.write();
            workbook.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    void createFirstSheet() {
        try {

            //Excel sheet name. 0 (number)represents first sheet
            WritableSheet sheet = workbook.createSheet("sheet1", 0);
            // column and row title
            sheet.addCell(new Label(0, 0, "Original text"));
            sheet.addCell(new Label(1, 0, "Translated text"));
            sheet.addCell(new Label(2, 0, "Engine"));
            sheet.addCell(new Label(3, 0, "Translated from"));
            sheet.addCell(new Label(4, 0, "Translated to"));


            for(Excelget i:al) {

                sheet.addCell(new Label(0, 1, i.getInput()));
                sheet.addCell(new Label(0, 2, i.getOutput()));
                sheet.addCell(new Label(0, 3, i.getEngine()));
                sheet.addCell(new Label(0, 4, i.getFrom()));
                sheet.addCell(new Label(0, 5, i.getTo()));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}

Parsing arbitrary numbers

This seem silly but the hardest thing I've come across so far is how to parse arbitrary numbers in GF!
For example:
"cats have 4 legs".
"there are twenty people in the room"
I've found Numerals.gf in the lib, but for the life of me I can't figure out how to use it. I compiles fine but then fails to parse any numbers.

Decouple outdated SQLite3 Btree dependency

Right now, the module src/runtime/c/sg includes a custom version (namely sqlite3Btree.{c,h}) of an outdated snapshot of SQLite's source.
These files mention functions such as sqlite3StrICmp which are nowhere defined and are thus leading to undefined reference errors; at least when building for Windows which does not allow unknown references in shared libraries afaik. See also https://groups.google.com/forum/#!topic/gf-dev/BkYwEl0SE00 where the exact issued build instructions can be found.

I tried replacing sqlite3Btree.{c,h} by the most recent SQLite3 amalgamation files, however, the internal API of sqlite3Btree changed.
For example, the old sqlite3BtreeInsert's function signature contained in this repository looks like

int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey,
const void *pData, int nData,
int nZero, int bias, int seekResult);

but the current one (as found in the amalgamation sqlite3.c) looks like

SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
                       int flags, int seekResult);

As SQLITE_PRIVATE also indicates, the Btree API was never meant to be stable and publicly accessible.

Various issues with running the RGL test suite

RGL-related tests seem to be located in at least 3 different places (which is confusing):

  • lib/tests
  • lib/treebanks
  • testsuite/libraries

The gold-standard testsuite/libraries/exx-resource.gfs.gold covers just 3 languages.

Running cabal test fails (at least under my setup) with:

cabal: You need to re-run the 'configure' command.
The version of Cabal being used has changed (was Cabal-1.22.5.0, now Cabal-1.22.2.0).
Additionally the compiler is different (was ghc-7.10, now ghc-7.6)
which is probably the cause of the problem.

Difficulties understanding Pattern Matching

I understand Pattern Matching in GF is working in a non-greedy way instead of the usual greedy matching which is the default in POSIX regular expressions.

Now I have difficulties writing a greedy pattern matcher. For instance, if I have

  mkTüttö : Str -> Noun = \tüttö -> 
    case tüttö of {
      tüt + "t" + ö => mkTüttöConcrete tüt ö ; 
      _ => Predef.error "Unsuitable lemma for mkTüttö"
    } ;

It will match tüt with the empty string and ö will match üttö. What I want is that the constant "t" in the pattern will match the last t in tüttö (i.e greedy matching).

The GF book and slides only mention pattern composition with the + and | operators but doesn't tell how repetition can be expressed (except for the non-greedy wildcard _).

What would be the correct way to express a greedy regular expression such as POSIX .* or [a-z]* with the GF Pattern Matching mechanism?

Conversion of AppGer.gf and AppFre.gf to .Pgf not working

$ make AppGer.pgf
mkdir -p ./gfos && gf -s -make -literal=PN,Symb -probs=./app.probs -gfo-dir ./gfos -name=AppGer AppGer.gf
gf: out of memory (requested 1048576 bytes)
Makefile:61: recipe for target 'AppGer.pgf' failed
make: *** [AppGer.pgf] Error 251

when trying to convert AppGer.gf and AppFre.gf to .Pgf,i am getting out of memory error.kindly need help for the same.Any help would be much appreciated.
Thanks in advance.

Could not find module ‘SG’ and ‘PGF2’ while building

@krangelov Do you know why this is happening?. I was able to create the .so file but runghc glosses.hs command resulted in this error.

:~/GFT/GF-master/src/ui/android# runghc glosses.hs 

glosses.hs:1:8:
    Could not find module ‘SG’
    Use -v to see a list of the files searched for.

glosses.hs:2:8:
    Could not find module ‘PGF2’
    Use -v to see a list of the files searched for.
root@ap-vbox:~/GFT/GF-master/src/ui/android# 

should the `vars` oper be added to the Prelude?

considering the problem I had at #28 with the extensive use of variants in a large grammar, the oper vars was proposed as partial solution:

-- hack to get the same behaviour as from variants. parses both, linearizes the first. 
oper vars : Str -> Str -> Str = \x,y -> pre { "" => x ; _ => y } ;

it then became a definition in a module of the grammar, but I wonder if it shouldn't be in the Prelude, so that no other grammars need to repeat its definition.

Resource API for Turkish

The status document says that the Turkish resource grammar library does not implement the resource API. I am very interested in working on this as a native speaker of Turkish!

If someone can instruct me on where to start (or point me to some documentation on this) I'll start doing some work. I'm opening this up issue to track the progress on this.

In NounTur.gf, the following linearizations have to be implemented:

  • NounTur.gf
    • AdNum
    • AdjDAP
    • AdvCN
    • AdvNP
    • ApposCN
    • ComplN3
    • CountNP
    • DetDAP
    • DetNP
    • DetQuantOrd
    • ExtAdvNP
    • NumDigits
    • OrdNumeralSuperl
    • PPartNP
    • PartNP
    • PossNP
    • PredetNP
    • RelCN
    • RelNP
    • SentCN
    • Use2N3
    • Use3N3
    • UsePN
  • StructuralTur.gf
    • all_Predet
    • almost_AdA
    • almost_AdN
    • although_Subj
    • always_AdV
    • and_Conj
    • as_CAdv
    • at_least_AdN
    • at_most_AdN
    • because_Subj
    • behind_Prep
    • between_Prep
    • both7and_DConj
    • but_PConj
    • by8agent_Prep
    • by8means_Prep
    • can8know_VV
    • can_VV
    • during_Prep
    • either7or_DConj
    • every_Det
    • everybody_NP
    • everything_NP
    • everywhere_Adv
    • except_Prep
    • few_Det
    • for_Prep
    • from_Prep
    • have_V2
    • here7from_Adv
    • here7to_Adv
    • here_Adv
    • how8many_IDet
    • how8much_IAdv
    • how_IAdv
    • if_Subj
    • if_then_Conj
    • in8front_Prep
    • in_Prep
    • language_title_Utt
    • less_CAdv
    • many_Det
    • more_CAdv
    • most_Predet
    • much_Det
    • must_VV
    • no_Quant
    • no_Utt
    • nobody_NP
    • not_Predet
    • nothing_NP
    • on_Prep
    • only_Predet
    • or_Conj
    • otherwise_PConj
    • part_Prep
    • please_Voc
    • possess_Prep
    • quite_Adv
    • so_AdA
    • somePl_Det
    • someSg_Det
    • somebody_NP
    • something_NP
    • somewhere_Adv
    • that_Subj
    • there7from_Adv
    • there7to_Adv
    • there_Adv
    • therefore_PConj
    • through_Prep
    • to_Prep
    • too_AdA
    • under_Prep
    • very_AdA
    • want_VV
    • whatPl_IP
    • whatSg_IP
    • when_IAdv
    • when_Subj
    • where_IAdv
    • which_IQuant
    • whoPl_IP
    • whoSg_IP
    • why_IAdv
    • without_Prep
    • yes_Utt
  • SentenceTur.gf:
    • AdvS
    • AdvSlash
    • EmbedQS
    • EmbedS
    • EmbedVP
    • ExtAdvS
    • ImpVP
    • PredSCVP
    • RelS
    • SSubjS
    • SlashPrep
    • SlashVP
    • SlashVS
    • UseCl
    • UseQCl
    • UseRCl
    • UseSlash
  • AdjectiveTur.gf
    • AdAP
    • CAdvAP
    • ReflA2
    • SentAP

Could not find module ‘SG’ and ‘PGF2’ while building

@krangelov Do you know why this is happening?. I was able to create the .so file but runghc glosses.hs command resulted in this error.

:~/GFT/GF-master/src/ui/android# runghc glosses.hs 

glosses.hs:1:8:
    Could not find module ‘SG’
    Use -v to see a list of the files searched for.

glosses.hs:2:8:
    Could not find module ‘PGF2’
    Use -v to see a list of the files searched for.
root@ap-vbox:~/GFT/GF-master/src/ui/android# 

Crash while switching between languages.

This is the log

java.lang.RuntimeException: An error occured while executing doInBackground()
                                                                             at android.os.AsyncTask$3.done(AsyncTask.java:304)
                                                                             at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
                                                                             at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
                                                                             at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                                                             at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
                                                                             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                                             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                                             at java.lang.Thread.run(Thread.java:818)
                                                                          Caused by: org.grammaticalframework.pgf.PGFError: The concrete syntax is not loaded
                                                                             at org.grammaticalframework.pgf.Concr.linearize(Native Method)
                                                                             at com.gftranslation.GFTranslator.translate(GFTranslator.java:368)
                                                                             at com.proxy.businessobject.OfflineTranslate$3.doInBackground(OfflineTranslate.java:391)
                                                                             at com.proxy.businessobject.OfflineTranslate$3.doInBackground(OfflineTranslate.java:383)
                                                                             at android.os.AsyncTask$2.call(AsyncTask.java:292)
                                                                             at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                             at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
                                                                             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
                                                                             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
                                                                             at java.lang.Thread.run(Thread.java:818) 

Polarity being parsed but not showing up in trees

This pizza isn't warm is parsed successfully, but the resulting tree is just:
Is ( This ( Pizza ) ) Warm

The negation is ignored. How do I get the polarity to be put into the tree? I expect something like:

Not( Is ( This ( Pizza ) ) Warm)

I'm using the RGL.

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.