Class: CNTK::Dictionary

Inherits:
Object
  • Object
show all
Defined in:
lib/cntk/dictionary.rb,
ext/cntk/cntk_wrap.cxx

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, self) ⇒ Object



23506
23507
23508
23509
23510
23511
23512
23513
23514
23515
23516
23517
23518
23519
23520
23521
23522
23523
23524
23525
23526
23527
23528
23529
23530
23531
23532
23533
23534
23535
# File 'ext/cntk/cntk_wrap.cxx', line 23506

SWIGINTERN VALUE _wrap_new_Dictionary(int nargs, VALUE *args, VALUE self) {
  int argc;
  VALUE argv[1];
  int ii;
  
  argc = nargs;
  if (argc > 1) SWIG_fail;
  for (ii = 0; (ii < argc); ++ii) {
    argv[ii] = args[ii];
  }
  if (argc == 0) {
    return _wrap_new_Dictionary__SWIG_0(nargs, args, self);
  }
  if (argc == 1) {
    int _v;
    void *vptr = 0;
    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CNTK__Dictionary, 0);
    _v = SWIG_CheckState(res);
    if (_v) {
      return _wrap_new_Dictionary__SWIG_1(nargs, args, self);
    }
  }
  
fail:
  Ruby_Format_OverloadedError( argc, 1, "Dictionary.new", 
    "    Dictionary.new()\n"
    "    Dictionary.new(CNTK::Dictionary const &)\n");
  
  return Qnil;
}

Class Method Details

.create(h) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/cntk/dictionary.rb', line 52

def self.create(h)
  dict = new()
  h.each_pair{|k, v|
    k = k.to_s if k.is_a?(Symbol)
    dict[k] = DictionaryValue.create(v)
  }
  return dict
end

.load(*args) ⇒ Object



23733
23734
23735
23736
23737
23738
23739
23740
23741
23742
23743
23744
23745
23746
23747
23748
23749
23750
23751
23752
23753
23754
23755
23756
23757
23758
23759
23760
23761
23762
23763
23764
23765
23766
23767
23768
23769
23770
23771
23772
23773
23774
23775
23776
23777
# File 'ext/cntk/cntk_wrap.cxx', line 23733

SWIGINTERN VALUE
_wrap_Dictionary_load(int argc, VALUE *argv, VALUE self) {
  std::wstring *arg1 = 0 ;
  int res1 = SWIG_OLDOBJ ;
  CNTK::Dictionary result;
  VALUE vresult = Qnil;
  
  if ((argc < 1) || (argc > 1)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
  }
  {
    std::wstring *ptr = (std::wstring *)0;
    res1 = SWIG_AsPtr_std_wstring(argv[0], &ptr);
    if (!SWIG_IsOK(res1)) {
      SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "std::wstring const &","CNTK::Dictionary::Load", 1, argv[0] )); 
    }
    if (!ptr) {
      SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "std::wstring const &","CNTK::Dictionary::Load", 1, argv[0])); 
    }
    arg1 = ptr;
  }
  {
    try {
      result = CNTK::Dictionary::Load((std::wstring const &)*arg1); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = SWIG_NewPointerObj((new CNTK::Dictionary(static_cast< const CNTK::Dictionary& >(result))), SWIGTYPE_p_CNTK__Dictionary, SWIG_POINTER_OWN |  0 );
  if (SWIG_IsNewObj(res1)) delete arg1;
  return vresult;
fail:
  if (SWIG_IsNewObj(res1)) delete arg1;
  return Qnil;
}

Instance Method Details

#==(*args) ⇒ Object

call-seq:

==(other) -> bool

Equality comparison operator.



23925
23926
23927
23928
23929
23930
23931
23932
23933
23934
23935
23936
23937
23938
23939
23940
23941
23942
23943
23944
23945
23946
23947
23948
23949
23950
23951
23952
23953
23954
23955
23956
23957
23958
23959
23960
23961
23962
23963
23964
23965
23966
23967
23968
23969
23970
23971
23972
23973
# File 'ext/cntk/cntk_wrap.cxx', line 23925

SWIGINTERN VALUE
_wrap_Dictionary___eq__(int argc, VALUE *argv, VALUE self) {
  CNTK::Dictionary *arg1 = (CNTK::Dictionary *) 0 ;
  CNTK::Dictionary *arg2 = 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  void *argp2 ;
  int res2 = 0 ;
  bool result;
  VALUE vresult = Qnil;
  
  if ((argc < 1) || (argc > 1)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
  }
  res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CNTK__Dictionary, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Dictionary *","__eq__", 1, self )); 
  }
  arg1 = reinterpret_cast< CNTK::Dictionary * >(argp1);
  res2 = SWIG_ConvertPtr(argv[0], &argp2, SWIGTYPE_p_CNTK__Dictionary,  0 );
  if (!SWIG_IsOK(res2)) {
    SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "CNTK::Dictionary const &","__eq__", 2, argv[0] )); 
  }
  if (!argp2) {
    SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "CNTK::Dictionary const &","__eq__", 2, argv[0])); 
  }
  arg2 = reinterpret_cast< CNTK::Dictionary * >(argp2);
  {
    try {
      result = (bool)CNTK_Dictionary___eq__(arg1,(CNTK::Dictionary const &)*arg2); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = SWIG_From_bool(static_cast< bool >(result));
  return vresult;
fail:
  return Qnil;
}

#[](*args) ⇒ Object

call-seq:

[](key) -> DictionaryValue

Element accessor/slicing.



23789
23790
23791
23792
23793
23794
23795
23796
23797
23798
23799
23800
23801
23802
23803
23804
23805
23806
23807
23808
23809
23810
23811
23812
23813
23814
23815
23816
23817
23818
23819
23820
23821
23822
23823
23824
23825
23826
23827
23828
23829
23830
23831
23832
23833
23834
23835
23836
23837
23838
23839
23840
23841
# File 'ext/cntk/cntk_wrap.cxx', line 23789

SWIGINTERN VALUE
_wrap_Dictionary___getitem__(int argc, VALUE *argv, VALUE self) {
  CNTK::Dictionary *arg1 = (CNTK::Dictionary *) 0 ;
  std::wstring *arg2 = 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  int res2 = SWIG_OLDOBJ ;
  CNTK::DictionaryValue result;
  VALUE vresult = Qnil;
  
  if ((argc < 1) || (argc > 1)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
  }
  res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CNTK__Dictionary, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Dictionary *","__getitem__", 1, self )); 
  }
  arg1 = reinterpret_cast< CNTK::Dictionary * >(argp1);
  {
    std::wstring *ptr = (std::wstring *)0;
    res2 = SWIG_AsPtr_std_wstring(argv[0], &ptr);
    if (!SWIG_IsOK(res2)) {
      SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "std::wstring const &","__getitem__", 2, argv[0] )); 
    }
    if (!ptr) {
      SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "std::wstring const &","__getitem__", 2, argv[0])); 
    }
    arg2 = ptr;
  }
  {
    try {
      result = CNTK_Dictionary___getitem__(arg1,(std::wstring const &)*arg2); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = SWIG_NewPointerObj((new CNTK::DictionaryValue(static_cast< const CNTK::DictionaryValue& >(result))), SWIGTYPE_p_CNTK__DictionaryValue, SWIG_POINTER_OWN |  0 );
  if (SWIG_IsNewObj(res2)) delete arg2;
  return vresult;
fail:
  if (SWIG_IsNewObj(res2)) delete arg2;
  return Qnil;
}

#[]=(*args) ⇒ Object

call-seq:

[]=(key, v)

Element setter/slicing.



23853
23854
23855
23856
23857
23858
23859
23860
23861
23862
23863
23864
23865
23866
23867
23868
23869
23870
23871
23872
23873
23874
23875
23876
23877
23878
23879
23880
23881
23882
23883
23884
23885
23886
23887
23888
23889
23890
23891
23892
23893
23894
23895
23896
23897
23898
23899
23900
23901
23902
23903
23904
23905
23906
23907
23908
23909
23910
23911
23912
23913
# File 'ext/cntk/cntk_wrap.cxx', line 23853

SWIGINTERN VALUE
_wrap_Dictionary___setitem__(int argc, VALUE *argv, VALUE self) {
  CNTK::Dictionary *arg1 = (CNTK::Dictionary *) 0 ;
  std::wstring *arg2 = 0 ;
  CNTK::DictionaryValue *arg3 = 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  int res2 = SWIG_OLDOBJ ;
  void *argp3 ;
  int res3 = 0 ;
  
  if ((argc < 2) || (argc > 2)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
  }
  res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CNTK__Dictionary, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Dictionary *","__setitem__", 1, self )); 
  }
  arg1 = reinterpret_cast< CNTK::Dictionary * >(argp1);
  {
    std::wstring *ptr = (std::wstring *)0;
    res2 = SWIG_AsPtr_std_wstring(argv[0], &ptr);
    if (!SWIG_IsOK(res2)) {
      SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "std::wstring const &","__setitem__", 2, argv[0] )); 
    }
    if (!ptr) {
      SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "std::wstring const &","__setitem__", 2, argv[0])); 
    }
    arg2 = ptr;
  }
  res3 = SWIG_ConvertPtr(argv[1], &argp3, SWIGTYPE_p_CNTK__DictionaryValue,  0 );
  if (!SWIG_IsOK(res3)) {
    SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "CNTK::DictionaryValue const &","__setitem__", 3, argv[1] )); 
  }
  if (!argp3) {
    SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "CNTK::DictionaryValue const &","__setitem__", 3, argv[1])); 
  }
  arg3 = reinterpret_cast< CNTK::DictionaryValue * >(argp3);
  {
    try {
      CNTK_Dictionary___setitem__(arg1,(std::wstring const &)*arg2,(CNTK::DictionaryValue const &)*arg3); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  if (SWIG_IsNewObj(res2)) delete arg2;
  return Qnil;
fail:
  if (SWIG_IsNewObj(res2)) delete arg2;
  return Qnil;
}

#add(*args) ⇒ Object



23593
23594
23595
23596
23597
23598
23599
23600
23601
23602
23603
23604
23605
23606
23607
23608
23609
23610
23611
23612
23613
23614
23615
23616
23617
23618
23619
23620
23621
23622
23623
23624
23625
23626
23627
23628
23629
23630
23631
23632
23633
23634
23635
23636
23637
23638
# File 'ext/cntk/cntk_wrap.cxx', line 23593

SWIGINTERN VALUE
_wrap_Dictionary_add(int argc, VALUE *argv, VALUE self) {
  CNTK::Dictionary *arg1 = (CNTK::Dictionary *) 0 ;
  CNTK::Dictionary *arg2 = 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  void *argp2 ;
  int res2 = 0 ;
  
  if ((argc < 1) || (argc > 1)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
  }
  res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CNTK__Dictionary, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Dictionary *","Add", 1, self )); 
  }
  arg1 = reinterpret_cast< CNTK::Dictionary * >(argp1);
  res2 = SWIG_ConvertPtr(argv[0], &argp2, SWIGTYPE_p_CNTK__Dictionary,  0 );
  if (!SWIG_IsOK(res2)) {
    SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "CNTK::Dictionary const &","Add", 2, argv[0] )); 
  }
  if (!argp2) {
    SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "CNTK::Dictionary const &","Add", 2, argv[0])); 
  }
  arg2 = reinterpret_cast< CNTK::Dictionary * >(argp2);
  {
    try {
      (arg1)->Add((CNTK::Dictionary const &)*arg2); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  return Qnil;
fail:
  return Qnil;
}

#contains(*args) ⇒ Object



23538
23539
23540
23541
23542
23543
23544
23545
23546
23547
23548
23549
23550
23551
23552
23553
23554
23555
23556
23557
23558
23559
23560
23561
23562
23563
23564
23565
23566
23567
23568
23569
23570
23571
23572
23573
23574
23575
23576
23577
23578
23579
23580
23581
23582
23583
23584
23585
23586
23587
23588
23589
23590
# File 'ext/cntk/cntk_wrap.cxx', line 23538

SWIGINTERN VALUE
_wrap_Dictionary_contains(int argc, VALUE *argv, VALUE self) {
  CNTK::Dictionary *arg1 = (CNTK::Dictionary *) 0 ;
  std::wstring *arg2 = 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  int res2 = SWIG_OLDOBJ ;
  bool result;
  VALUE vresult = Qnil;
  
  if ((argc < 1) || (argc > 1)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
  }
  res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CNTK__Dictionary, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Dictionary *","Contains", 1, self )); 
  }
  arg1 = reinterpret_cast< CNTK::Dictionary * >(argp1);
  {
    std::wstring *ptr = (std::wstring *)0;
    res2 = SWIG_AsPtr_std_wstring(argv[0], &ptr);
    if (!SWIG_IsOK(res2)) {
      SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "std::wstring const &","Contains", 2, argv[0] )); 
    }
    if (!ptr) {
      SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "std::wstring const &","Contains", 2, argv[0])); 
    }
    arg2 = ptr;
  }
  {
    try {
      result = (bool)(arg1)->Contains((std::wstring const &)*arg2); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = SWIG_From_bool(static_cast< bool >(result));
  if (SWIG_IsNewObj(res2)) delete arg2;
  return vresult;
fail:
  if (SWIG_IsNewObj(res2)) delete arg2;
  return Qnil;
}

#save(*args) ⇒ Object



23681
23682
23683
23684
23685
23686
23687
23688
23689
23690
23691
23692
23693
23694
23695
23696
23697
23698
23699
23700
23701
23702
23703
23704
23705
23706
23707
23708
23709
23710
23711
23712
23713
23714
23715
23716
23717
23718
23719
23720
23721
23722
23723
23724
23725
23726
23727
23728
23729
23730
# File 'ext/cntk/cntk_wrap.cxx', line 23681

SWIGINTERN VALUE
_wrap_Dictionary_save(int argc, VALUE *argv, VALUE self) {
  CNTK::Dictionary *arg1 = (CNTK::Dictionary *) 0 ;
  std::wstring *arg2 = 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  int res2 = SWIG_OLDOBJ ;
  
  if ((argc < 1) || (argc > 1)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
  }
  res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CNTK__Dictionary, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Dictionary *","Save", 1, self )); 
  }
  arg1 = reinterpret_cast< CNTK::Dictionary * >(argp1);
  {
    std::wstring *ptr = (std::wstring *)0;
    res2 = SWIG_AsPtr_std_wstring(argv[0], &ptr);
    if (!SWIG_IsOK(res2)) {
      SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "std::wstring const &","Save", 2, argv[0] )); 
    }
    if (!ptr) {
      SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "std::wstring const &","Save", 2, argv[0])); 
    }
    arg2 = ptr;
  }
  {
    try {
      (arg1)->Save((std::wstring const &)*arg2); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  if (SWIG_IsNewObj(res2)) delete arg2;
  return Qnil;
fail:
  if (SWIG_IsNewObj(res2)) delete arg2;
  return Qnil;
}

#size(*args) ⇒ Object



23641
23642
23643
23644
23645
23646
23647
23648
23649
23650
23651
23652
23653
23654
23655
23656
23657
23658
23659
23660
23661
23662
23663
23664
23665
23666
23667
23668
23669
23670
23671
23672
23673
23674
23675
23676
23677
23678
# File 'ext/cntk/cntk_wrap.cxx', line 23641

SWIGINTERN VALUE
_wrap_Dictionary_size(int argc, VALUE *argv, VALUE self) {
  CNTK::Dictionary *arg1 = (CNTK::Dictionary *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  size_t result;
  VALUE vresult = Qnil;
  
  if ((argc < 0) || (argc > 0)) {
    rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
  }
  res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CNTK__Dictionary, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CNTK::Dictionary *","Size", 1, self )); 
  }
  arg1 = reinterpret_cast< CNTK::Dictionary * >(argp1);
  {
    try {
      result = (arg1)->Size(); 
    }
    catch (const std::runtime_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (const std::invalid_argument &e) {
      SWIG_exception(SWIG_ValueError,e.what()); 
    }
    catch (const std::logic_error &e) {
      SWIG_exception(SWIG_RuntimeError,e.what()); 
    }
    catch (...) {
      SWIG_exception(SWIG_UnknownError,"Runtime exception"); 
    }
  }
  vresult = SWIG_From_size_t(static_cast< size_t >(result));
  return vresult;
fail:
  return Qnil;
}