feat: add a feature to choose where to extract metadata#116
Merged
SaulLu merged 18 commits intobigscience-workshop:masterfrom Dec 23, 2021
Merged
feat: add a feature to choose where to extract metadata#116SaulLu merged 18 commits intobigscience-workshop:masterfrom
SaulLu merged 18 commits intobigscience-workshop:masterfrom
Conversation
SaulLu
commented
Dec 21, 2021
Comment on lines
+548
to
+554
| { | ||
| "char_end_idx": None, | ||
| "char_start_idx": None, | ||
| "relative_end_pos": None, | ||
| "relative_start_pos": None, | ||
| "html_attrs": None, | ||
| "ent_desc": None, |
Collaborator
Author
There was a problem hiding this comment.
Note here that with the datasets library all dictionaries in the lists of a unique column must have the same keys!
SaulLu
commented
Dec 22, 2021
Comment on lines
+325
to
332
| if not example_length: | ||
| continue | ||
| example_metadata.append(example_length) | ||
| elif self.mode == "sentence": | ||
| example_length = self._extract_length_from_sentences(example_text) | ||
| example_metadata.extend(example_length) | ||
| else: | ||
| print("Please select a valid length type [text or sentence].") |
Collaborator
Author
SaulLu
commented
Dec 22, 2021
| # Iterate through the metadata associated with all examples in this batch. | ||
| for example_url, example_metadata in zip(examples[self.col_url], example_metadata_list): | ||
| example_datasource = self._extract_datasource_from_url(example_url) | ||
| print(example_datasource) |
Collaborator
Author
There was a problem hiding this comment.
@chkla , nit, I've removed it (cf this comment)
SaulLu
commented
Dec 22, 2021
Comment on lines
+541
to
+581
| col_to_store_all_metadata = "metadata" | ||
| columns_names_to_concat = [ | ||
| col_to_store_metadata_html, | ||
| col_to_store_metadata_url, | ||
| col_to_store_metadata_timestamp, | ||
| col_to_store_metadata_website_desc, | ||
| col_to_store_metadata_entities, | ||
| col_to_store_metadata_generation_length_text, | ||
| col_to_store_metadata_generation_length_sentence, | ||
| col_to_store_metadata_datasource, | ||
| ] | ||
| concat_columns_fn = concat_columns( | ||
| columns_names_to_concat=columns_names_to_concat, | ||
| new_colum_name=col_to_store_all_metadata, | ||
| ) | ||
| ds = ds.map(concat_columns_fn, batched=True, batch_size=3, remove_columns=columns_names_to_concat) | ||
|
|
||
| for metadata_type in [ | ||
| self.target_metadata_html, | ||
| self.target_metadata_url, | ||
| self.target_metadata_timestamp, | ||
| self.target_metadata_website_desc, | ||
| self.target_metadata_entities, | ||
| self.target_metadata_generation_length_text, | ||
| self.target_metadata_generation_length_sentence, | ||
| self.target_metadata_datasource, | ||
| ]: | ||
| for id, metadata_example in enumerate(metadata_type): | ||
| for metadata in metadata_example: | ||
| for potential_missing_key in [ | ||
| "char_end_idx", | ||
| "char_start_idx", | ||
| "relative_end_pos", | ||
| "relative_start_pos", | ||
| "html_attrs", | ||
| "ent_desc", | ||
| ]: | ||
| if potential_missing_key in metadata: | ||
| continue | ||
| metadata[potential_missing_key] = None | ||
| self.assertIn(metadata, ds[id][col_to_store_all_metadata]) |
Collaborator
Author
There was a problem hiding this comment.
@cccntu , to accompany my answer on slack, here is the part I just added to the tests to show how we can reconcile all the metadata in the same column at the end
chkla
approved these changes
Dec 22, 2021
timoschick
reviewed
Dec 23, 2021
Contributor
timoschick
left a comment
There was a problem hiding this comment.
My review comes a bit late, but I have now taken a look at the UrlPreprocessor and HtmlPreprocessor and everything looks good to me :)
tianjianjiang
added a commit
to tianjianjiang/bigscience-metadata
that referenced
this pull request
Jan 21, 2022
* master: (141 commits) build: bump nltk to 3.6.7 for security and performance (bigscience-workshop#130) build: bump nltk to 3.6.7 for security and performance (#5) Add fp16, multi-GPU training script (toy dataset) (bigscience-workshop#123) create dataset with html, timestamp, url, datasource, generation length and website description metadata and tittles, footers and headers from HTML (bigscience-workshop#119) remove `#SBATCH --gres=gpu:0 ` from `03_create_dataset.slurm` (bigscience-workshop#121) Add joint training slurm script (bigscience-workshop#111) Add features types for the metadata to extract and test multiprocessing (bigscience-workshop#118) feat: add a feature to choose where to extract metadata (bigscience-workshop#116) Use dateutil to parse date (bigscience-workshop#117) feat: change how the entity extraction process use ids (bigscience-workshop#115) add `path_or_url_flair_ner_model` in order to execute the entity extraction on a partition without internet (bigscience-workshop#106) delete old submodule delete ds_store style check style & quality imports handle IndexError for `wikipedia_desc_utils` (bigscience-workshop#102) handle the comment specific type not recognized by pyarrow (bigscience-workshop#83) quality check Change torch version + make it optional (bigscience-workshop#82) ... # Conflicts: # bsmetadata/metadata_utils.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Here is the beginning of the PR discussed in the meeting. This RP includes:
UrlProcessorto extract the url in the same format as the other metadataReady for review:
cc @timoschick (if you can have a more deep review for the
HtmlProcessorandUrlProcessorpart it would be of a great help!)