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

BGL > Json : Keys with two or more values #344

Closed
shahram7 opened this issue Dec 2, 2021 · 10 comments
Closed

BGL > Json : Keys with two or more values #344

shahram7 opened this issue Dec 2, 2021 · 10 comments
Labels

Comments

@shahram7
Copy link

shahram7 commented Dec 2, 2021

Hi Ilius,
I hope you're doing well.
I've recently noticed, that the JSON file that I converted from BGL 10 months ago doesn't have all entries.
I think it's because my BGL Glossary has more Values for some Keys. (one Value for each each part of speech (noun, adj or verb) ) and in JSON File it's going to be overwritten by last Value.
Is there a solution to append new values to the first value?
Best Regards
thanks in advance dadash

@ilius
Copy link
Owner

ilius commented Dec 2, 2021

Please try converting again.

@ilius ilius closed this as completed Dec 2, 2021
@ilius ilius added the Bug label Dec 2, 2021
@shahram7
Copy link
Author

shahram7 commented Dec 2, 2021

thanks alot

@shahram7
Copy link
Author

shahram7 commented Dec 3, 2021

Hi Ilius,
after I've cloned the latest state I get this error by converting from bgl to json

[INFO] Writing to Json file 'C:\\pyglossary\\Eng_Ger.json'
[INFO] Using Reader class from BabylonBgl plugin for direct conversion without loading into memory
[ERROR] Exception while calling plugin's write function
Traceback (most recent call last):
  File "C:\pyglossary\glossary.py", line 1217, in write
    for entry in self:
  File "C:\pyglossary\glossary.py", line 425, in _readersEntryGen
    for index, entry in enumerate(self._applyEntryFiltersGen(reader)):
  File "C:\pyglossary\glossary.py", line 440, in _applyEntryFiltersGen
    entry = entryFilter.run(entry, index)
  File "C:\pyglossary\entry_filters.py", line 295, in run
    entry._word = word
AttributeError: 'DataEntry' object has no attribute '_word'
Traceback (most recent call last):
  File "C:\pyglossary\glossary.py", line 1217, in write
    for entry in self:
  File "C:\pyglossary\glossary.py", line 425, in _readersEntryGen
    for index, entry in enumerate(self._applyEntryFiltersGen(reader)):
  File "C:\pyglossary\glossary.py", line 440, in _applyEntryFiltersGen
    entry = entryFilter.run(entry, index)
  File "C:\pyglossary\entry_filters.py", line 295, in run
    entry._word = word
AttributeError: 'DataEntry' object has no attribute '_word'


[ERROR] Writing file 'C:/pyglossary/Eng_Ger.json' failed.

Am I doing something wrong?

@ilius ilius reopened this Dec 3, 2021
ilius added a commit that referenced this issue Dec 3, 2021
@ilius
Copy link
Owner

ilius commented Dec 3, 2021

Please try again.

@shahram7
Copy link
Author

shahram7 commented Dec 4, 2021

thank you it's working again :)

@ilius ilius closed this as completed Dec 4, 2021
@shahram7
Copy link
Author

shahram7 commented Dec 4, 2021

Hi Ilius, The Values in converted json file are still getting overwritten and that Problem remained unsolved. I attach my BGL file here. You can surely find the reason easier.
Eng_Ger.zip

@ilius
Copy link
Owner

ilius commented Dec 4, 2021

Which keys ae overwritten?

Maybe I should have explained.
Look up keys "Bar", "Bar (2)", "Bar (3)", "Bar (4)" for example.
We just add a number like that to keys that have been used in previous entries.
We don't modify the values.

Also JSON is probably not a good format to convert BGL files because it doesn't support alternative word lookup when you load them (they are separated by | in our json). Unless you create your own index (or lookup table), which is kinda against the point of using json.

@shahram7
Copy link
Author

shahram7 commented Dec 4, 2021

for instance i have following HTML code for that word "object" in my json file.

object<SUP>2</SUP><br><br><DIV style="margin-top : 3px"></DIV><FONT color="#3333CC" size="2.5"><B>object</SUP></B></FONT> [<FONT face="lucida sans unicode">ɒ</FONT>b'<IMG src="2F89DD93.bmp" align="center" width="12" height="15">ekt] <DIV style="margin-top : 3px"></DIV><TABLE cellpadding="3" cellspacing="0" border="0"> <TR valign="top"><TD nowrap="nowrap" style="vertical-align:top"><STRONG> I </STRONG></TD><TD> <FONT color="#3333CC">intransitive verb</FONT><BR></TD></TR></TABLE><TABLE cellpadding="3" cellspacing="0" border="0"> <TR valign="top"><TD nowrap="nowrap" style="vertical-align:top"><STRONG> <IMG src="A4F2AA15.bmp" align="absmiddle" width="17" height="17"> </STRONG></TD><TD> <FONT color="#33CC66"><I>(oppose, disapprove)</I></FONT> dagegen sein; <FONT color="#33CC66"><I>(mind, dislike)</I></FONT> etwas dagegen haben; <IMG src="00CE26A7.bmp" align="absmiddle" width="8" height="8"> <B><FONT color="#663300">to object to something</FONT></B> <FONT color="#33CC66"><I>(oppose, disapprove)</I></FONT> gegen etwas <FONT color="#990033"><B><I>accusative</I></B></FONT> sein; <FONT color="#33CC66"><I>(dislike, mind)</I></FONT> etwas gegen etwas <FONT color="#990033"><B><I>accusative</I></B></FONT> haben; <FONT color="#33CC66"><I>(stronger)</I></FONT> sich <FONT color="#990033"><B><I>dative</I></B></FONT> etwas verbitten </TD></TR><TR valign="top"><TD nowrap="nowrap" style="vertical-align:top"><STRONG> <IMG src="DB565468.bmp" align="absmiddle" width="17" height="17"> </STRONG></TD><TD> <FONT color="#33CC66"><I>(protest)</I></FONT> protestieren </TD></TR><TR valign="top"><TD nowrap="nowrap" style="vertical-align:top"><STRONG> II </STRONG></TD><TD> <FONT color="#3333CC">transitive verb</FONT><BR>einwenden </TD></TR></TABLE>

I've been using the Json files in my Python script to create flashcards.
to which Format shall I convert my BGLs in order to be able to read them in python?

thanks in advance

@ilius
Copy link
Owner

ilius commented Dec 4, 2021

You can use Tabfile or CSV that are easy to parse.
Either way, you gotta create your own lookup HashTable (dict) in memory to look up words.

@shahram7
Copy link
Author

shahram7 commented Dec 4, 2021

thanks bro <3

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