Coder Social home page Coder Social logo

letuananh / intsem.fx Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 1.0 3.66 MB

A Python 3 implementation of the Integrated Semantic Framework that provides computational deep semantic analysis by combining structural semantics from construction grammars and lexical semantics from ontologies in a single representation.

Home Page: https://osf.io/9udjk/

License: MIT License

Python 99.69% Shell 0.31%
erg python grammar nlp hpsg delphin

intsem.fx's Introduction

Integrated Semantic Framework

A Python 3 implementation of the Integrated Semantic Framework that provides computational deep semantic analysis by combining structural semantics from construction grammars and lexical semantics from ontologies in a single representation.

coolisf is only a back-end semantic parsing module that runs on command-line interaface or in Python programs. If you want a friendly graphical user interface, please use visualkopasu.

A quick glance

To parse a sentence, use coolisf text command

python -m coolisf text "I drink green tea." -f dmrs

:`I drink green tea.` (len=5)
------------------------------------------------------------
dmrs {
  10000 [pron<0:1> x ind=+ num=sg pers=1 pt=std];
  10001 [pronoun_q<0:1> x ind=+ num=sg pers=1 pt=std];
  10002 [_drink_v_1_rel<2:7> e mood=indicative perf=- prog=- sf=prop tense=pres];
  10003 [udef_q<8:18> x num=sg pers=3];
  10004 [_green+tea_n_1_rel<8:18> x num=sg pers=3];
  0:/H -> 10002;
  10001:RSTR/H -> 10000;
  10002:ARG1/NEQ -> 10000;
  10002:ARG2/NEQ -> 10004;
  10003:RSTR/H -> 10004;
}
# 10002 -> 01170052-v[drink/lelesk]
# 10004 -> 07935152-n[green tea/lelesk]
...

For batch processing, create a text file with each sentence on a separate line. For example here is the content of the file demo.txt

I drink green tea.
Sherlock Holmes has three guard dogs.
A soul is not a living thing.
Do you have any green tea chest?

After that, run the following parse command to analyse the text and write the output to demo_out.xml

python -m coolisf parse demo.txt -o demo_out.xml

Here is an example of using coolisf in a Python code

from coolisf import GrammarHub
ghub = GrammarHub()
# parse an English text
sent = ghub.ERG_ISF.parse("I love drip coffee.")
# print semantic structures for all potential readings
for reading in sent:
    print(reading.dmrs())

Output

dmrs {
  10000 [pron<0:1> x ind=+ num=sg pers=1 pt=std];
  10001 [pronoun_q<0:1> x ind=+ num=sg pers=1 pt=std];
  10002 [_love_v_1_rel<2:6> e mood=indicative perf=- prog=- sf=prop tense=pres];
  10003 [udef_q<7:19> x num=sg pers=3];
  10004 [_drip+coffee_n_1_rel<7:19> x num=sg pers=3];
  0:/H -> 10002;
  10001:RSTR/H -> 10000;
  10002:ARG1/NEQ -> 10000;
  10002:ARG2/NEQ -> 10004;
  10003:RSTR/H -> 10004;
}
...

Fore more information, please refer to the documentation for coolisf at https://coolisf.readthedocs.io

Install

The coolisf package itself is available on PyPI and it can be installed using pip

pip install coolisf

However, it can be tricky to acquire all the required components and data. Please find version specific prerequisites and installation instructions on coolisf's official Github release page.

If you encounter any problems or difficulties, please submit a ticket for support at: https://github.com/letuananh/intsem.fx/issues

intsem.fx's People

Contributors

letuananh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

coderboy24x7

intsem.fx's Issues

missing module in lelesk

During the installation from source

$ ./setup.py
/home/user/.local/lib/python3.6/site-packages/delphin/interfaces/ace.py:37: FutureWarning: Responses from the ACE interface will use a response class (like delphin.interfaces.rest) in future releases and may not be entirely compatible with the current format.
  FutureWarning
Traceback (most recent call last):
  File "./setup.py", line 39, in <module>
    from coolisf import __author__, __email__
  File "/home/user/workspace/intsem.fx/coolisf/__init__.py", line 49, in <module>
    from .ghub import GrammarHub
  File "/home/user/workspace/intsem.fx/coolisf/ghub.py", line 47, in <module>
    from coolisf.config import read_config
  File "/home/user/workspace/intsem.fx/coolisf/config.py", line 46, in <module>
    from coolisf.common import write_file
  File "/home/user/workspace/intsem.fx/coolisf/common.py", line 43, in <module>
    from lelesk.util import ptpos_to_wn
ModuleNotFoundError: No module named 'lelesk.util'

error after the installation

% python -m coolisf text "I drink green tea." -f dmrs
Traceback (most recent call last):
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/ar/venv/lib/python3.8/site-packages/coolisf/__main__.py", line 6, in <module>
    main.main()
  File "/Users/ar/venv/lib/python3.8/site-packages/coolisf/main.py", line 468, in main
    app.run()
  File "/Users/ar/venv/lib/python3.8/site-packages/texttaglib/chirptext/cli.py", line 135, in run
    args.func(self, args)
  File "/Users/ar/venv/lib/python3.8/site-packages/coolisf/main.py", line 230, in parse_text
    result = ghub.parse(text, args.grammar, args.topk, args.wsd, args.nocache, wsd=wsd, ctx=ctx)
  File "/Users/ar/venv/lib/python3.8/site-packages/coolisf/ghub.py", line 133, in parse
    sent = self[grm].parse(txt, parse_count=pc, ignore_cache=ignore_cache)
  File "/Users/ar/venv/lib/python3.8/site-packages/coolisf/ghub.py", line 226, in parse
    return self.parse_many((text,), parse_count, extra_args, ignore_cache)[0]
  File "/Users/ar/venv/lib/python3.8/site-packages/coolisf/ghub.py", line 221, in parse_many
    for sent in self.parse_many_iterative(texts, parse_count, extra_args, ignore_cache):
  File "/Users/ar/venv/lib/python3.8/site-packages/coolisf/ghub.py", line 179, in parse_many_iterative
    with ace.AceParser(self.gram_file, executable=self.ace_bin, cmdargs=args) as parser, self.cache.ctx() as ctx:
  File "/Users/ar/venv/lib/python3.8/site-packages/texttaglib/puchikarui/puchikarui.py", line 570, in ctx
    return self.ds.open(schema=self)
  File "/Users/ar/venv/lib/python3.8/site-packages/texttaglib/puchikarui/puchikarui.py", line 232, in open
    exe = ExecutionContext(self.path, schema=schema, auto_commit=ac)
  File "/Users/ar/venv/lib/python3.8/site-packages/texttaglib/puchikarui/puchikarui.py", line 376, in __init__
    self.conn = sqlite3.connect(str(path))
sqlite3.OperationalError: unable to open database file

I have to create the local/isf/data/temp manually. Maybe add that to https://coolisf.readthedocs.io/en/latest/?

install error

After install all the requirements.txt with python3 -m pip install -r requirements.txt, I still needed to run pip3 install chirptext and pip3 install yawlib. But how to install lelesk?

$ ./isf
WARNING: ISF_HOME could not be located ...
Defaulting to /Users/ar/hpsg/intsem.fx-0.2.2
/usr/local/lib/python3.7/site-packages/delphin/interfaces/ace.py:37: FutureWarning: Responses from the ACE interface will use a response class (like delphin.interfaces.rest) in future releases and may not be entirely compatible with the current format.
  FutureWarning
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/Users/ar/hpsg/intsem.fx-0.2.2/coolisf/__init__.py", line 49, in <module>
    from .ghub import GrammarHub
  File "/Users/ar/hpsg/intsem.fx-0.2.2/coolisf/ghub.py", line 47, in <module>
    from coolisf.config import read_config
  File "/Users/ar/hpsg/intsem.fx-0.2.2/coolisf/config.py", line 46, in <module>
    from coolisf.common import write_file
  File "/Users/ar/hpsg/intsem.fx-0.2.2/coolisf/common.py", line 43, in <module>
    from lelesk.util import ptpos_to_wn
ModuleNotFoundError: No module named 'lelesk'

code for programmatically get the senses for each predicate

The code in the README file shows how to print a specific reading of a sentence. But I want to go further in the use of the DMRS augmented with senses.. How can I get the predicates and the senses? ISF has a wrapper to the https://pydelphin.readthedocs.io/en/latest/ classes, right? In what objects the senses are attached? Can you expand the code below to show how to iterate over the predicates of a reading to get its associated senses?

from coolisf import GrammarHub
ghub = GrammarHub()
# parse an English text
sent = ghub.ERG_ISF.parse("I love drip coffee.")
# print semantic structures for all potential readings
for reading in sent:
    print(reading.dmrs())

A complementary question is if the initial predicates are available besides the ones produced by ISF for the MWE. For example, can I still get the green and tea beside the green+tea?

Dissertation available?

Hi Le Tuan Anh,

PhD Dissertation: Developing and Applying an Integrated Semantic Framework for Natural Language Understanding

Are you planning to make your dissertation available ?

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.