Dmitry Kirsanov commited on
Commit
bbf13e1
·
1 Parent(s): 1b5739d

more methods

Browse files
Files changed (1) hide show
  1. fad.py +21 -2
fad.py CHANGED
@@ -64,6 +64,20 @@ class Fad:
64
  for value in values:
65
  self.newnote(type, value)
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  def get_note_by_value(self, value, valuetype):
68
  for id, note in self.notes.items():
69
  if note.type == self.notetypes[valuetype] and note.properties["value"] == value:
@@ -217,8 +231,13 @@ if __name__ == "__main__":
217
  #print(f.get_plaintext_with_markup(fad, "point"))
218
  assert(f.get_plaintext_with_markup(fad, "point", show_id=True) == '<point id="3"/>A<point id="2"/><point id="1"/>123456789B123456789C123456789')
219
 
220
- f.add_notes_from_list(["actor1", "actor2"], "actor")
221
- f.add_notes_from_list(["audience1", "audience2", "audience3"], "audience")
 
 
 
 
 
222
 
223
  f.set_property_to_mark(fad, "span", 1, "actors", "actor1", "actor")
224
 
 
64
  for value in values:
65
  self.newnote(type, value)
66
 
67
+ def get_notes_by_type(self, valuetype):
68
+ ids = []
69
+ for id, note in self.notes.items():
70
+ if note.type == self.notetypes[valuetype]:
71
+ ids.append(id)
72
+ return ids
73
+
74
+ def get_values_by_type(self, valuetype):
75
+ values = []
76
+ for id, note in self.notes.items():
77
+ if note.type == self.notetypes[valuetype]:
78
+ values.append(note.properties["value"])
79
+ return values
80
+
81
  def get_note_by_value(self, value, valuetype):
82
  for id, note in self.notes.items():
83
  if note.type == self.notetypes[valuetype] and note.properties["value"] == value:
 
231
  #print(f.get_plaintext_with_markup(fad, "point"))
232
  assert(f.get_plaintext_with_markup(fad, "point", show_id=True) == '<point id="3"/>A<point id="2"/><point id="1"/>123456789B123456789C123456789')
233
 
234
+ actors = ["actor1", "actor2"]
235
+ audiences = ["audience1", "audience2", "audience3"]
236
+ f.add_notes_from_list(actors, "actor")
237
+ f.add_notes_from_list(audiences, "audience")
238
+
239
+ assert(actors == f.get_values_by_type("actor"))
240
+ assert(audiences == f.get_values_by_type("audience"))
241
 
242
  f.set_property_to_mark(fad, "span", 1, "actors", "actor1", "actor")
243