| Name | ulflib JSON |
| Version |
0.0.23
JSON |
| download |
| home_page | |
| Summary | A Python port of the Lisp ulflib package by Gene Kim. |
| upload_time | 2024-01-19 02:39:37 |
| maintainer | |
| docs_url | None |
| author | |
| requires_python | >=3.7 |
| license | |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
transduction
memoization
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# Python ULF Library
Python library for interfacing with and manipulating unscoped episodic logical forms (ULF), based on the [original Common Lisp implementation](https://github.com/genelkim/ulf-lib) by Gene Kim.
Additional information can be found at the [ULF project page](https://www.cs.rochester.edu/u/gkim21/ulf/).
## Dependencies
* [transduction](https://pypi.org/project/transduction/)
* [memoization](https://pypi.org/project/memoization/)
## Summary
Install the package using `pip install ulflib`.
Import the package using the following line.
```python
from ulflib import ulflib
```
## Documentation
### Lexical match predicates
The following match functions are made available for matching individual lexical items (intended for use with the [transduction](https://pypi.org/project/transduction/) package). Refer to the [ULF annotation guidelines](https://www.cs.rochester.edu/u/gkim21/ulf/assets/doc/ulf_annotation_guideline_v1.pdf) for additional details on the ULF lexical categories.
Upon importing this package, each lexical match function is registered with the transduction package and can be accessed in transduction rules using the corresponding predicates, e.g., `!lex-noun-p` or `*lex-noun-p`. The negated versions of the predicates are also registered, e.g., `!not-lex-noun-p`.
```python
LEX_PREDS = [
lex_noun_p,
lex_rel_noun_p,
lex_function_p,
lex_pronoun_p,
lex_verb_p,
lex_adjective_p,
lex_p_p,
lex_p_arg_p,
lex_ps_p,
lex_pq_p,
lex_prep_p,
lex_pp_p,
lex_mod_a_p,
lex_mod_n_p,
lex_mod_p,
lex_rel_p,
lex_det_p,
lex_coord_p,
lex_aux_s_p,
lex_aux_v_p,
lex_aux_p,
lex_number_p,
lex_name_p,
lex_adv_a_p,
lex_adv_s_p,
lex_adv_e_p,
lex_adv_f_p,
lex_adv_formula_p,
lex_adv_p,
lex_x_p,
lex_yn_p,
lex_gr_p,
lex_sent_p,
lex_tense_p,
lex_aspect_p,
lex_detformer_p,
litstring_p,
lex_equal_p,
lex_set_of_p,
lex_noun_postmod_macro_p,
lex_np_postmod_macro_p,
lex_noun_or_np_postmod_macro_p,
lex_macro_p,
lex_macro_rel_hole_p,
lex_macro_sub_hole_p,
lex_macro_hole_p,
lex_hole_variable_p,
lex_verbaux_p,
lex_pasv_p,
lex_possessive_s_p,
lex_invertible_verb_p,
lex_comma_p,
lex_elided_p,
surface_token_p,
]
```
### Phrasal match predicates
The following match functions are made available for matching phrasal ULF categories:
```python
PHRASE_PREDS = [
noun_p,
adj_p,
adj_premod_p,
adj_postmod_p,
adv_a_p,
adv_e_p,
adv_s_p,
adv_f_p,
adv_p,
mod_a_p,
mod_n_p,
mod_a_former_p,
mod_n_former_p,
pp_p,
term_p,
verb_p,
pred_p,
det_p,
aux_p,
tensed_aux_p,
tensed_verb_p,
sent_p,
tensed_sent_p,
sent_punct_p,
sent_mod_p,
ps_p,
noun_reifier_p,
verb_reifier_p,
sent_reifier_p,
tensed_sent_reifier_p,
advformer_p,
detformer_p,
modformer_p,
preposs_macro_p,
relativized_sent_p,
p_arg_p,
voc_p,
]
```
### General match predicates
The following additional (uncategorized) match predicates are also defined:
```python
GEN_PREDS = [
plur_term_p,
plur_partitive_p,
plur_noun_p,
plur_lex_noun_p,
pasv_lex_verb_p,
unknown_p,
postmod_p,
postmod_adj_p,
verb_arg_p,
verb_or_tensed_verb_p,
sent_or_sent_mod_p,
sent_or_tensed_sent_p,
phrasal_sent_op_p,
type_shifter_p,
prog_marker_p,
perf_marker_p,
aux_or_head_verb_p,
noun_or_adj_p,
invertible_verb_or_aux_p
]
```
### Search
The following functions can be used to search for the heads of verb phrases, noun phrases, and adjective phrases within a ULF, respectively:
```python
find_vp_head(vp)
find_np_head(np)
find_ap_head(ap)
```
Additionally, the following functions find and replace the heads with some given value `sub`:
```python
replace_vp_head(vp, sub)
replace_np_head(np, sub)
replace_ap_head(ap, sub)
```
The following match functions are also defined (mostly used internally by the above functions):
```python
SEARCH_PREDS = [
marked_conjugated_vp_head_p,
vp_head_p,
np_postmodification_head_p,
ap_premodification_head_p,
ap_postmodification_head_p
]
```
### Suffix
The following functions are defined for manipulating the suffix of a ULF lexical item:
```python
suffix_for_type(x)
"""Return the suffix for the type. If none found, return the type."""
add_suffix(word, suffix)
"""Take a word string and a suffix and merge them together."""
suffix_check(x, suffix)
"""Check if a symbol has the given suffix."""
split_by_suffix(x)
"""Split a symbol by its suffix."""
has_suffix(x)
"""Check if a symbol has a suffix."""
strip_suffix(str)
"""Strips the suffix, marked with '.', from a string, e.g., man.n -> man."""
```
### Macro
The following top-level functions are defined for processing macros in ULFs:
```python
add_info_to_sub_vars(ulf)
"""Add types, pluralization, etc. to the variables *h for sub macros."""
add_info_to_relativizers(ulf)
"""Add pluralization, etc. to the relativizers in relative clauses."""
apply_sub_macro(ulf, fail_on_bad_use=False)
"""Apply a sub macro."""
apply_rep_macro(ulf, fail_on_bad_use=False)
"""Apply a rep macro."""
apply_qt_attr_macro(ulf)
"""Apply a qt_attr macro."""
apply_substitution_macros(ulf)
"""Apply all substitution macros: sub, rep, qt-attr."""
```
### Scoping
The functions within the `scoping` module can be used to scope tense, quantifiers, and coordinated expressions within a ULF formula:
```python
from ulflib import scoping
scoping.scope(ulf)
```
If you wish to scope only a particular type of element (e.g., only tense), a list of keywords can be provided as an optional argument (where each member is `tense`, `quan`, or `coord`):
```python
from ulflib import scoping
scoping.scope(ulf, types=['tense'])
```
Scoping relies on the following rules for determining whether an unscoped element is accessible within an
embedding expression. To be accessible, the unscoped element must not be embedded by:
1. A larger expression binding a variable occurring free in the unscoped element.
2. A sentence modifier other than `not`.
3. A nonsubsective predicate modifier (`not`, `nearly`, ...; however, past/pres generally escape from these contexts).
4. An already scoped quantifier, or already scoped tense operator.
5. An unscoped conjunction or disjunction of sub-expressions.
6. A verbal sub-expression of the ulf, e.g., a subordinate or relative or conjoined verbal clause.
We can recursively use these accessibility rules even when we're no longer looking at a wff -- e.g., if some *part* of a wff contains
a verbal sub-wff, any unscoped elements in that sub-wff are inaccessible at the level of the wff; similarly for unscoped sub-wff
conjunctions/disjunctions, and certain modified and already scoped elements. However, we need to distinguish top-level and embedded candidate extraction, because at the top level extraction of unscoped elements from a clause is *not* blocked.
We don't extract definites or indefinites from scope islands. For definites, this is logically unnecessary (if they pick out
some entity not dependent on variables of embedding quantifiers) and for indefinites we can "raise" them, if necessary, either by
a physical transformation (including the possibility of removing an argument of a Skolem function, if we Skolemize) or by equating
them to an external entity.
Raw data
{
"_id": null,
"home_page": "",
"name": "ulflib",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "",
"author_email": "Benjamin Kane <Ben.Kane@me.com>, Gene Kim <genekim@usf.edu>",
"download_url": "https://files.pythonhosted.org/packages/59/24/5811030ece2efaa03bdee787240a0dcd12340eb84842efd1b895e5bcc4f1/ulflib-0.0.23.tar.gz",
"platform": null,
"description": "# Python ULF Library\n\nPython library for interfacing with and manipulating unscoped episodic logical forms (ULF), based on the [original Common Lisp implementation](https://github.com/genelkim/ulf-lib) by Gene Kim.\n\nAdditional information can be found at the [ULF project page](https://www.cs.rochester.edu/u/gkim21/ulf/).\n\n## Dependencies\n\n* [transduction](https://pypi.org/project/transduction/)\n* [memoization](https://pypi.org/project/memoization/)\n\n## Summary\n\nInstall the package using `pip install ulflib`.\n\nImport the package using the following line.\n\n```python\nfrom ulflib import ulflib\n```\n\n## Documentation\n\n### Lexical match predicates\n\nThe following match functions are made available for matching individual lexical items (intended for use with the [transduction](https://pypi.org/project/transduction/) package). Refer to the [ULF annotation guidelines](https://www.cs.rochester.edu/u/gkim21/ulf/assets/doc/ulf_annotation_guideline_v1.pdf) for additional details on the ULF lexical categories.\n\nUpon importing this package, each lexical match function is registered with the transduction package and can be accessed in transduction rules using the corresponding predicates, e.g., `!lex-noun-p` or `*lex-noun-p`. The negated versions of the predicates are also registered, e.g., `!not-lex-noun-p`.\n\n```python\nLEX_PREDS = [\n lex_noun_p,\n lex_rel_noun_p,\n lex_function_p,\n lex_pronoun_p,\n lex_verb_p,\n lex_adjective_p,\n lex_p_p,\n lex_p_arg_p,\n lex_ps_p,\n lex_pq_p,\n lex_prep_p,\n lex_pp_p,\n lex_mod_a_p,\n lex_mod_n_p,\n lex_mod_p,\n lex_rel_p,\n lex_det_p,\n lex_coord_p,\n lex_aux_s_p,\n lex_aux_v_p,\n lex_aux_p,\n lex_number_p,\n lex_name_p,\n lex_adv_a_p,\n lex_adv_s_p,\n lex_adv_e_p,\n lex_adv_f_p,\n lex_adv_formula_p,\n lex_adv_p,\n lex_x_p,\n lex_yn_p,\n lex_gr_p,\n lex_sent_p,\n lex_tense_p,\n lex_aspect_p,\n lex_detformer_p,\n litstring_p,\n lex_equal_p,\n lex_set_of_p,\n lex_noun_postmod_macro_p,\n lex_np_postmod_macro_p,\n lex_noun_or_np_postmod_macro_p,\n lex_macro_p,\n lex_macro_rel_hole_p,\n lex_macro_sub_hole_p,\n lex_macro_hole_p,\n lex_hole_variable_p,\n lex_verbaux_p,\n lex_pasv_p,\n lex_possessive_s_p,\n lex_invertible_verb_p,\n lex_comma_p,\n lex_elided_p,\n surface_token_p,\n]\n```\n\n\n### Phrasal match predicates\n\nThe following match functions are made available for matching phrasal ULF categories:\n\n```python\nPHRASE_PREDS = [\n noun_p,\n adj_p,\n adj_premod_p,\n adj_postmod_p,\n adv_a_p,\n adv_e_p,\n adv_s_p,\n adv_f_p,\n adv_p,\n mod_a_p,\n mod_n_p,\n mod_a_former_p,\n mod_n_former_p,\n pp_p,\n term_p,\n verb_p,\n pred_p,\n det_p,\n aux_p,\n tensed_aux_p,\n tensed_verb_p,\n sent_p,\n tensed_sent_p,\n sent_punct_p,\n sent_mod_p,\n ps_p,\n noun_reifier_p,\n verb_reifier_p,\n sent_reifier_p,\n tensed_sent_reifier_p,\n advformer_p,\n detformer_p,\n modformer_p,\n preposs_macro_p,\n relativized_sent_p,\n p_arg_p,\n voc_p,\n]\n```\n\n\n### General match predicates\n\nThe following additional (uncategorized) match predicates are also defined:\n\n```python\nGEN_PREDS = [\n plur_term_p,\n plur_partitive_p,\n plur_noun_p,\n plur_lex_noun_p,\n pasv_lex_verb_p,\n unknown_p,\n postmod_p,\n postmod_adj_p,\n verb_arg_p,\n verb_or_tensed_verb_p,\n sent_or_sent_mod_p,\n sent_or_tensed_sent_p,\n phrasal_sent_op_p,\n type_shifter_p,\n prog_marker_p,\n perf_marker_p,\n aux_or_head_verb_p,\n noun_or_adj_p,\n invertible_verb_or_aux_p\n]\n```\n\n\n### Search\n\nThe following functions can be used to search for the heads of verb phrases, noun phrases, and adjective phrases within a ULF, respectively:\n\n```python\nfind_vp_head(vp)\nfind_np_head(np)\nfind_ap_head(ap)\n```\n\nAdditionally, the following functions find and replace the heads with some given value `sub`:\n\n```python\nreplace_vp_head(vp, sub)\nreplace_np_head(np, sub)\nreplace_ap_head(ap, sub)\n```\n\nThe following match functions are also defined (mostly used internally by the above functions):\n\n```python\nSEARCH_PREDS = [\n marked_conjugated_vp_head_p,\n vp_head_p,\n np_postmodification_head_p,\n ap_premodification_head_p,\n ap_postmodification_head_p\n]\n```\n\n\n### Suffix\n\nThe following functions are defined for manipulating the suffix of a ULF lexical item:\n\n```python\nsuffix_for_type(x)\n\"\"\"Return the suffix for the type. If none found, return the type.\"\"\"\n\nadd_suffix(word, suffix)\n\"\"\"Take a word string and a suffix and merge them together.\"\"\"\n\nsuffix_check(x, suffix)\n\"\"\"Check if a symbol has the given suffix.\"\"\"\n\nsplit_by_suffix(x)\n\"\"\"Split a symbol by its suffix.\"\"\"\n\nhas_suffix(x)\n\"\"\"Check if a symbol has a suffix.\"\"\"\n\nstrip_suffix(str)\n\"\"\"Strips the suffix, marked with '.', from a string, e.g., man.n -> man.\"\"\"\n```\n\n\n### Macro\n\nThe following top-level functions are defined for processing macros in ULFs:\n\n```python\nadd_info_to_sub_vars(ulf)\n\"\"\"Add types, pluralization, etc. to the variables *h for sub macros.\"\"\"\n\nadd_info_to_relativizers(ulf)\n\"\"\"Add pluralization, etc. to the relativizers in relative clauses.\"\"\"\n\napply_sub_macro(ulf, fail_on_bad_use=False)\n\"\"\"Apply a sub macro.\"\"\"\n\napply_rep_macro(ulf, fail_on_bad_use=False)\n\"\"\"Apply a rep macro.\"\"\"\n\napply_qt_attr_macro(ulf)\n\"\"\"Apply a qt_attr macro.\"\"\"\n\napply_substitution_macros(ulf)\n\"\"\"Apply all substitution macros: sub, rep, qt-attr.\"\"\"\n```\n\n\n### Scoping\n\nThe functions within the `scoping` module can be used to scope tense, quantifiers, and coordinated expressions within a ULF formula:\n\n```python\nfrom ulflib import scoping\nscoping.scope(ulf)\n```\n\nIf you wish to scope only a particular type of element (e.g., only tense), a list of keywords can be provided as an optional argument (where each member is `tense`, `quan`, or `coord`):\n\n```python\nfrom ulflib import scoping\nscoping.scope(ulf, types=['tense'])\n```\n\nScoping relies on the following rules for determining whether an unscoped element is accessible within an\nembedding expression. To be accessible, the unscoped element must not be embedded by:\n\n1. A larger expression binding a variable occurring free in the unscoped element.\n2. A sentence modifier other than `not`.\n3. A nonsubsective predicate modifier (`not`, `nearly`, ...; however, past/pres generally escape from these contexts).\n4. An already scoped quantifier, or already scoped tense operator.\n5. An unscoped conjunction or disjunction of sub-expressions.\n6. A verbal sub-expression of the ulf, e.g., a subordinate or relative or conjoined verbal clause.\n\nWe can recursively use these accessibility rules even when we're no longer looking at a wff -- e.g., if some *part* of a wff contains\na verbal sub-wff, any unscoped elements in that sub-wff are inaccessible at the level of the wff; similarly for unscoped sub-wff\nconjunctions/disjunctions, and certain modified and already scoped elements. However, we need to distinguish top-level and embedded candidate extraction, because at the top level extraction of unscoped elements from a clause is *not* blocked.\n\nWe don't extract definites or indefinites from scope islands. For definites, this is logically unnecessary (if they pick out\nsome entity not dependent on variables of embedding quantifiers) and for indefinites we can \"raise\" them, if necessary, either by\na physical transformation (including the possibility of removing an argument of a Skolem function, if we Skolemize) or by equating\nthem to an external entity.",
"bugtrack_url": null,
"license": "",
"summary": "A Python port of the Lisp ulflib package by Gene Kim.",
"version": "0.0.23",
"project_urls": {
"Bug Tracker": "https://github.com/bkane2/ulflib-py/issues",
"Homepage": "https://github.com/bkane2/ulflib-py"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cb2e60ff8b1ef645a142701e90b3dfb6e5c7fe547edf5f40d44e64e3f452d62c",
"md5": "0088e1f6d92d06a5e2d81a77fda28a81",
"sha256": "37ec931b65ef665fdd89e9b4a595ec53075589626ae4f91c542d9216255d1b07"
},
"downloads": -1,
"filename": "ulflib-0.0.23-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0088e1f6d92d06a5e2d81a77fda28a81",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 33405,
"upload_time": "2024-01-19T02:39:36",
"upload_time_iso_8601": "2024-01-19T02:39:36.043675Z",
"url": "https://files.pythonhosted.org/packages/cb/2e/60ff8b1ef645a142701e90b3dfb6e5c7fe547edf5f40d44e64e3f452d62c/ulflib-0.0.23-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "59245811030ece2efaa03bdee787240a0dcd12340eb84842efd1b895e5bcc4f1",
"md5": "453dec6747908c7747e2a8671bcc9f24",
"sha256": "97c72c3d29f7b00c2ffde313f2c33049a91e6fffbaa611f85a024ba76dee803c"
},
"downloads": -1,
"filename": "ulflib-0.0.23.tar.gz",
"has_sig": false,
"md5_digest": "453dec6747908c7747e2a8671bcc9f24",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 32044,
"upload_time": "2024-01-19T02:39:37",
"upload_time_iso_8601": "2024-01-19T02:39:37.960314Z",
"url": "https://files.pythonhosted.org/packages/59/24/5811030ece2efaa03bdee787240a0dcd12340eb84842efd1b895e5bcc4f1/ulflib-0.0.23.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-19 02:39:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "bkane2",
"github_project": "ulflib-py",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "transduction",
"specs": []
},
{
"name": "memoization",
"specs": []
}
],
"lcname": "ulflib"
}