ccdv commited on
Commit
7b54938
1 Parent(s): 3d9fdd9

remove <S> </S>

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. pubmed-summarization.py +8 -4
README.md CHANGED
@@ -15,7 +15,7 @@ task_ids:
15
 
16
  Dataset for summarization of long documents.\
17
  Adapted from this [repo](https://github.com/armancohan/long-summarization).\
18
- Note that original data are pre-tokenized so this dataset returns " ".join(text).\
19
  This dataset is compatible with the [`run_summarization.py`](https://github.com/huggingface/transformers/tree/master/examples/pytorch/summarization) script from Transformers if you add this line to the `summarization_name_mapping` variable:
20
  ```python
21
  "ccdv/pubmed-summarization": ("article", "abstract")
 
15
 
16
  Dataset for summarization of long documents.\
17
  Adapted from this [repo](https://github.com/armancohan/long-summarization).\
18
+ Note that original data are pre-tokenized so this dataset returns " ".join(text) and add "\n" for paragraphs. \
19
  This dataset is compatible with the [`run_summarization.py`](https://github.com/huggingface/transformers/tree/master/examples/pytorch/summarization) script from Transformers if you add this line to the `summarization_name_mapping` variable:
20
  ```python
21
  "ccdv/pubmed-summarization": ("article", "abstract")
pubmed-summarization.py CHANGED
@@ -68,7 +68,7 @@ class PubMedSummarizationDataset(datasets.GeneratorBasedBuilder):
68
  ),
69
  ]
70
 
71
- DEFAULT_CONFIG_NAME = "document"
72
 
73
  def _info(self):
74
  # Should return a datasets.DatasetInfo object
@@ -118,8 +118,12 @@ class PubMedSummarizationDataset(datasets.GeneratorBasedBuilder):
118
  'sections': List[List[str]]
119
  """
120
  if self.config.name == "document":
121
- article = data["article_text"]
 
122
  else:
123
  article = [item.strip() for sublist in data["sections"] for item in sublist]
124
- abstract = data["abstract_text"]
125
- yield id_, {"article": ' '.join(article), "abstract": ' '.join(abstract)}
 
 
 
 
68
  ),
69
  ]
70
 
71
+ DEFAULT_CONFIG_NAME = "section"
72
 
73
  def _info(self):
74
  # Should return a datasets.DatasetInfo object
 
118
  'sections': List[List[str]]
119
  """
120
  if self.config.name == "document":
121
+ article = [d.strip() for d in data["article_text"]]
122
+ article = " ".join(article)
123
  else:
124
  article = [item.strip() for sublist in data["sections"] for item in sublist]
125
+ article = " \n ".join(article)
126
+
127
+ abstract = [ab.replace("<S>", "").replace("</S>", "").strip() for ab in data["abstract_text"]]
128
+ abstract = " \n ".join(abstract)
129
+ yield id_, {"article": article, "abstract": abstract}