In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "Python text query code how to write", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Python text query code how to write" it!
/ / text query
/ / what needs to be done
/ / 1. Put each line of a text into the vector.
/ / 2. Record the line number of each word
/ / 3. Output each line of words according to the line number.
Class TextQuery
{
Public:
Typedef vector::size_type line_no
Void store_file (ifstream& is)
Setprint_lineno (string&) const
Stringprint_linestring (line_no) const
Private:
Vectorline_of_text
Mapword_map
}
Void TextQuery::store_file (ifstream& is)
{
String word
While (getline (is,word))
{
Line_of_text.push_back (word)
}
Line_no num
For (num=0; num! = line_of_text.size (); + + num)
{
String line, tempword
Istringstream istream (line_of_ text [num])
While (istream > > word)
{
Word_ map [word] .insert (num)
}
}
}
Set TextQuery::print_lineno (string& str)
{
Map::iterator iter = word_map.find (str)
If (iter = = word_map.end ())
{
Return set ()
}
Return iter- > second
}
String TextQuery::print_linestring (line_no num)
{
If (num < line_of_text.size ())
{
Return line_of_ text[num]
}
}
Void print_result (const set& los, const string& str, const TextQuery & textclass)
{
Cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.