~wintermute-devel/wintermute/linguistics-devel

« back to all changes in this revision

Viewing changes to wintermute-linguistics-en/src/EnglishParser.hpp

  • Committer: Jacky Alciné
  • Date: 2011-04-15 19:44:37 UTC
  • Revision ID: jackyalcine@gmail.com-20110415194437-35z370knjjz96oea
FINALLY! Wintermute has a very rough understanding of English! It knows how verbs would be conjugated, how pronouns works, and there's preliminary work for pulling information from the ontology. Only for English; Spanish support should be up next.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * @file    EnglishParser.cpp
 
3
 * @author  Jacky Alcine <jackyalcine@gmail.com>
 
4
 * @created February 10, 2011, 12:07 AM
 
5
 * @license GPL3
 
6
 *
 
7
 * This library is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU Library General Public
 
9
 * License as published by the Free Software Foundation; either
 
10
 * version 3 of the License, or (at your option) any later version.
 
11
 *
 
12
 * This library is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
 * Library General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU Library General Public
 
18
 * License along with this library; if not, write to the
 
19
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
20
 * Boston, MA 02111-1307, USA.
 
21
 *
 
22
 */
 
23
 
 
24
#ifndef WINTERMUTE_LINGUISTICS_ENGLISHPARSER_HPP
 
25
#    define     WINTERMUTE_LINGUISTICS_ENGLISHPARSER_HPP
 
26
 
 
27
#    include <wintermute-linguistics.hpp>
 
28
#    include <vector>
 
29
 
 
30
namespace Wintermute {
 
31
        namespace Linguistics {
 
32
                namespace English {
 
33
                        using namespace Wintermute::Linguistics;
 
34
 
 
35
                        /**
 
36
                         * @description Represents a parser that understands a set of English syntax,
 
37
                         */
 
38
                        class EnglishParser : public Parser {
 
39
                        public:
 
40
                                /**
 
41
                                 * @description Creates a new English parser.
 
42
                                 */
 
43
                                EnglishParser ( );
 
44
                                /**
 
45
                                 * @description Returns the locale of this parser.
 
46
                                 * @return string The locale of the parser; defaults to 'en'.
 
47
                                 */
 
48
                                virtual const string getLocale ( ) const;
 
49
 
 
50
                                /**
 
51
                                 * @note This will always return a space.
 
52
                                 * @description Determines the separator used to represent a break between words.
 
53
                                 * @return char A character representing a space.
 
54
                                 */
 
55
                                virtual char getTextSeparator ( ) const;
 
56
 
 
57
                        private:
 
58
                                /**
 
59
                                 * @description Generates the preliminary information of the syntactical tree to be formed from a set of tokens.
 
60
                                 * @param StringVector The tokens to parse.
 
61
                                 * @return SyntacticBranch The tree of nodes representing every possible path of interpretation for this node.
 
62
                                 */
 
63
                                virtual SyntacticBranch generateSyntactics ( const StringVector& );
 
64
                                /**
 
65
                                 * @description Generates a Phrase from a said node at a specific position in a sentence.
 
66
                                 * @param NodeVector::iterator The position of the node to be the 'head' node of the phrase.
 
67
                                 * @param NodeVector The entire vector of nodes.
 
68
                                 * @return A pointer to the Phrase formed, or NULL.
 
69
                                 */
 
70
                                virtual Phrase* formPhrase ( const NodeVector::iterator& , NodeVector& );
 
71
                                /**
 
72
                                 * @description Generates a SyntacticLink from a phrase to another phrase.
 
73
                                 * @param PhraseVector::iterator The position of the phrase to be considered.
 
74
                                 * @param PhraseVector The entire vector of phrases.
 
75
                                 * @return A pointer to the Link formed, or NULL.
 
76
                                 */
 
77
                                virtual SyntacticLink* formSyntacticLink ( const PhraseVector::iterator& , PhraseVector& );
 
78
                                /**
 
79
                                 * @note This function does nothing at the moment, only will come to use as the ontology grows.
 
80
                                 * @description Does prerequeiste work on each node; such as connecting them to concepts or instances within the ontology; a sort of 'late binding'.
 
81
                                 * @param The PhraseVector to iterate over and connect.
 
82
                                 */
 
83
                                virtual void doPreparsingWork ( PhraseVector& );
 
84
                                /**
 
85
                                 * @note This is the most interestingly complex method of them all.
 
86
                                 * @descripion Interprets and, if needed, carries out the tasks described by a sentence.
 
87
                                 * @param The LinkVector to iterate over and interpret.
 
88
                                 */
 
89
                                virtual void interpretLinks ( const LinkVector& );
 
90
                        };
 
91
                }
 
92
        }
 
93
}
 
94
 
 
95
#endif  /* WINTERMUTE_LINGUISTICS_ENGLISHPARSER_HPP */
 
96