查找句子边界的 Java 库

发布于 2024-07-12 06:11:04 字数 952 浏览 9 评论 0原文

有谁知道有一个 Java 库可以处理查找句子边界吗? 我认为这将是一个智能 StringTokenizer 实现,它知道语言可以使用的所有句子终止符。

以下是我使用 BreakIterator 的经验:

使用此处的示例: 我有以下日语:

今日はパソコンを買った。高性能のマックは早い!とても快適です。

在 ascii 中,它看起来像这样:

\ufeff\u4eca\u65e5\u306f\u30d1\u30bd\u30b3\u30f3\u3092\u8cb7\u3063\u305f\u3002\u9ad8\u6027\u80fd\u306e\u30de\u30c3\u30af\u306f\u65e9\u3044\uff01\u3068\u3066\u3082\u5feb\u9069\u3067\u3059\u3002

这是我更改的示例部分: static void SentenceExamples() {

  Locale currentLocale = new Locale ("ja","JP");
  BreakIterator sentenceIterator = 
     BreakIterator.getSentenceInstance(currentLocale);
  String someText = "今日はパソコンを買った。高性能のマックは早い!とても快適です。";

当我查看边界索引时,我看到了这一点:

0|13|24|32

但这些索引不对应于任何句子终止符。

Does anyone know of a Java library that handles finding sentence boundaries? I'm thinking that it would be a smart StringTokenizer implementation that knows about all of the sentence terminators that languages can use.

Here's my experience with BreakIterator:

Using the example here:
I have the following Japanese:

今日はパソコンを買った。高性能のマックは早い!とても快適です。

In ascii, it looks like this:

\ufeff\u4eca\u65e5\u306f\u30d1\u30bd\u30b3\u30f3\u3092\u8cb7\u3063\u305f\u3002\u9ad8\u6027\u80fd\u306e\u30de\u30c3\u30af\u306f\u65e9\u3044\uff01\u3068\u3066\u3082\u5feb\u9069\u3067\u3059\u3002

Here's the part of that sample that I changed:
static void sentenceExamples() {

  Locale currentLocale = new Locale ("ja","JP");
  BreakIterator sentenceIterator = 
     BreakIterator.getSentenceInstance(currentLocale);
  String someText = "今日はパソコンを買った。高性能のマックは早い!とても快適です。";

When I look at the Boundary indices, I see this:

0|13|24|32

But those indices don't correspond to any sentence terminators.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

許願樹丅啲祈禱 2024-07-19 06:11:04

您想要研究国际化的 BreakIterator 类。 句子边界的一个很好的起点。

You want to look into the internationalized BreakIterator classes. A good starting point for sentence boundaries.

2024-07-19 06:11:04

你写了:

我认为这将是一个智能 StringTokenizer 实现,它知道语言可以使用的所有句子终止符。

这里的一个基本问题是句子终止符取决于上下文,请考虑:

琼斯博士是如何计算出 5 的! 没有递归?

这应该被识别为单个句子,但如果您只是拆分可能的句子终止符,您将得到三个句子。

所以这是一个比人们一开始想象的更复杂的问题。 可以使用机器学习技术来实现它。 例如,您可以查看 OpenNLP 项目,特别是 SentenceDetectorME 类。

You wrote:

I'm thinking that it would be a smart StringTokenizer implementation that knows about all of the sentence terminators that languages can use.

A basic problem here is that sentence terminators depend on the context, consider:

How did Dr. Jones compute 5! without recursion?

This should be recognized as a single sentence, but if you just split on possible sentence terminators you will get three sentences.

So this is a more complex problem than one might think in the beginning. It can be approached using machine learning techniques. You could for instance look into the OpenNLP project, in particular the SentenceDetectorME class.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文