Python LMF library
 All Classes Namespaces Files Functions Variables
lexical_resource.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 """! @package core
4 """
5 
6 from core.global_information import GlobalInformation
7 
9  """! "Lexical Resource is a class representing the entire resource and is a container for one or more lexicons. There is only one Lexical Resource instance." (LMF)
10  """
11  def __init__(self, dtd_version=16):
12  """! @brief Constructor.
13  @return A LexicalResource instance.
14  """
15  self.dtdVersion = dtd_version
16  ## GlobalInformation instance is owned by LexicalResource
17  # There is one GlobalInformation for one LexicalResource
18  self.global_information = GlobalInformation()
19  ## Lexicon instances are owned by LexicalResource
20  # There is one or more Lexicon instances for one unique LexicalResource
21  self.lexicon = []
22  ## Speaker instances are owned by LexicalResource
23  # There is zero to many Speaker instances for one unique LexicalResource
24  self.speaker = []
25 
26  def __del__(self):
27  """! @brief Destructor.
28  Release GlobalInformation, Lexicon, Speaker instances.
29  """
30  for lexicon in self.lexicon:
31  del lexicon
32  del self.lexicon[:]
33  for speaker in self.speaker:
34  del speaker
35  del self.speaker[:]
36  if self.global_information is not None:
37  del self.global_information
38 
39  def get_lexicons(self):
40  """! @brief Get all lexicons maintained by the lexical resource.
41  @return A Python list of lexicons.
42  """
43  return self.lexicon
44 
45  def add_lexicon(self, lexicon):
46  """! @brief Add a lexicon to the lexical resource.
47  @param lexicon A Lexicon instance to add to the Lexical Resource.
48  @return Lexical Resource instance.
49  """
50  self.lexicon.append(lexicon)
51  return self
52 
53  def remove_lexicon(self, lexicon):
54  """! @brief Remove a lexicon from the lexical resource.
55  @param lexicon The Lexicon instance to remove from the Lexical Resource.
56  @return Lexical Resource instance.
57  """
58  self.lexicon.remove(lexicon)
59  return self
60 
61  def get_lexicon(self, id):
62  """Retrieve a lexicon from its identifier.
63  @param id The identifier of the lexicon to retrieve.
64  @result A Lexicon instance, or None if not found.
65  """
66  for lexicon in self.get_lexicons():
67  if lexicon.id == id:
68  return lexicon
69 
70  def set_dtdVersion(self, dtd_version):
71  """! @brief Set DTD version.
72  @param dtd_version The DTD version to use.
73  @return LexicalResource instance.
74  """
75  self.dtdVersion = dtd_version
76  return self
77 
78  def get_dtdVersion(self):
79  """! @brief Get DTD version.
80  @return LexicalResource attribute 'dtdVersion'.
81  """
82  return self.dtdVersion
83 
84  def set_language_code(self, language_code):
85  """! @brief Set language code.
86  Attribute 'languageCode' is owned by GlobalInformation.
87  @param language_code The language code to use.
88  @return LexicalResource instance.
89  """
90  self.global_information.set_languageCode(language_code)
91  return self
92 
93  def get_language_code(self):
94  """! @brief Get language code.
95  Attribute 'languageCode' is owned by GlobalInformation.
96  @return GlobalInformation attribute 'languageCode'.
97  """
98  return self.global_information.get_languageCode()
99 
100  def set_version(self, version):
101  """! @brief Set version.
102  Attribute 'version' is owned by GlobalInformation.
103  @param version The version to set.
104  @return LexicalResource instance.
105  """
106  self.global_information.set_version(version)
107  return self
108 
109  def get_version(self):
110  """! @brief Get version.
111  Attribute 'version' is owned by GlobalInformation.
112  @return GlobalInformation attribute 'version'.
113  """
114  return self.global_information.get_version()
115 
116  def set_license(self, license):
117  """! @brief Set license.
118  Attribute 'license' is owned by GlobalInformation.
119  @param license The license to set.
120  @return LexicalResource instance.
121  """
122  self.global_information.set_license(license)
123  return self
124 
125  def get_license(self):
126  """! @brief Get license.
127  Attribute 'license' is owned by GlobalInformation.
128  @return GlobalInformation attribute 'license'.
129  """
130  return self.global_information.get_license()
131 
132  def set_character_encoding(self, character_encoding):
133  """! @brief Set character encoding.
134  Attribute 'characterEncoding' is owned by GlobalInformation.
135  @param character_encoding The character encoding to use.
136  @return LexicalResource instance.
137  """
138  self.global_information.set_characterEncoding(character_encoding)
139  return self
140 
142  """! @brief Get character encoding.
143  Attribute 'characterEncoding' is owned by GlobalInformation.
144  @return GlobalInformation attribute 'characterEncoding'.
145  """
146  return self.global_information.get_characterEncoding()
147 
148  def set_date_coding(self, date_coding):
149  """! @brief Set date coding.
150  Attribute 'dateCoding' is owned by GlobalInformation.
151  @param date_coding The date coding to use.
152  @return LexicalResource instance.
153  """
154  self.global_information.set_dateCoding(date_coding)
155  return self
156 
157  def get_date_coding(self):
158  """! @brief Get date coding.
159  Attribute 'dateCoding' is owned by GlobalInformation.
160  @return GlobalInformation attribute 'dateCoding'.
161  """
162  return self.global_information.get_dateCoding()
163 
164  def set_project_name(self, project_name):
165  """! @brief Set project name.
166  Attribute 'projectName' is owned by GlobalInformation.
167  @param project_name The project's name to set.
168  @return LexicalResource instance.
169  """
170  self.global_information.set_projectName(project_name)
171  return self
172 
173  def get_project_name(self):
174  """! @brief Get project name.
175  Attribute 'projectName' is owned by GlobalInformation.
176  @return GlobalInformation attribute 'projectName'.
177  """
178  return self.global_information.get_projectName()
179 
180  def set_creation_date(self, date):
181  """! @brief Set creation date.
182  Attribute 'creationDate' is owned by GlobalInformation.
183  @param date The date to set, in format YYYY-MM-DD.
184  @return LexicalResource instance.
185  """
186  self.global_information.set_creationDate(date)
187  return self
188 
189  def get_creation_date(self):
190  """! @brief Get creation date.
191  Attribute 'creationDate' is owned by GlobalInformation.
192  @return GlobalInformation attribute 'creationdDate'.
193  """
194  return self.global_information.get_creationDate()
195 
196  def set_last_update(self, date):
197  """! @brief Set last update.
198  Attribute 'lastUpdate' is owned by GlobalInformation.
199  @param date The date to set, in format YYYY-MM-DD.
200  @return LexicalResource instance.
201  """
202  self.global_information.set_lastUpdate(date)
203  return self
204 
205  def get_last_update(self):
206  """! @brief Get last update.
207  Attribute 'lastUpdate' is owned by GlobalInformation.
208  @return GlobalInformation attribute 'lastUpdate'.
209  """
210  return self.global_information.get_lastUpdate()
211 
212  def set_author(self, author):
213  """! @brief Set author.
214  Attribute 'author' is owned by GlobalInformation.
215  @param author The author's name to set.
216  @return LexicalResource instance.
217  """
218  self.global_information.set_author(author)
219  return self
220 
221  def get_author(self):
222  """! @brief Get author.
223  Attribute 'author' is owned by GlobalInformation.
224  @return GlobalInformation attribute 'author'.
225  """
226  return self.global_information.get_author()
227 
228  def set_description(self, description):
229  """! @brief Set description.
230  Attribute 'description' is owned by GlobalInformation.
231  @param description The description to set.
232  @return LexicalResource instance.
233  """
234  self.global_information.set_description(description)
235  return self
236 
237  def get_description(self):
238  """! @brief Get description.
239  Attribute 'description' is owned by GlobalInformation.
240  @return GlobalInformation attribute 'description'.
241  """
242  return self.global_information.get_description()
243 
245  """! @brief Get bibliographic citation.
246  Attribute 'bibliographicCitation' is owned by GlobalInformation.
247  @return GlobalInformation attribute 'bibliographicCitation'.
248  """
249  return self.global_information.get_bibliographicCitation()
speaker
Speaker instances are owned by LexicalResource There is zero to many Speaker instances for one unique...
def get_bibliographic_citation
Get bibliographic citation.
def get_lexicons
Get all lexicons maintained by the lexical resource.
"Lexical Resource is a class representing the entire resource and is a container for one or more lexi...
def add_lexicon
Add a lexicon to the lexical resource.
lexicon
Lexicon instances are owned by LexicalResource There is one or more Lexicon instances for one unique ...
def remove_lexicon
Remove a lexicon from the lexical resource.
global_information
GlobalInformation instance is owned by LexicalResource There is one GlobalInformation for one Lexical...