XTL  0.1
eXtended Template Library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nlp.hpp
Go to the documentation of this file.
1 
5 #pragma once
6 
7 #include <xtd/xtd.hpp>
8 
9 #include <vector>
10 #include <typeinfo>
11 #include <string>
12 #include <fstream>
13 #include <map>
14 
15 #include <xtd/meta.hpp>
16 #include <xtd/string.hpp>
17 #include <xtd/var.hpp>
18 #include <xtd/type_info.hpp>
19 #include <xtd/wrapped_type.hpp>
20 #include <xtd/debug.hpp>
21 
22 namespace xtd{
23  namespace nlp{
24 
25 
26  using raw_text = WRAPPED(xtd::string);
27  using lemma = WRAPPED(xtd::string);
28 
29  enum part_of_speech : uint64_t {
30  unknown = 0,
31  adj_ppl = 1,
32  adj_pert = (adj_ppl << 1),
33  adj = (adj_ppl | adj_pert),
34  adv = (adj_pert << 1),
35  noun_Tops = (adv << 1),
36  noun_act = (noun_Tops << 1),
37  noun_animal = (noun_act << 1),
38  noun_artifact = (noun_animal << 1),
39  noun_attribute = (noun_artifact << 1),
40  noun_body = (noun_attribute << 1),
41  noun_cognition = (noun_body << 1),
42  noun_communication = (noun_cognition << 1),
43  noun_event = (noun_communication << 1),
44  noun_feeling = (noun_event << 1),
45  noun_food = (noun_feeling << 1),
46  noun_group = (noun_food << 1),
47  noun_location = (noun_group << 1),
48  noun_motive = (noun_location << 1),
49  noun_object = (noun_motive << 1),
50  noun_person = (noun_object << 1),
51  noun_phenomenon = (noun_person << 1),
52  noun_plant = (noun_phenomenon << 1),
53  noun_possession = (noun_plant << 1),
54  noun_process = (noun_possession << 1),
55  noun_quantity = (noun_process << 1),
56  noun_relation = (noun_quantity << 1),
57  noun_shape = (noun_relation << 1),
58  noun_state = (noun_shape << 1),
59  noun_substance = (noun_state << 1),
60  noun_time = (noun_substance << 1),
61  noun_plural = (noun_time << 1),
62  noun_phrase = (noun_plural << 1),
63  noun = (noun_Tops | noun_act | noun_animal | noun_artifact | noun_attribute | noun_body | noun_cognition |
64  noun_communication | noun_event | noun_feeling | noun_food | noun_group | noun_location | noun_motive |
65  noun_object | noun_person | noun_phenomenon | noun_plant | noun_possession | noun_process | noun_quantity |
66  noun_relation | noun_shape | noun_state | noun_substance | noun_time | noun_plural | noun_phrase),
67  verb_cognition = (noun_phrase << 1),
68  verb_communication = (verb_cognition << 1),
69  verb_competition = (verb_communication << 1),
70  verb_consumption = (verb_competition << 1),
71  verb_contact = (verb_consumption << 1),
72  verb_creation = (verb_contact << 1),
73  verb_emotion = (verb_creation << 1),
74  verb_motion = (verb_emotion << 1),
75  verb_perception = (verb_motion << 1),
76  verb_possession = (verb_perception << 1),
77  verb_social = (verb_possession << 1),
78  verb_stative = (verb_social << 1),
79  verb_weather = (verb_stative << 1),
80  verb_body = (verb_weather << 1),
81  verb_change = (verb_body << 1),
82  verb_participle = (verb_change << 1),
83  verb_transitive = (verb_participle << 1),
84  verb_intransitive = (verb_transitive << 1),
85  verb = (verb_cognition | verb_communication | verb_competition | verb_consumption | verb_contact |
86  verb_creation | verb_emotion | verb_motion | verb_perception | verb_possession | verb_social |
87  verb_stative | verb_weather | verb_body | verb_change | verb_participle | verb_transitive | verb_intransitive),
88  conjunction = (verb_intransitive << 1),
89  preposition = (conjunction << 1),
90  interjection = (preposition << 1),
91  definite_article = (interjection << 1),
92  indefinite_article = (definite_article << 1),
93  nominative = (indefinite_article << 1),
94  pronoun = (nominative << 1),
95  };
96  }
97 
98  namespace _ {
99  template<>
100  class xstring_format<char, const nlp::part_of_speech &> {
101  public:
102  inline static string format(const nlp::part_of_speech &iPOS) {
103  xtd::string sRet = "(";
104  if (nlp::part_of_speech::unknown == iPOS) sRet += "unknown";
105  if (nlp::part_of_speech::adj & iPOS) sRet += "adj | ";
106  if (nlp::part_of_speech::adv & iPOS) sRet += "adv | ";
107  if (nlp::part_of_speech::noun & iPOS) sRet += "noun | ";
108  if (nlp::part_of_speech::verb & iPOS) sRet += "verb | ";
109  if (nlp::part_of_speech::conjunction & iPOS) sRet += "conjunction | ";
110  if (nlp::part_of_speech::preposition & iPOS) sRet += "preposition | ";
111  if (nlp::part_of_speech::interjection & iPOS) sRet += "interjection | ";
112  if (nlp::part_of_speech::definite_article & iPOS) sRet += "definite_article | ";
113  if (nlp::part_of_speech::indefinite_article & iPOS) sRet += "indefinite_article | ";
114  if (nlp::part_of_speech::nominative & iPOS) sRet += "nominative | ";
115  if (nlp::part_of_speech::pronoun & iPOS) sRet += "pronoun | ";
116  sRet += ")";
117  return sRet;
118  }
119  };
120  }
121 
122 }
123 
124 
125 
126 #include "pos.hpp"
template meta-programming utilities
pos tagging
multi-type variant using type-erasure
specializations of std::basic_string for advanced and common string handling
host, target and build configurations and settings Various components are purpose built for specific ...
wraps a type in a class for compiler type deductive distinction
std::type_info extensions
Debugging.