from fasthtml.common import * from fasthtml.components import * from plotly import graph_objects as go from fh_plotly import plotly2fasthtml import pandas as pd import json from data_viewer import view_data, gen_random_id from data_viewer import DV, DV2, DVS from rich import print import uuid import plotly.express as px from fasthtml.components import D_code overview = Div( H2("Curated Sources Processing"), H3("What This Section Contains"), P("This section provides a complete discussion on the filtering applied to the 14 curated sources that comprise the non-web data section of TxT360. The section is split into the following topic areas: "), Ul( Li("Curated Sources Data Processing Summary", style = "margin-bottom: 5px"), Li("Individual Filtering Discussion for Each Source", style = "margin-bottom: 5px"), ), ), curated_sources_intro = Div( H2("Curated Sources in TxT360"), P("Curated sources comprise high-quality datasets that contain domain-specificity.", B(" TxT360 was strongly influenced by The Pile regarding both inclusion of the dataset and filtering techniques."), " These sources, such as Arxiv, Wikipedia, and Stack Exchange, provide valuable data that is excluded from the web dataset mentioned above. Analyzing and processing non-web data can yield insights and opportunities for various applications. Details about each of the sources are provided below. "), P("TxT360 respects the copyright of the data sources and have not included the controversial data that was used in The Pile like YouTube and Opensubtitles, Reddit threads, and books."), ) treemap_data = { 'Source': ['ArXiv', 'PubMed Central', 'PubMed Abstract', 'S2ORC Full Text', 'S2ORC Abstract', 'PhilPapers', 'Wikipedia', 'StackExchange', 'EuroParl', 'Ubuntu IRC', 'Freelaw', 'PG19', 'USPTO', 'HackerNews', 'DM Maths'], 'Category': ['Papers', 'Papers', 'Papers', 'Papers', 'Papers', 'Papers', 'Internet', 'Conversational', 'Legal/Formal', 'Conversational', 'Legal/Formal', 'Books', 'Legal/Formal', 'Conversational', 'Reasoning'], 'Count': [100, 200, 150, 120, 80, 90, 300, 250, 180, 150, 150, 250, 180, 120, 90], 'Details': [ 'A repository of scientific papers in various disciplines, including computer science, physics, mathematics, and more.', 'A database of biomedical and life sciences research articles.', 'Abstracts of biomedical literature from various sources.', 'Full-text articles from the Semantic Scholar Open Research Corpus.', 'Abstracts of articles from the Semantic Scholar Open Research Corpus.', 'Papers from the PhilPapers database, a comprehensive index and bibliography of philosophy research.', 'A collaborative online encyclopedia that covers a wide range of topics.', 'A network of question-and-answer websites on various subjects, including programming, science, mathematics, and more.', 'A collection of multilingual parallel corpora of parliamentary debates from the European Parliament.', 'Chat logs from the Ubuntu Internet Relay Chat (IRC) channels.', 'Legal documents and court cases from various jurisdictions.', 'A collection of books from Project Gutenberg, a digital library of public domain works.', 'Patent documents from the United States Patent and Trademark Office.', 'User-generated news and discussion platform focused on technology and startups.', 'Deep Mind Maths dataset with generated questions.' ] } total_count = sum(treemap_data['Count']) treemap_data['Percentage'] = [count / total_count * 100 for count in treemap_data['Count']] fig = px.treemap(treemap_data, path=['Category', 'Source'], values='Count', hover_data=['Details', 'Percentage'], hover_name='Source') treemap_chart = fig #start individual tables showing filterin wikipedia_filter = pd.DataFrame( { "Dataset": [ "Wikipedia", ], "Lines Downloaded": [ "61614907", ], "Percent Removed After Language Filter": [ "0.00%", ], "Percent Removed After Min Word Count Filter": [ "1.86%", ], "Percent Removed After Unigram Probability Filter": [ "0.00%", ], "Percent Removed After Local Dedup": [ "", ], "Total Percentage Remaining": [ "", ], } ) table_html_wikipedia = wikipedia_filter.to_html(index=False, border=0) table_div_wikipedia = Div(NotStr(table_html_wikipedia), style="margin: 40px;") freelaw_filter = pd.DataFrame( { "Dataset": [ "FreeLaw", ], "Lines Downloaded": [ "75971288", ], "Percent Removed After Language Filter": [ "3.00%", ], "Percent Removed After Min Word Count Filter": [ "7.49%", ], "Percent Removed After Unigram Probability Filter": [ "0.07%", ], "Percent Removed After Local Dedup": [ "", ], "Total Percentage Remaining": [ "%", ], } ) table_html_freelaw = freelaw_filter.to_html(index=False, border=0) table_div_freelaw = Div(NotStr(table_html_freelaw), style="margin: 40px;") dmm_filter = pd.DataFrame( { "Dataset": [ "DM Math", ], "Lines Downloaded": [ "112559888", ], "Percent Removed After Language Filter": [ "0.00%", ], "Percent Removed After Min Word Count Filter": [ "0.00%", ], "Percent Removed After Unigram Probability Filter": [ "0.00%", ], "Percent Removed After Local Dedup": [ "", ], "Total Percentage Remaining": [ "%", ], } ) table_html_dmm = dmm_filter.to_html(index=False, border=0) table_div_dmm = Div(NotStr(table_html_dmm), style="margin: 40px;") uspto_filter = pd.DataFrame( { "Dataset": [ "USPTO", ], "Lines Downloaded": [ "6880276", ], "Percent Removed After Language Filter": [ "0.02%", ], "Percent Removed After Min Word Count Filter": [ "1.88%", ], "Percent Removed After Unigram Probability Filter": [ "0.01%", ], "Percent Removed After Local Dedup": [ "", ], "Total Percentage Remaining": [ "%", ], } ) table_html_uspto = uspto_filter.to_html(index=False, border=0) table_div_uspto = Div(NotStr(table_html_uspto), style="margin: 40px;") pg19_filter = pd.DataFrame( { "Dataset": [ "PG-19", ], "Lines Downloaded": [ "28752", ], "Percent Removed After Language Filter": [ "0.24%", ], "Percent Removed After Min Word Count Filter": [ "0.00%", ], "Percent Removed After Unigram Probability Filter": [ "0.17%", ], "Percent Removed After Local Dedup": [ "", ], "Total Percentage Remaining": [ "%", ], } ) table_html_pg19 = pg19_filter.to_html(index=False, border=0) table_div_pg19 = Div(NotStr(table_html_pg19), style="margin: 40px;") hn_filter = pd.DataFrame( { "Dataset": [ "HackerNews", ], "Lines Downloaded": [ "2064931", ], "Percent Removed After Language Filter": [ "2.62%%", ], "Percent Removed After Min Word Count Filter": [ "0.02%", ], "Percent Removed After Unigram Probability Filter": [ "0.34%", ], "Percent Removed After Local Dedup": [ "", ], "Total Percentage Remaining": [ "%", ], } ) table_html_hn = hn_filter.to_html(index=False, border=0) table_div_hn = Div(NotStr(table_html_hn), style="margin: 40px;") uirc_filter = pd.DataFrame( { "Dataset": [ "Ubunutu IRC", ], "Lines Downloaded": [ "37966", ], "Percent Removed After Language Filter": [ "38.10%", ], "Percent Removed After Min Word Count Filter": [ "0.14%", ], "Percent Removed After Unigram Probability Filter": [ "1.12%", ], "Percent Removed After Local Dedup": [ "", ], "Total Percentage Remaining": [ "%", ], } ) table_html_uirc = uirc_filter.to_html(index=False, border=0) table_div_uirc = Div(NotStr(table_html_uirc), style="margin: 40px;") up_filter = pd.DataFrame( { "Dataset": [ "EuroParl", ], "Lines Downloaded": [ "69814", ], "Percent Removed After Language Filter": [ "0.00%", ], "Percent Removed After Min Word Count Filter": [ "0.00%", ], "Percent Removed After Unigram Probability Filter": [ "0.00%", ], "Percent Removed After Local Dedup": [ "", ], "Total Percentage Remaining": [ "%", ], } ) table_html_up = up_filter.to_html(index=False, border=0) table_div_up = Div(NotStr(table_html_up), style="margin: 40px;") se_filter = pd.DataFrame( { "Dataset": [ "StackExchange", ], "Lines Downloaded": [ "23246548", ], "Percent Removed After Language Filter": [ "0.00%", ], "Percent Removed After Min Word Count Filter": [ "0.00%", ], "Percent Removed After Unigram Probability Filter": [ "0.00%", ], "Percent Removed After Local Dedup": [ "", ], "Total Percentage Remaining": [ "%", ], } ) table_html_se = se_filter.to_html(index=False, border=0) table_div_se = Div(NotStr(table_html_se), style="margin: 40px;") arx_filter = pd.DataFrame( { "Dataset": [ "ArXiv", ], "Lines Downloaded": [ "1911867", ], "Percent Removed After Language Filter": [ "2.22%", ], "Percent Removed After Min Word Count Filter": [ "5.65%", ], "Percent Removed After Unigram Probability Filter": [ "0.07%", ], "Percent Removed After Local Dedup": [ "", ], "Total Percentage Remaining": [ "%", ], } ) table_html_arx = arx_filter.to_html(index=False, border=0) table_div_arx = Div(NotStr(table_html_arx), style="margin: 40px;") s2o_filter = pd.DataFrame( { "Dataset": [ "S2ORC", ], "Lines Downloaded": [ "12963563", ], "Percent Removed After Language Filter": [ "0.00%", ], "Percent Removed After Min Word Count Filter": [ "0.00%", ], "Percent Removed After Unigram Probability Filter": [ "0.00%", ], "Percent Removed After Local Dedup": [ "", ], "Total Percentage Remaining": [ "%", ], } ) table_html_s2o = s2o_filter.to_html(index=False, border=0) table_div_s2o = Div(NotStr(table_html_s2o), style="margin: 40px;") med_filter = pd.DataFrame( { "Dataset": [ "PubMed - Central", ], "Lines Downloaded": [ "5230932", ], "Percent Removed After Language Filter": [ "7.66%", ], "Percent Removed After Min Word Count Filter": [ "1.29%", ], "Percent Removed After Unigram Probability Filter": [ "0.02%", ], "Percent Removed After Local Dedup": [ "", ], "Total Percentage Remaining": [ "%", ], } ) table_html_med = med_filter.to_html(index=False, border=0) table_div_med = Div(NotStr(table_html_med), style="margin: 40px;") phil_filter = pd.DataFrame( { "Dataset": [ "Phil Papers", ], "Lines Downloaded": [ "49389", ], "Percent Removed After Language Filter": [ "20.68%", ], "Percent Removed After Min Word Count Filter": [ "0.00%", ], "Percent Removed After Unigram Probability Filter": [ "0.12%", ], "Percent Removed After Local Dedup": [ "", ], "Total Percentage Remaining": [ "%", ], } ) table_html_phil = phil_filter.to_html(index=False, border=0) table_div_phil = Div(NotStr(table_html_phil), style="margin: 40px;") ## end individual tables showing filterin ## start filtered examples wiki_examples = DV("data/curated_samples/wiki.json", 0, "Wikipedia") freelaw_examples = DV2("data/curated_samples/freelaw_raw.json", "data/curated_samples/freelaw_extract.json", 2) se_examples = DV2("data/curated_samples/stackexchange_raw.json", "data/curated_samples/stackexchange_extract.json", 3) phil_examples = DV("data/curated_samples/philpapers_raw.json", 2, "PhilPapers") arx_examples = DV2("data/curated_samples/arxiv_raw.json", "data/curated_samples/arxiv_extract.json", 3) s2o_examples = DV("data/curated_samples/s2orc_raw.json", 0, "S2ORC") s2oa_examples = DV("data/curated_samples/s2orc_abstract_raw.json", 0, "S2ORC Abstract") pubmed_examples = DV2("data/curated_samples/pubmed_raw.json", "data/curated_samples/pubmed_extract.json", 3) dmm_examples = DV2("data/curated_samples/dm_maths_raw.json", "data/curated_samples/dm_maths_extract.json", 3) pg19_examples = DV("data/curated_samples/pg19_raw.json", 0, "PG19") eu_examples = DV("data/curated_samples/europarl_raw.json", 0, "Europarl") ## end filtered examples data_preprocessing_div = Div( H2("Filtering Steps and Definitions"), P("Data preprocessing is a crucial step in the data science pipeline. It involves cleaning and transforming raw data into a format that is suitable for analysis. This process includes handling missing values, normalizing data, encoding categorical variables, and more."), P("The ", B("Language Filter"), " removes documents in unwanted languages. This step improves data quality by removing irrelevant documents."), P("The ", B("Minimum Word Count Filter")," sets a threshold for required words within a document. This step filters out low-quality or incomplete documents. However, this step may remove documents that contain valuable information so a proper analysis is important for each datasource."), P("The ", B("Unigram Log Probability Filter")," calculates the log probability of each unigram to measure the significance of individual words. This step quantifies the importance of individual words but maay not capture the semantic meaning of words."), H3("Data Processing for S2ORC"), P("The formating of the S2ORC dataset required special filters to be applied. These filters were not applied to the other data sources."), P("The ", B("Title Abstract Filter")," extracts information from the title and abstract. This step provides additional information for analysis but may introduce bias in the analysis."), P("The ", B("Majority Language Filter")," identifies the majority language in the dataset. This step displays the distribution of languages in the dataset to enable language-specific analysis and insights."), P("The ", B("Paragraph Count Filter")," counts the number of paragraphs in each document. This step helps to analyze the structure and length of documents which can be a useful hueristic for document complexity."), P("The ",B("Frequency Filter")," calculates the frequency of each word in the dataset. This step serves to identify important words and topics in the dataset but may be sensitive to noise and outliers."), ) # Data for the stacked bar chart data = { 'Filter': ['Downloaded Lines', 'Language Filter', 'Min Word Count', 'Unigram Log Probability'], 'Wikipedia': [61614907, 61614907, 60468491, 60468491], 'Freelaw': [75971288, 73690766, 68171834, 68123174], 'DM Maths': [112559888, 112559888, 112559888, 112559888], 'USPTO': [6880276, 6878964, 6749922, 6749389], 'PG19': [28752, 28683, 28682, 28632], 'Hackernews': [2064931, 2010802, 2010488, 2003636], 'Ubuntu IRC': [37966, 23501, 23468, 23205], 'Europarl': [69814, 69814, 69814, 69814], 'StackExchange': [23246548, 23246548, 23246352, 23246352], 'Arxiv': [1911867, 1869441, 1763840, 1762661], 'S2ORC': [12963563, 12963563, 12963563, 12963563], 'S2ORC Abstract': [102324176, 83867601, 82889293, 82777912], 'Pubmed Central': [5230932, 4830486, 4768310, 4767474], 'Pubmed Abstract': [25787474, 25784374, 25747955, 25746724], 'Phil Papers': [49389, 39175, 39175, 39128] } # Creating a dataframe df = pd.DataFrame(data) # Creating the stacked bar chart fig = go.Figure() # Add trace for each dataset for dataset in df.columns[1:]: fig.add_trace(go.Bar( name=dataset, x=df['Filter'], y=df[dataset] )) # Update the layout fig.update_layout( barmode='stack', title='Document Reduction by Filter for Each Dataset', xaxis_title='Filter', yaxis_title='Number of Lines', legend_title='Dataset', height=600, width=1000 ) # Show the plot diff2_stacked_bar = fig filtering_process = Div( Section( H2("Discussion on Filtering All Curated Sources"), P("Below is a detail recount of how each dataset was extracted and filtered. If specific challenges were found with a dataset, they are included and discussed to the best of our abilities. The figure below provides a global view of the document filtering results. ~8% of documents were removed during these three steps."), plotly2fasthtml(diff2_stacked_bar), H3("This section continues belows with the specific filtering steps taken for all 14 curated datasets."), ), Section( Div( H3("Wikipedia"), P("Wikipedia is an encyclopedia form of high-quality text data used for language modeling. We have included filtered and deduplicated versions of complete Wikipedia data directly provided by the Wikipedia Foundation for more than 350 languages."), P(B("Download and Extraction: "), "The Wikimedia dataset was downloaded from the official snapshot on Huggingface: ", A("https://huggingface.co/datasets/wikimedia/wikipedia/tree/main", href="https://huggingface.co/datasets/wikimedia/wikipedia/tree/main"), ". The", D_code("huggingface dataset.to_json", language="python"), " function was used to convert the original parqet format to the jsonl format."), P(B("Filtering: "), "Manual inspection of the dataset demostrated high quality content. Only one filter was used to remove articles with few words. Based normal sentence constructs, the article was kept if it contained 10 or more words. Any article with fewer than 10 words was removed."), table_div_wikipedia, Details( Summary("Wikipedia Filtering Examples"), Div( wiki_examples, style="background-color: white; padding: 15px; margin-top: 10px; margin-bottom: 10px; border-radius: 8px; border: none; " # Styling for the DV2 part ), style=""" background-color: #FFFAEA; /* Light yellow background */ padding: 15px; border-radius: 12px; margin-bottom: 15px """, ), ), ), Section( Div( H3("ArXiv"), P("The ArXiv dataset is a vast collection of preprint research papers primarily in Mathematics, Computer Science, and Physics. Established in 1991, it offers high-quality text and mathematical knowledge, making it an invaluable resource for academic and scientific research. ArXiv papers are typically written in LaTeX, a popular typesetting system for these fields. We have extracted the information from latex and converted it into a text format."), P(B("Download and Extraction: "),"All the data was downloaded in original latex format from Arxiv official S3 dump ", A("s3://arxic/src", href="s3://arxic/src"), ". We try to encode the downloaded data into utf-8 or guess encoding using chardet library. After that pandoc was used to extract information from the latex files and saved as markdown format", D_code("pandoc -s {tex} -o out/{out_name}.md --wrap=none", language="python"), ". All markdowns were combined to create jsonl files."), H4("Filtering"), P("Multiple filters are used here after manually verifying output of all the filters as suggested by peS2o dataset (citation needed)"), Ol( Li("Language Filter: any language other than English are discarded"), Li("Minimum Word Count Filter: less than 500 words (not inclusive) are discarded"), Li("Unigram Log Probablity Filter: Documents were kept if they their average unigram log probability was higher than -20. To calculate the average log word probability, we use word frequencies extracted from the", A("1T Web-gram corpus", href= "https://catalog.ldc.upenn.edu/LDC2006T13"),". Specifically, we use the list available created by ", A("Rachel Tatman", href="https://www.kaggle.com/datasets/rtatman/english-word-frequency"),"."), Li("Note: The Frequency Filter was calculated but not applied. The most frequent word in the paper consists of alpha characters only, and it appears in less than 7.5% of the document. Words are obtained by splitting the text on whitespace."), ), table_div_arx, Details( Summary("ArXiv Filtering Examples"), Div( arx_examples, style="background-color: white; padding: 15px; margin-top: 10px; margin-bottom: 10px; border-radius: 8px; border: none; " # Styling for the DV2 part ), style=""" background-color: #FFFAEA; /* Light yellow background */ padding: 15px; border-radius: 12px; margin-bottom: 15px """, ), ), ), Section( Div( H3("S2ORC - NEED TO MAKE S2ORC ABSTRACT AND UPDATE THIS FILTERING SECTION"), P("The Semantic Scholar Open Research Corpus (S2ORC) is a comprehensive dataset designed for natural language processing (NLP) and text-mining research over scientific papers. It includes rich metadata, and abstract and full-text content for millions of academic papers across various disciplines. This dataset is further divided into two components, S2ORC abstract and S2ORC full text."), H4("Download and Extraction"), Ol( Li("This was downloaded directly in zip format using S2ORC api key and normal get request. code: response = urllib.request.urlopen(url)"), Li("There were two kind of datasets that was downloaded S2ORC and S2ORC abstract"), ), H4("Filtering - S2ORC"), P("1. Multiple filters are used here after manually verifying output of all the filters as suggested by peS2o dataset"), Ol( Li("title_abstract: must have title and abstract"), Li("The paper must be in English. To determine the language of each document, we use the pycld3 library. We run pycld3 on the first 2000 characters of each paragraph in the paper. The language of the paper is the most common language of the paragraphs."), Li("word_count: less than 500 words (not inclusive) are discarded"), Li("paragraph_count: The paper must have at least 5 paragraphs after removing paragraphs with less than -20 average log world probability"), Li("frequency: The most frequent word in the paper consists of alpha characters only, and it appears in less than 7.5% of the document. Words are obtained by splitting the text on whitespace."), ), H4("Filtering - S2ORC Abstract"), P("1. Multiple filters are used here after manually verifying output of all the filters as suggested by peS2o dataset. The frequency filter was not used as suggested by peS2o because it was removing good samples as inspected manually"), Ol( Li("title_abstract: must have title and abstract"), Li("language: abstract must be in English"), Li("word_count: less than 20 (not inclusive) are discarded"), Li("Unigram log probablity"), Li("frequency: The most frequent word in the paper consists of alpha characters only, and it appears in less than 7.5% of the document. Words are obtained by splitting the text on whitespace."), ), H4("Local Deduplication Process"), Ol( Li("Local dedup was done with all papers combined."), ), H4("Global Deduplication Process"), Ol( Li("This data was part of paper domain which are combined together and minhash was generated and deduped together with all the datasets after doing local dedup"), ), table_div_s2o, Details( Summary("FreeLaw Filtering Examples -- need to update"), Div( freelaw_examples, style="background-color: white; padding: 15px; margin-top: 10px; margin-bottom: 10px; border-radius: 8px; border: none; " # Styling for the DV2 part ), style=""" background-color: #FFFAEA; /* Light yellow background */ padding: 15px; border-radius: 12px; margin-bottom: 15px """, ), ), ), Section( Div( H3("PubMed - need to update with abstract vs central"), P(""), H4("Download and Extraction"), Ol( Li("First all the urls of PMC and PMA files are parsed and stored as text file from FTP server https://ftp.ncbi.nlm.nih.gov/pub/pmc/oa_package/"), Li("All the urls are downloaded and the downloaded data is in xml.tar format"), Li("For pubmed central First tar files are opened using tarfile library and then converted to markdown format using pandoc: pandoc -f jats {nxml} -o {pmcid}.md --wrap=none"), Li("All the markdown files are combined to create jsonl files. In jsonl files, 1 line correspond to 1 markdown file."), Li("For pubmed abstract, the XML files are in very simple format and beautiful soup is directly used to extract the abstract, title and pmid and stored in jsonl format"), ), H4("Filtering"), P("1. Multiple filters are used here after manually verifying output of all the filters as suggested by peS2o dataset."), Ol( Li("min_word: less than 100 words (not inclusive) are discarded, less than 20 words for pubmed abstract"), Li("Language: any language other than English are discarded"), Li("Frequency: The most frequent word in the paper consists of alpha characters only, and it appears in less than 7.5% of the document. Words are obtained by splitting the text on whitespace. This filter is not used for pubmed abstract"), Li("Unigram log probablity: Must have higher than -20 average unigram log probability. To calculate the average log word probability, we use word frequencies extracted from the 1T Web Ngram corpus; specifically, we use the list available created by Rachel Tatman. A copy is hosted here."), Li("need to add the hyperlinks for the section above"), ), H4("Local Deduplication Process"), Ol( Li("Local dedup was done with all papers combined."), ), H4("Global Deduplication Process"), Ol( Li("This data was part of paper domain which are combined together and minhash was generated and deduped together with all the datasets after doing local dedup."), ), table_div_med, Details( Summary("PubMed Filtering Examples"), Div( pubmed_examples, style="background-color: white; padding: 15px; margin-top: 10px; margin-bottom: 10px; border-radius: 8px; border: none; " # Styling for the DV2 part ), style=""" background-color: #FFFAEA; /* Light yellow background */ padding: 15px; border-radius: 12px; margin-bottom: 15px """, ), ), ), Section( Div( H3("Phil Papers"), P("Papers from the PhilPapers database, a comprehensive index and bibliography of philosophy research maintained by the Center for Digital Philosophy at the University of Western Ontario."), P(B("Download and Extraction: "), "Original PDF files download from", A("https://philarchive.org/oai.pl", href="https://philarchive.org/oai.pl"), ". All available PDF's were downloaded. Each PDF was converted to text using java", D_code("-jar ../philpapers_resources/src/pdfbox-app-2.0.21.jar ExtractText {f0} {FOUT.name}", language="java"), ". After converting to text formatting, a language was detected and added using the langdetect (citation needed) library."), H4("Filtering"), Ul( Li(P(B("Hyphenation Removal:"), D_code("end-of", language="python"), " becomes ", D_code("end of", language="python")), style = "margin-bottom: 2px"), Li(P(B("Newline Filtering:"), D_code("This is/na sentence.", language="python"), " becomes ", D_code("This is a sentence.", language="python")), style = "margin-bottom: 2px"), Li(P(B("Header/Footer Filtering:"), D_code("(c) 2023 Company Name.", language="python"), " is removed ",), style = "margin-bottom: 2px"), Li(P(B("Double Whitespace Filtering:"), D_code("This is a test.", language="python"), " becomes ", D_code("This is a test.", language="python")), style = "margin-bottom: 2px"), Li(P(B("Mean Line Length Check: "), "removes paragraphs with an average line length of < 2.0"), style = "margin-bottom: 2px"), Li(P(B("CID Percentage Filter: "), "removes LaTex heavy paragraphs that contain over 10% “CID” font artifacts."), style = "margin-bottom: 2px"), Li(P(B("Letterness Filter: "), "discards paragraphs with a low proportion of letters"), style = "margin-bottom: 2px"), Li(P(B("Removing Leading/Trailing Numbers: "), "removes numbers at the start or end of paragraphs. ", D_code("1 This is a sentence.", language="python"), " becomes ", D_code("This is a sentence.", language="python")), style = "margin-bottom: 2px"), Li(P(B("Fixing Unicode Issues: "), "fixes Unicode issues."), style = "margin-bottom: 2px"), Li(P(B("Combining Diacritics Correction: "), D_code("a'", language="python"), " becomes ", D_code("å", language="python")), style = "margin-bottom: 2px"), Li(P(B("Unigram Log Probability: "), "the document must have higher than -20 average unigram log probability."), style = "margin-bottom: 2px"), ), table_div_phil, Details( Summary("Phil Papers Filtering Examples"), Div( phil_examples, style="background-color: white; padding: 15px; margin-top: 10px; margin-bottom: 10px; border-radius: 8px; border: none; " # Styling for the DV2 part ), style=""" background-color: #FFFAEA; /* Light yellow background */ padding: 15px; border-radius: 12px; margin-bottom: 15px """, ), ), ), Section( Div( H3("Europarl"), P("A collection of multilingual parallel corpora of parliamentary debates from the European Parliament. This is a high-quality legacy dataset earlier used for translation tasks."), P(B("Download and Extraction: "), "Original dataset was downloaded from", A("http://www.statmt.org/europarl/v7/europarl.tgz", href="http://www.statmt.org/europarl/v7/europarl.tgz"),". The files were converted to jsonl lines for filtering."), H4("Filtering"), P("EuroParl was initially filtered during the download process. Documents with fewer than 200 characters were removed. The documents also contained HTML tags which were removed."), D_code(""" Raw single line in data:
Hi I am speaker
After tag removal: P Hi I am speaker
We remove everything that starts with ["P", "BRK", "CHAPTER", "/P"]
and only keep tagnae == SPEAKER
because line starting with