我有条短信。文本具有不同的行号,具体取决于印刷的书籍。我的应用程序也需要这样显示。例如:
B = zeros(iMax,jMax);
for i = 1:iMax
B(i,:) = f(A(i,:),i)';
end
文本需要保存在某个后端的某个地方。我可以逐行保存整个文本:
1 This is a sentence. Here is another. The third sentence 1
2 stretches over multiple lines and is only completed in 2
3 line number 3. Then we have a fourth and fifth sentence, 3
4 but then that's it. That's it. 4
但是,此解决方案也很难看。此外,我正在从事的项目要求我将句子视为工作的基本单位。例如,除了需要在屏幕上渲染文本之外,我经常需要与句子有关的信息,并且几乎从不使用行。假设我需要保存特定句子的单词数。将文本分成句子会更容易:
text = {
{
line_no: 1,
content: "This is a sentence. Here is another. The third sentence",
},
{
line_no: 2,
content: "stretches over multiple lines and is only completed in",
},
etc...};
我正在努力了解如何使用后一种方法(或类似方法),并且仍然将行号保存在某个地方。我将不胜感激这里的一些建议!