EasyDict

我尝试整理了下朗文词典的,像这样,有什么结构上的错误吗

还有,这个JSON模板似乎没有变形,这个是词典软件搞定的还是放什么里面?

{
  "dict_id": "simple LDOCE en-en draft v0",
  "entry_id": 16,
  "headword": "answer",
  "headword_normalized": "answer",
  "entry_type": "word",
  "pronunciation": [
    {
      "region": "US",
      "notation": "ˈænsər"
    },
    {
      "region": "UK",
      "notation": "ˈɑːnsə"
    }
  ],
  "sense": [
    {
      "index": 1,
      "label": {
        "grammar": [
          "C,U"
        ],
        "definition": {
          "en": "something you say when you reply to a question that someone has asked you"
        },
        "example": [
          {
            "en": "You don’t have to give them an answer now."
          },
          {
            "en": "Every time I ask him about it, I get a different answer."
          },
          {
            "en": "These are important questions, and we want answers to them."
          },
          {
            "en": "She’s still waiting for an answer from the school."
          },
          {
            "en": "The honest answer was that I didn’t know."
          },
          {
            "en": "He was never able to get a straight answer about why it happened."
          },
          {
            "en": "It’s impossible for me to give you a definite answer at this time."
          },
          {
            "en": "The short answer is that it can’t be done."
          },
          {
            "en": "In answer to your question, yes, you can go."
          },
          {
            "en": "If it’s money you want, the answer is no!"
          }
        ]
      }
    },
    {
      "index": 2,
      "label": {
        "grammar": [
          "C"
        ],
        "definition": {
          "en": "something that you write or say in reply to a question in a test or competition"
        },
        "example": [
          {
            "en": "What was the answer to question 4?"
          },
          {
            "en": "Score two points for each correct answer."
          }
        ]
      }
    },
    {
      "index": 3,
      "label": {
        "grammar": [
          "C"
        ],
        "definition": {
          "en": "a written reply to a letter, invitation, advertisement etc"
        },
        "example": [
          {
            "en": "Did you ever get an answer to your letter?"
          }
        ]
      }
    },
    {
      "index": 4,
      "label": {
        "grammar": [
          "C"
        ],
        "definition": {
          "en": "a way of dealing with a problem"
        },
        "example": [
          {
            "en": "There is no simple answer."
          },
          {
            "en": "The police do not have an answer to rising crime."
          },
          {
            "en": "Some people think cars should be banned from the city, but I don’t think that’s the answer."
          },
          {
            "en": "If he could get a job, it’d be the answer to all his worries."
          }
        ]
      }
    },
    {
      "index": 5,
      "label": {
        "grammar": [
          "singular, U usually in negative"
        ],
        "definition": {
          "en": "if you get an answer when you call someone on the phone, they pick up the phone and talk to you"
        },
        "example": [
          {
            "en": "I tried calling him all day but couldn’t get an answer."
          }
        ]
      }
    },
    {
      "index": 6,
      "label": {
        "grammar": [
          "singular, U usually in negative"
        ],
        "definition": {
          "en": "if you get an answer when you knock on a door, someone opens it and talks to you"
        },
        "example": [
          {
            "en": "I tried knocking on her door, but there was no answer."
          }
        ]
      }
    }
  ]
}
{
  "dict_id": "simple LDOCE en-en draft v0",
  "entry_id": 17,
  "headword": "answer",
  "headword_normalized": "answer",
  "entry_type": "word",
  "sense": [
    {
      "index": 1,
      "label": {
        "grammar": [
          "I,T"
        ],
        "definition": {
          "en": "to say something to someone as a reply when they have asked you a question, made a suggestion etc"
        },
        "example": [
          {
            "en": "She thought for a moment before answering."
          },
          {
            "en": "He still hadn’t answered my question."
          },
          {
            "en": "‘Why don’t you just leave?’ ‘I’d like to,’ she answered, ‘but I have nowhere else to go.’"
          },
          {
            "en": "When questioned, Hughes answered that he knew nothing about the robbery."
          },
          {
            "en": "How much was it? Come on, answer me."
          }
        ]
      }
    },
    {
      "index": 2,
      "label": {
        "grammar": [
          "I,T"
        ],
        "definition": {
          "en": "to write or say the answer to a question in a test or competition"
        },
        "example": [
          {
            "en": "Answer as many questions as possible in the time provided."
          }
        ]
      }
    }
  ]
}

看了下楼主的数据结构定义,其中有个datas这个字段,data本身就是复数单数是datum,不需要加s。
另外楼主似乎没考虑其他语言的词典,比如不支持日语的furigana,就是html用ruby显示。
另外几种语言混合和从右制作不知道能不能正确显示,比如这个:

学习了学习了,等会改掉

这个是不是也可以照葫芦画瓢扩展下

[学](:がく)[習](:しゅう)

这个我查了下,flutter是支持的

不好意思,刚才没看到你的评论
label标签里只要grammar就行,label和definition哪些是并列的
"dict_id"里好像不能有空格
"headword_normalized"不用放entry里,构建db的时候会自己生成
section和page字段是必须的,如果没有,就留空

这是什么意思,apples跳转到apple吗,这是词典统一实现的
以及我有json版的朗文(很新的那种),你有意向转吗

不好意思,刚才没看到你的评论
label标签里只要grammar就行,label和definition哪些是并列的
"dict_id"里好像不能有空格
"headword_normalized"不用放entry里,构建db的时候会自己生成
section和page字段是必须的,如果没有,就留空

这是什么意思,apples跳转到apple吗,这是词典统一实现的
以及我有json版的朗文(很新的那种版本),你有意向转吗

好吧代码一不小心写串了

变形 像这样 (past tense saw /sɔː $ sɒː/, *past participle *seen /siːn/) 或者 固定的结构 是放哪的还是由软件补

这样应该结构没啥毛病了

{
  "dict_id": "simple_LDOCE_en-en_draft_v0",
  "entry_id": 1510,
  "headword": "answer",
  "entry_type": "word",
  "page": "",
  "section": "n",
  "pronunciation": [
    {
      "region": "US",
      "notation": "ˈænsər"
    },
    {
      "region": "UK",
      "notation": "ˈɑːnsə"
    }
  ],
  "sense": [
    {
      "index": 1,
      "label": {
        "grammar": [
          "C,U"
        ]
      },
      "definition": {
        "en": "something you say when you reply to a question that someone has asked you"
      },
      "example": [
        {
          "en": "You don’t have to give them an answer now."
        },
        {
          "en": "Every time I ask him about it, I get a different answer."
        },
        {
          "en": "These are important questions, and we want answers to them."
        },
        {
          "en": "She’s still waiting for an answer from the school."
        },
        {
          "en": "The honest answer was that I didn’t know."
        },
        {
          "en": "He was never able to get a straight answer about why it happened."
        },
        {
          "en": "It’s impossible for me to give you a definite answer at this time."
        },
        {
          "en": "The short answer is that it can’t be done."
        },
        {
          "en": "In answer to your question, yes, you can go."
        },
        {
          "en": "If it’s money you want, the answer is no!"
        }
      ]
    },
    {
      "index": 2,
      "label": {
        "grammar": [
          "C"
        ]
      },
      "definition": {
        "en": "something that you write or say in reply to a question in a test or competition"
      },
      "example": [
        {
          "en": "What was the answer to question 4?"
        },
        {
          "en": "Score two points for each correct answer."
        }
      ]
    },
    {
      "index": 3,
      "label": {
        "grammar": [
          "C"
        ]
      },
      "definition": {
        "en": "a written reply to a letter, invitation, advertisement etc"
      },
      "example": [
        {
          "en": "Did you ever get an answer to your letter?"
        }
      ]
    },
    {
      "index": 4,
      "label": {
        "grammar": [
          "C"
        ]
      },
      "definition": {
        "en": "a way of dealing with a problem"
      },
      "example": [
        {
          "en": "There is no simple answer."
        },
        {
          "en": "The police do not have an answer to rising crime."
        },
        {
          "en": "Some people think cars should be banned from the city, but I don’t think that’s the answer."
        },
        {
          "en": "If he could get a job, it’d be the answer to all his worries."
        }
      ]
    },
    {
      "index": 5,
      "label": {
        "grammar": [
          "singular, U usually in negative"
        ]
      },
      "definition": {
        "en": "if you get an answer when you call someone on the phone, they pick up the phone and talk to you"
      },
      "example": [
        {
          "en": "I tried calling him all day but couldn’t get an answer."
        }
      ]
    },
    {
      "index": 6,
      "label": {
        "grammar": [
          "singular, U usually in negative"
        ]
      },
      "definition": {
        "en": "if you get an answer when you knock on a door, someone opens it and talks to you"
      },
      "example": [
        {
          "en": "I tried knocking on her door, but there was no answer."
        }
      ]
    }
  ]
}

顺便带上代码,由XML转来的,有想搞朗文的可以看看,细节还没完善,原词典结构复杂,有取舍。JSON版的朗文,或许可以发出来让大家看看什么结构,如果规整的话应该不难转;顺便附上词典XML,感兴趣的也可以看

dictXmlToJson.py (5.2 KB)

example_words_xml.zip (18.1 KB)

1 Like

这个没设计放的地方,想着由软件统一实现就可以了
试了下,是可以渲染的。

不知道xml什么样,可以试试多用用data和board元素,我写了不少嵌套适配,应该可以多多少少适配点复杂的格式

软件看上去还是不错的,但如果词典解释里有生词,没有办法点击了解生词的意思,大佬,能不能添加相应的功能?

双击查词zs

data : { 的 key: 对应的可以是什么呀,还有board

都是map对象

:sweat_smile: :sweat_smile: :sweat_smile:

1 Like

更新了1.2.1版本,现在可以直接在搜索框里 查词、拼音查词、通配符查词,还可以勾选高级选项进行大小写区分、简繁区分等。
想日语等应该也是可以通过假名查词的,只要制作词典时phonetic字段里填了相应值。

还有很多细节优化。

2 Likes

开发者功德无量
下载了词库,不知道怎么添加。也没有扫描词库功能。
不知道后面会支持正则表达式全文检索吗?:blush:


这里设置词典根目录

手动添加的话,目录结构为:根目录-每个词典一个文件夹(文件夹名一定要是词典id)-文件夹里是各个文件

不过云服务里加个网址,直接从服务器下载管理最方便,还能获取更新

1 Like

看了下,似乎正则表达式效率不太行?
glob搜索模式应该能覆盖挺多场景的吧

1 Like

好的,谢谢……

哦哦,我研究下,还不太会用

glob是查找文件和路径的吧?
ai所说正则适合匹配文本内容