Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read xml file from goldbook.iupac.org #355

Closed
dthirst opened this issue Jan 22, 2022 · 5 comments
Closed

Read xml file from goldbook.iupac.org #355

dthirst opened this issue Jan 22, 2022 · 5 comments
Labels

Comments

@dthirst
Copy link

dthirst commented Jan 22, 2022

Hi!

I tried converting an xml dictionary into stardict with the CLI, but get hit with this exception every time:

unhandled exception:
Traceback (most recent call last):
  File "/Users/USERNAME/src/pyglossary/pyglossary/ui/ui_cmd_interactive.py", line 1016, in run
    succeed = ui_cmd.UI.run(self, **self.getRunKeywordArgs())
  File "/Users/USERNAME/src/pyglossary/pyglossary/ui/ui_cmd.py", line 331, in run
    finalOutputFile = self.glos.convert(
  File "/Users/USERNAME/src/pyglossary/pyglossary/glossary.py", line 1323, in convert
    if not self.read(
  File "/Users/USERNAME/src/pyglossary/pyglossary/glossary.py", line 846, in read
    reader = self._createReader(format, options)
  File "/Users/USERNAME/src/pyglossary/pyglossary/glossary.py", line 733, in _createReader
    reader = self.plugins[format].readerClass(self)
  File "/Users/USERNAME/src/pyglossary/pyglossary/plugins/wiktionary_dump.py", line 38, in __init__
    self.compilePatterns()
  File "/Users/USERNAME/src/pyglossary/pyglossary/plugins/wiktionary_dump.py", line 121, in compilePatterns
    self._re_comment = re.compile(
TypeError: compile() takes from 1 to 2 positional arguments but 3 were given

Best,

@ilius
Copy link
Owner

ilius commented Jan 22, 2022

What kind of XML dictionary?
There are several formats that use XML.
Is it for Wikimedia dumps?
Or Apple Dictionary source format?

@ilius ilius changed the title Conversion from xml to ifo fails: compile() takes from 1 to 2 positional arguments but 3 were given Conversion from xml to ifo fails Jan 22, 2022
@dthirst
Copy link
Author

dthirst commented Jan 23, 2022

Thank you for your swift reply and attempt to fix the bug!
I honestly don't know what standard the file in question adheres to, I got it from here and they only state that it is in XML format: https://goldbook.iupac.org/
I pulled the commit you referenced, unfortunately I am met with another exception:

[INFO] Automatically switching to SQLite mode for writing Stardict
[INFO] fileSize = 7011746
unhandled exception:
Traceback (most recent call last):
  File "/Users/USERNAME/src/pyglossary/pyglossary/glossary.py", line 902, in _read
    reader.open(filename)
  File "/Users/USERNAME/src/pyglossary/pyglossary/plugins/wiktionary_dump.py", line 65, in open
    siteinfoBytes = self._readSiteInfo()
  File "/Users/USERNAME/src/pyglossary/pyglossary/plugins/wiktionary_dump.py", line 49, in _readSiteInfo
    siteinfoBytes = self._buff + b"</siteinfo>"
TypeError: unsupported operand type(s) for +: 'NoneType' and 'bytes'

[CRITICAL] Reading file '/Users/demian/Downloads/goldbook_vocab.xml' failed.

@ilius ilius changed the title Conversion from xml to ifo fails Read xml file from goldbook.iupac.org Jan 23, 2022
@ilius
Copy link
Owner

ilius commented Jan 23, 2022

This format is not supported.

@ilius ilius added the Feature label Jan 23, 2022
@dthirst
Copy link
Author

dthirst commented Jan 23, 2022

I understand, thank you.

@ilius
Copy link
Owner

ilius commented Mar 2, 2022

I added support.
If using command line, you need to pass --read-format IUPACGoldbook.

@ilius ilius closed this as completed Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants