raannakasturi commited on
Commit
72c7a0a
·
1 Parent(s): ba2b457

Refactor title and citation encoding in paper_data and test functions for improved handling of special characters

Browse files
Files changed (2) hide show
  1. main.py +10 -1
  2. post_blog.py +12 -2
main.py CHANGED
@@ -30,7 +30,16 @@ def paper_data(paper_data, wait_time=5):
30
  print(f"Skipping paper with ID: {paper_id} (summary/mindmap not found)")
31
  continue
32
  try:
33
- title = html.escape(title.encode('unicode-escape').decode().replace('\\\\', '\\'))
 
 
 
 
 
 
 
 
 
34
  post_blog(title, category, summary, mindmap, citation, access_key, wait_time)
35
  except Exception as e:
36
  print(f"Error posting blog '{title}': {e}")
 
30
  print(f"Skipping paper with ID: {paper_id} (summary/mindmap not found)")
31
  continue
32
  try:
33
+ try:
34
+ escaped_title = repr(title.encode('latin1').decode('unicode-escape')).strip()
35
+ except:
36
+ escaped_title = repr(title).strip()
37
+ title = html.escape(str(escaped_title).strip()[1:-1])
38
+ try:
39
+ encoded_bytes = citation.encode('latin1').decode('utf-8', errors='replace')
40
+ except:
41
+ encoded_bytes = repr(citation)
42
+ citation = html.unescape(encoded_bytes)
43
  post_blog(title, category, summary, mindmap, citation, access_key, wait_time)
44
  except Exception as e:
45
  print(f"Error posting blog '{title}': {e}")
post_blog.py CHANGED
@@ -153,7 +153,7 @@ def test(uaccess_key):
153
  "2412.16344": {
154
  "id": "2412.20276",
155
  "doi": "https://doi.org/10.48550/arXiv.2412.20276",
156
- "title": "Demographics of black holes at $<$100 R$_{\\rm g}$ scales: accretion flows, jets, and shadows",
157
  "category": "Astrophysics",
158
  "citation": "Nair, D. G., Nagar, N. M., Ramakrishnan, V., Wielgus, M., Arratia, V., Krichbaum, T. P., Zhang, X. A., Ricarte, A., S., S., Hernández-Yévenes, J., Ford, N. M., Bandyopadhyay, B., Gurwell, M., Burridge, R., Pesce, D. W., Doeleman, S. S., Kim, J.-Y., Kim, D., Janssen, M., … Zensus, J. A. (2024). Demographics of black holes at $<$100 R$_{\\rm g}$ scales: accretion flows, jets, and shadows (Version 1). arXiv. https://doi.org/10.48550/ARXIV.2412.20276",
159
  "summary": "## Summary\nThe Event Horizon Telescope (EHT) has imaged supermassive black holes (SMBHs) in M87 and Sgr A*, testing General Relativity and constraining black hole mass. The EHT has also imaged inner jets of several SMBHs, but at coarser resolutions than 100 Rg. The \"Event Horizon and Environs\" (ETHER) sample is a comprehensive database of SMBH mass estimates, radio to hard X-ray flux densities, and spectral energy distribution information.\n\n## Highlights\n- The EHT has imaged SMBH shadows in M87 and Sgr A*, testing General Relativity and constraining black hole mass.\n- The EHT has imaged the inner jets of several SMBHs, but at coarser resolutions than 100 Rg.\n- The ETHER sample is a comprehensive database of SMBH mass estimates, radio to hard X-ray flux densities, and spectral energy distribution information.\n- The ETHER database includes predictions for the 230 GHz and 345 GHz flux densities in the EHT field of view for approximately 40,000 SMBHs.\n- The 43 GHz VLBA is the highest frequency sensitive phase-referenced VLBI network, providing valuable constraints for SED modeling.\n- The ngEHT is expected to measure approximately 50 SMBH masses, 30 SMBH spins, and 7 SMBH shadows.\n- The ngEHT will enable demographic studies of SMBHs, testing General Relativity and constraining black hole mass.\n\n## Key Insights\n- The EHT's ability to image SMBH shadows and inner jets has opened a new window into understanding these enigmatic objects, allowing for tests of General Relativity and constraints on black hole mass.\n- The ETHER sample provides a comprehensive database for identifying and optimizing target selection for the EHT and its upgrades, enabling the identification of a \"Gold Sample\" of nearby low-luminosity Active Galactic Nuclei (AGNs) optimal for studying jet bases and potentially imaging black hole shadows.\n- The ngEHT will enable the measurement of approximately 50 SMBH masses, 30 SMBH spins, and 7 SMBH shadows, providing a significant increase in the number of SMBHs that can be studied in detail.\n- The 43 GHz VLBA provides valuable constraints for SED modeling, allowing for the prediction of EHT flux densities and the identification of optimal targets for EHT observations.\n- The ETHER database includes predictions for the 230 GHz and 345 GHz flux densities in the EHT field of view for approximately 40,000 SMBHs, enabling the identification of potential targets for EHT observations.\n- The ngEHT will enable demographic studies of SMBHs, testing General Relativity and constraining black hole mass, and providing insights into the properties of these enigmatic objects.\n- The EHT's ability to image SMBH shadows and inner jets has significant implications for our understanding of these objects and the role they play in the universe, and will continue to be an important area of research in the coming years.",
@@ -167,12 +167,22 @@ def test(uaccess_key):
167
  for category, catdata in data.items():
168
  if category != 'status':
169
  for paper_id, paperdata in catdata.items():
170
- title = html.escape(paperdata['title'].encode('unicode-escape').decode().replace('\\\\', '\\'))
171
  category = paperdata['category']
172
  summary = paperdata.get('summary', '')
173
  mindmap = paperdata.get('mindmap', '')
174
  citation = paperdata.get('citation', '')
175
  uaccess_key = access_key
 
 
 
 
 
 
 
 
 
 
176
  status = post_blog(title, category, summary, mindmap, citation, uaccess_key, 0)
177
  print(status)
178
  return status
 
153
  "2412.16344": {
154
  "id": "2412.20276",
155
  "doi": "https://doi.org/10.48550/arXiv.2412.20276",
156
+ "title": "From Painlev\xe9 equations to ${\cal N}=2$ susy gauge theories: prolegomena",
157
  "category": "Astrophysics",
158
  "citation": "Nair, D. G., Nagar, N. M., Ramakrishnan, V., Wielgus, M., Arratia, V., Krichbaum, T. P., Zhang, X. A., Ricarte, A., S., S., Hernández-Yévenes, J., Ford, N. M., Bandyopadhyay, B., Gurwell, M., Burridge, R., Pesce, D. W., Doeleman, S. S., Kim, J.-Y., Kim, D., Janssen, M., … Zensus, J. A. (2024). Demographics of black holes at $<$100 R$_{\\rm g}$ scales: accretion flows, jets, and shadows (Version 1). arXiv. https://doi.org/10.48550/ARXIV.2412.20276",
159
  "summary": "## Summary\nThe Event Horizon Telescope (EHT) has imaged supermassive black holes (SMBHs) in M87 and Sgr A*, testing General Relativity and constraining black hole mass. The EHT has also imaged inner jets of several SMBHs, but at coarser resolutions than 100 Rg. The \"Event Horizon and Environs\" (ETHER) sample is a comprehensive database of SMBH mass estimates, radio to hard X-ray flux densities, and spectral energy distribution information.\n\n## Highlights\n- The EHT has imaged SMBH shadows in M87 and Sgr A*, testing General Relativity and constraining black hole mass.\n- The EHT has imaged the inner jets of several SMBHs, but at coarser resolutions than 100 Rg.\n- The ETHER sample is a comprehensive database of SMBH mass estimates, radio to hard X-ray flux densities, and spectral energy distribution information.\n- The ETHER database includes predictions for the 230 GHz and 345 GHz flux densities in the EHT field of view for approximately 40,000 SMBHs.\n- The 43 GHz VLBA is the highest frequency sensitive phase-referenced VLBI network, providing valuable constraints for SED modeling.\n- The ngEHT is expected to measure approximately 50 SMBH masses, 30 SMBH spins, and 7 SMBH shadows.\n- The ngEHT will enable demographic studies of SMBHs, testing General Relativity and constraining black hole mass.\n\n## Key Insights\n- The EHT's ability to image SMBH shadows and inner jets has opened a new window into understanding these enigmatic objects, allowing for tests of General Relativity and constraints on black hole mass.\n- The ETHER sample provides a comprehensive database for identifying and optimizing target selection for the EHT and its upgrades, enabling the identification of a \"Gold Sample\" of nearby low-luminosity Active Galactic Nuclei (AGNs) optimal for studying jet bases and potentially imaging black hole shadows.\n- The ngEHT will enable the measurement of approximately 50 SMBH masses, 30 SMBH spins, and 7 SMBH shadows, providing a significant increase in the number of SMBHs that can be studied in detail.\n- The 43 GHz VLBA provides valuable constraints for SED modeling, allowing for the prediction of EHT flux densities and the identification of optimal targets for EHT observations.\n- The ETHER database includes predictions for the 230 GHz and 345 GHz flux densities in the EHT field of view for approximately 40,000 SMBHs, enabling the identification of potential targets for EHT observations.\n- The ngEHT will enable demographic studies of SMBHs, testing General Relativity and constraining black hole mass, and providing insights into the properties of these enigmatic objects.\n- The EHT's ability to image SMBH shadows and inner jets has significant implications for our understanding of these objects and the role they play in the universe, and will continue to be an important area of research in the coming years.",
 
167
  for category, catdata in data.items():
168
  if category != 'status':
169
  for paper_id, paperdata in catdata.items():
170
+ title = paperdata['title']
171
  category = paperdata['category']
172
  summary = paperdata.get('summary', '')
173
  mindmap = paperdata.get('mindmap', '')
174
  citation = paperdata.get('citation', '')
175
  uaccess_key = access_key
176
+ try:
177
+ escaped_title = repr(title.encode('latin1').decode('unicode-escape')).strip()
178
+ except:
179
+ escaped_title = repr(title).strip()
180
+ title = html.escape(str(escaped_title).strip()[1:-1])
181
+ try:
182
+ encoded_bytes = citation.encode('latin1').decode('utf-8', errors='replace')
183
+ except:
184
+ encoded_bytes = repr(citation)
185
+ citation = html.unescape(encoded_bytes)
186
  status = post_blog(title, category, summary, mindmap, citation, uaccess_key, 0)
187
  print(status)
188
  return status