summary refs log tree commit diff stats
path: root/lib/word.cpp
blob: c50e7d3457fe9503bc6e7f3328369307e69966b2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "verbly.h"

namespace verbly {
  
  word::word(const data& _data, int _id) : _data(_data), _id(_id)
  {
    
  }
  
  std::list<std::string> word::rhyme_phonemes() const
  {
    std::list<std::string> result;
    
    for (auto pronunciation : pronunciations)
    {
      auto phemstrt = std::find_if(std::begin(pronunciation), std::end(pronunciation), [] (std::string phoneme) {
        return phoneme.find("1") != std::string::npos;
      });
      
      std::stringstream rhymer;
      for (auto it = phemstrt; it != std::end(pronunciation); it++)
      {
        rhymer << " " << *it;
      }
      
      result.push_back(rhymer.str());
    }
    
    return result;
  }
  
};