Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Having this sentence (consider many sentences in the future)

David Henderson Houston patented the first roll film for cameras in 1881.

I can make questions like
1. Who patented the roll film?
2. When was the first roll film for cameras patented?
3. What did David Houston patent (in 1881)?

The answer will return some or all of the sentence above in a format of answering the who, when and what.

My question (and what I am trying to achieve) is to separate this sentence in such a way that I can save it in a DB, smartly and efficiently.

I thought of editing this sentence leaving only the main keywords/facts; let's say David Houston patented the roll film in 1881.

After this, I thought I have to organize the words. So a solution may be to create tables for nouns, verbs, adjectives... separating the sentence in the correct table. Every word will have its unique ID.

In the table answers, the answer will be saved in a form like 2,23,64,4 every ID is a word... and with some agorithm and sql magic (this is not my point now) it will return the David Houston patented the roll film in 1881 on the question who.

What do you think of my thinking of separating the sentences like I wrote above? What are your thoughts on how I should organize the words to access them through a database? Am I entirely off the correct path?

share|improve this question

migrated from stackoverflow.com Oct 12 '11 at 1:54

This question came from our site for professional and enthusiast programmers.

1  
Your question basically comes down to: "How do I design an ontology?" You might want to read some of the existing papers on the subject. –  Jerry Coffin Oct 11 '11 at 21:21
    
The first thing you want to do is talk to those IBM guys who designed Watson, they rule at this sort of thing.. They wrote all that stuff in Java right? –  Mike Christensen Oct 11 '11 at 21:25
    
Maybe this is relevant: en.wikipedia.org/wiki/Natural_Language_Toolkit –  Blender Oct 11 '11 at 21:28
    
@MikeChristensen I dont think that there will be anything more powerfull than Watson ever! –  kotsirokolos Oct 11 '11 at 23:21
    
You're asking a very big question. There's a vast literature on natural language processing. You need to start getting books on the subject and reading them. This isn't something to attempt in an afternoon. –  Michael Kay Oct 12 '11 at 9:26

2 Answers 2

I think before you consider a way to store it, you must decide on a consistent sentence structure.
With your current example (removing all prepositions) David Houston patented the roll film in 1881. All your sentences must follow this format:
Name | Action | Object | When
If this is the case then you can store data in just those 4 fields. If you want to store answers as numbers then you would need a 5 tables, 1 for each Name, Action, Object, Date (each with 2 fields, an ID number and the description) and a 5th table to tie them all together like your | 2 | 23 | 64 | 4 | example. If you have a lot of data this would be the best way to go, especially if David Houston also did hundreds or thousands other things that you would like to store.
Hope this helps.

share|improve this answer

You could manually parse each sentence into its grammatical parts, as you would do in a sentence diagram.

Then you can make questions by removing one or more parts.

For example, you can remove the subject of the sentence, and replace it with "Who" or "What".

Or, you could remove the predicate, and ask: "What did (subject) do?"

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.