Revision 62

Date:
2011/06/06 07:05:45
Author:
gdshaw@RISCID.ORG
Revision Log:
Added function fragtable::token.
Files:

Legend:

 
Added
 
Removed
 
Modified
  • trunk/parser/fragtable.h

     
    65 65 size_t capacity() const
    66 66 { return _capacity; }
    67 67
    68 /** Get token for given index.
    69 * @param index the required index
    70 * @return the token
    71 */
    72 const std::string& token(size_t index) const
    73 { return _tokens[index]; }
    74
    68 75 /** Get non-modifiable tagset for given index and length.
    69 76 * @param index the required fragment index
    70 77 * @param length the required fragment length
  • trunk/parser/main.cc

     
    60 60 {
    61 61 fragtable table;
    62 62 table.prepare(text,lang.lexicon());
    63 table.apply(lang.grammar());
    64 std::cout << table;
    63
    64 unsigned int empty_count=0;
    65 size_t empty_index=0;
    66 for (size_t i=0,i_end=table.capacity();i!=i_end;++i)
    67 {
    68 if (table.tags(i,1).empty())
    69 {
    70 ++empty_count;
    71 empty_index=i;
    72 }
    73 }
    74 if (empty_count==1)
    75 {
    76 table.tags(empty_index,1)|=tag("n");
    77 table.tags(empty_index,1)|=tag("adj");
    78 table.tags(empty_index,1)|=tag("vi");
    79 table.tags(empty_index,1)|=tag("vf");
    80 table.tags(empty_index,1)|=tag("adv");
    81 table.apply(lang.grammar());
    82 std::cout << table.token(empty_index) << ": "
    83 << table.tags(empty_index,1) << std::endl;
    84 // std::cout << table;
    85 }
    86 // std::cout << std::endl;
    65 87 }
    66 std::cout << std::endl;
    67 88 }
    68 89 }
    69 90 catch (const std::exception& ex)