· 8 years ago · Jun 12, 2018, 05:20 AM
1I have 3 tables in my sqlite database:
2
3fragments
4-count
5-fragment words (not sure how to store it yet)
6
7isentence_links (inter-sentence links)
8-id_from
9-id_to
10-count
11
12xsentence links (cross-sentence links)
13-id_from
14-id_to
15-count
16
17So I parse text and chop it into chunks of 3 currently,
18I think I'm going to do it somehow like this:
19
20eg: "Hello, how are you?"
21fragment1 = ["", "Hello,", "how"]
22fragment2 = ["are", "you?", ""]
23
24the empty strings are so i know what starts and ends sentences
25
26then i find fragment1 in my database and
27increase the count if it exists
28if not i create it and set count to 1
29
30then i go through my sentence and link the fragments with
31the intersentence links table
32so I'd find the id of fragment1 and fragment2 and
33try to find it in the isentence_links
34if it exists i inc the count, if not create it
35
36now if someone said something like:
37"I'm good thanks, how about yourself?"
38
39I split it up into chunks of 3 again
40s2f1 = ["", "I'm", "good"]
41s2f2 = ["thanks,", "how", "about"]
42s2f3 = ["yourself?", "", ""]
43
44then I'd link s2f1 to s2f2 and link s2f2 to s2f3
45
46Then I'd go through my two sentences and link the fragments together
47so starting with first fragment from first sentence I'd link
48
49fragment1 -> s2f1, s2f2, s2f3
50fragment2 -> s2f1, s2f2, s2f3
51s2f1 -> fragment1, fragment2
52s2f2 -> fragment1, fragment2
53s2f3 -> fragment1, fragment2
54
55I think anyway need to test it..
56
57so then to generate a response I'd look for a fragment
58in the sentence with the lowest count
59I think, since that would most likely be the most important information
60
61then I'd search my cross-sentence table for that and
62if it finds something find a sentence beginning for it,
63if not one already,
64then find stuff to add on the end
65until we come across an empty string for the ending thing.
66
67sounds like it should work =p