5

Is there a way to check if a string represents an English sentence? I am currently looking at java packages but I cannot find anything that does it yet.

i.e.

the weather is good (valid)
the good is weather (invalid) 

Any ideas?

Thanks

user1663930
  • 295
  • 2
  • 5
  • 12

2 Answers2

1

What you really need is NLP parser (grammatical analysis).

This one is written in Java and it is fantastic.

nullpotent
  • 9,162
  • 1
  • 31
  • 42
0

While I realize the OP referenced Java, I will offer that the MS Office suite has a limited grammar checking engine that is intended to perform very top-level corrections/suggestions for what I would imagine is a fairly simplified set of sentence patterns it recognizes, eg, those found in typical office correspondence. I don't think it pretends to be exhaustive or anything like a full English analysis tool, but it might serve the basic purpose in a limited form.

The check is exposed through COM via the CheckGrammar method, which is called from the Application object of the host Office application. You supply the text to be checked. It can identify several problems in addition to fragments, such as tense and number disagreements, so you might have to refine the results it offers. It's far from perfect, but does give it the old college try :)

David W
  • 10,062
  • 34
  • 60