2

我有 .rtf 格式的塞尔维亚英语单词,我需要从这个文档中提取它并将它们放入一些数据结构中。我知道使用数据库,但我不知道它是否适合这种情况。例如,我有斜体字,不知道如何将其放入数据库(也许放入标签?)。是否有其他用于存储格式化文本(粗体和斜体)的数据结构?

4

2 回答 2

1

this depends if the whole text is underlined/italic or just some parts. If the whole text is underlined/italic you could add two columns like "is_bold" and "is_italic" to your database table. Otherwise I'd suggest some kind of markup (HTML Tags or Markdown). I focused on the database solution because I assume that you want to store this dictionary persistently.

Greetings

Simon

于 2011-03-05T01:21:18.773 回答
1

这取决于您在数据库中需要的粒度。你能根据格式的含义定义一个一致的数据模型吗?

class Entry {
    String serbianWord;
    String serbianPhonetic;
    String serbianOtherElementOfDictionary;
    String englishWord;
    String englishPhonetic;
    String englishOtherElementOfDictionary;
}

理想情况下,格式(视图)和数据库(模型)应该分开。

但是,如果这会使手头的问题变得过于复杂,那么存储标记数据是一个合理的选择。

于 2011-03-05T08:16:02.503 回答