mirror of
https://github.com/wassname/multifit.git
synced 2026-09-09 11:27:26 +08:00
Fix splitting by article for local languages and make it more memory efficient
The issue was that the code assumed that empty lines have space followed by a new line, which isn't the case for datasets generated by our scripts.
This commit is contained in:
@@ -41,15 +41,15 @@ def read_wiki_articles(filename):
|
||||
articles = []
|
||||
with open(filename, encoding='utf8') as f:
|
||||
lines = f.readlines()
|
||||
current_article = ''
|
||||
current_article = []
|
||||
for i,line in enumerate(lines):
|
||||
current_article += line
|
||||
if i < len(lines)-2 and lines[i+1] == ' \n' and istitle(lines[i+2]):
|
||||
articles.append(current_article)
|
||||
current_article = ''
|
||||
articles.append(current_article)
|
||||
current_article.append(line)
|
||||
if i < len(lines)-2 and lines[i+1].strip() == "" and istitle(lines[i+2]):
|
||||
articles.append("".join(current_article))
|
||||
current_article = []
|
||||
articles.append("".join(current_article))
|
||||
print(f"Wiki text was split to {len(articles)} articles")
|
||||
return pd.DataFrame({'texts':np.array(articles)})
|
||||
return pd.DataFrame({'texts': np.array(articles, dtype=np.object)})
|
||||
|
||||
@dataclass
|
||||
class LMHyperParams:
|
||||
|
||||
Reference in New Issue
Block a user