Smart email reading - ruby-on-rails

I am working on a erp system, being developed using Ruby on Rails. I want to create a sales order by reading the contents of the email. I can recognize by reading the contents if its a sales order or inquiry.
Now a step forward I want to read email and fetch the items in the list. I am planning to take words from the email and search them in the database under items. I can't fix a certain format for the email.
I am going to use following approach.
I'll be using ferret(initially, may switch to sphinx or similar) to search the items in the emails content.
1). Loop through items table and search them for exact phrase match.
Email.find_with_ferret("item+name")
2). Search email for item name split keyword. Email.find_with_ferret("items nice name")
3). Fuzzy search Email.find_with_ferret("items nice name~")
Please help me to improve this.

You're going to need to intercept the emails with rails. Here's a decent article explaining the various approaches to doing this:
http://steve.dynedge.co.uk/2010/09/07/incoming-email-in-rails-3-choosing-the-right-approach/

Related

IMPORTRANGE cannot be used along with normal filtering system

I have a website in English that I just translated in multiple languages.
For my English website, I have a dashboard where I track the performance of all my URLs on a monthly basis. I update this list when a new article is being published. Now, every time a new articles is published in English, it will be automatically translated in other languages and a new URL will be added to my website.
I'm trying to find a way to mirror my English report for all the other languages without having to maintain the URLs list the same way I do with English.
I thought using an IMPORTRANGE from my English master file where I will grab the list of URLs would be the best solution. However, by doing this, I won't be able to use the filter in my other dashboards.
Any suggestion on how to achieve this?
I've made a sample sheet to quickly show my issue.
If you have an imported range and manually input data, you won't be able to "join" them for the sorting part inside the filter. I was asking you if source data would remain in the same order, because if it does (meaning your new data will be "aligned" row by row with your manually input sales), you can sort and filter the range via formula in another column:
=SORT(A2:B,2,0)
With some filter:
=SORT(FILTER(A2:B,B2:B>=10),2,0)

view search queries by popuarity containing keyword

I have been spending some time watching the search queries that bring people to my site on google analytics recently, in order to see if people are finding exacty what they are looking for and if not creating that new content. But i figured an easier way would be to what search queries are popular. But containing a keyword that relates to my site.
for example, i want to see all the most queried search terms that contain "in japanese".
like "dog in japanese", "i love you in japanese"
I have found http://www.google.com/trends/
but after playing with it for a while it doesnt seem like i can do this. seems like i can just see popularity of spesific queries. I dont want to see how popular specific queries are, i want to see what queries containing x are popular. Anywhere i can do this?
If you join the Google AdWords program, you can use the Keyword Planner tool to try out keywords and immediately get the number of searches per month in a chosen geography. This is a very interesting tool. See http://adwords.google.com.
I'm not sure this question belongs here on SO though.

Can anyone recommend a gem for searching that actually allows me to easily filter my results in ruby on rails?

I've tried thinking sphinx after being pointed in that direction and simple filtering seems impossible. I've googled and asked questions for 2 days now and it seems it can't be done which is shocking because it's something commonly done when searching on websites.
All I would like to do add filtering options to my search form such as filtering by one or a combination of:
When user hits browse page all the sites users are returned but showing 20 results per page
Filtering options
in: location
who are: sexual preference
between the ages: age range
and located in: country
My search page works fine because all I require is 1 textfield a user uses for finding users by email, username or full name. My browse page is a different story because I'm using 1 form with multiple text fields and one or two select fields.
Example
Is there a gem that does this easily and performs well at the same time?
or would doing this manually via find methods be the only way?
Kind regards
Apart from using Sphinx and Thinking Sphinx, you can think of those gems: meta_where and meta_search
However after reading your description I think Sphinx is the best choice here indeed.
You wrote that it seems impossible to apply simple filtering using Thinking Sphinx. Let me explain a bit of Thinking Sphinx within the post you mentioned under the link: Example
You can go for Elasticsearch. Ruby has the 'Tire' gem, which is a client for ElasticSearch http://www.elasticsearch.org/

Ruby on Rails 3 search external website source based on top google result

I'm having a hard time finding out where to start with this one. I pull information from an external website and put some of the content on my page. I think I need two things done. 1. A google search that takes the url of the top search given a name of my current object. 2. A way to examine the source of the result and output the information of a tag with a specific class.
To better explain this, I'll create a hypothetical situation: Say I have a website that lists mattresses and gives reviews. Say I want to add other websites reviews and in this website there's a tag like 3.5/5. Then I want to display this review along with a link to the external page. Is there a way to search the site like "site:http://mattressreviewsite/ #matress.name", pull that top url, and then search the source for the string "class='rating'" and display this in my view?
Thanks for any help or guidance. I'm using Rails 3.
You need an HTTP client (httparty, net/http-default) for that and do some parsing to get the required results.
Go study the url patterns of google (as far as I remember it was google.com?q=search_string) and use the http client for requests (get/post). Parse the result (there are many HTML parser gems available too) to get what you need and for any subsequent HTTP requests. And don't forget the 'I am feeling lucky' feature of google which returns only one result.
All the best!

Twitter search for anything from a certain source

The Twitter-search features the possibility to search for a source of tweet by using the parameter "source:" (e.g. source:tweetdeck).
If I just search for that it complains about a missing query, but I actually want to search for any tweets from a certain source.
Is that possible?
You need to have some form of criteria, even if it's just 'recent tweets'. To query every single tweet is, I suspect, not possible at all and certainly not within the capabilities of the API.
Note: My mistake - was thinking of one of the REST APIs.

Resources