-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added universal propositions bank for French and German #1866
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1597,3 +1597,99 @@ def _download_wikiner(language_code: str, dataset_name: str): | |
words = line.split(" ") | ||
for word in words: | ||
out.write("\t".join(word.split("|")) + "\n") | ||
|
||
class UP_GERMAN(ColumnCorpus): | ||
def __init__( | ||
self, | ||
base_path: Union[str, Path] = None, | ||
in_memory: bool = True, | ||
document_as_sequence: bool = False, | ||
): | ||
""" | ||
Initialize the German dataset from the Universal Propositions Bank, comming from that webpage: | ||
https://github.com/System-T/UniversalPropositions. | ||
|
||
:param base_path: Default is None, meaning that corpus gets auto-downloaded and loaded. You can override this | ||
to point to a different folder but typically this should not be necessary. | ||
:param in_memory: If True, keeps dataset in memory giving speedups in training. | ||
:param document_as_sequence: If True, all sentences of a document are read into a single Sentence object | ||
""" | ||
if type(base_path) == str: | ||
base_path: Path = Path(base_path) | ||
|
||
# column format | ||
columns = {1: "text", 9: "frame"} | ||
|
||
# this dataset name | ||
dataset_name = self.__class__.__name__.lower() | ||
|
||
# default dataset folder is the cache root | ||
if not base_path: | ||
base_path = Path(flair.cache_root) / "datasets" | ||
data_folder = base_path / dataset_name | ||
|
||
# download data if necessary | ||
up_de_path = "https://raw.githubusercontent.com/System-T/UniversalPropositions/master/UP_German/" | ||
cached_path(f"{up_de_path}de-up-train.conllu", Path("datasets") / dataset_name) | ||
cached_path(f"{up_de_path}de-up-dev.conllu", Path("datasets") / dataset_name) | ||
cached_path(f"{up_de_path}de-up-test.conllu", Path("datasets") / dataset_name) | ||
|
||
super(UP_GERMAN, self).__init__( | ||
data_folder, | ||
columns, | ||
encoding="utf-8", | ||
train_file="de-up-train.conllu", | ||
test_file="de-up-dev.conllu", | ||
dev_file="de-up-test.conllu", | ||
in_memory=in_memory, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added comment_symbol="#" in both classes, thank you |
||
document_separator_token=None if not document_as_sequence else "-DOCSTART-", | ||
comment_symbol="#", | ||
) | ||
|
||
class UP_FRENCH(ColumnCorpus): | ||
def __init__( | ||
self, | ||
base_path: Union[str, Path] = None, | ||
in_memory: bool = True, | ||
document_as_sequence: bool = False, | ||
): | ||
""" | ||
Initialize the French dataset from the Universal Propositions Bank, comming from that webpage: | ||
https://github.com/System-T/UniversalPropositions. | ||
|
||
:param base_path: Default is None, meaning that corpus gets auto-downloaded and loaded. You can override this | ||
to point to a different folder but typically this should not be necessary. | ||
:param in_memory: If True, keeps dataset in memory giving speedups in training. | ||
:param document_as_sequence: If True, all sentences of a document are read into a single Sentence object | ||
""" | ||
if type(base_path) == str: | ||
base_path: Path = Path(base_path) | ||
|
||
# column format | ||
columns = {1: "text", 9: "frame"} | ||
|
||
# this dataset name | ||
dataset_name = self.__class__.__name__.lower() | ||
|
||
# default dataset folder is the cache root | ||
if not base_path: | ||
base_path = Path(flair.cache_root) / "datasets" | ||
data_folder = base_path / dataset_name | ||
|
||
# download data if necessary | ||
up_fr_path = "https://raw.githubusercontent.com/System-T/UniversalPropositions/master/UP_French/" | ||
cached_path(f"{up_fr_path}fr-up-train.conllu", Path("datasets") / dataset_name) | ||
cached_path(f"{up_fr_path}fr-up-dev.conllu", Path("datasets") / dataset_name) | ||
cached_path(f"{up_fr_path}fr-up-test.conllu", Path("datasets") / dataset_name) | ||
|
||
super(UP_FRENCH, self).__init__( | ||
data_folder, | ||
columns, | ||
encoding="utf-8", | ||
train_file="fr-up-train.conllu", | ||
test_file="fr-up-dev.conllu", | ||
dev_file="fr-up-test.conllu", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
in_memory=in_memory, | ||
document_separator_token=None if not document_as_sequence else "-DOCSTART-", | ||
comment_symbol="#", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is switched: You are loading the dev split as
test_file
and the test split asdev_file
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. Merde. Sorry for that. Such a sloppy work. I am going to fix that in a couple of minutes, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it, thank you!