Skip to main content

A general function that extracts a search query from spoken text given search terms to look out for.

Project description

Python Search Query Finder

General rule-based function that extracts a search query from spoken text given search terms to look out for.

Some possible search terms include 'to', 'on', 'for', 'about'

e.g. 'do a google search on Python.'
    search term = on
    query found = Python

This function also ignores false search_term_indicators such as 'like to', 'love to', 'want to'

e.g. 'I want to do a google search on Python'
     false search term = to
     false search term indicator = want
     actual search term = on
     query found = Python

Thus, in the above example, the function will correctly ignore 'do a google search on Python' as a possible search query and will capture 'Python' as the right query.

Other exmaples of use cases:

'Send an email to Alex'
  search term = to
  query found = Alex
 Arguments: <string> spoken_text, <list> feature_patterns=[],
            <list> search_terms=['to', 'on', 'for', 'search'], <list> false_search_term_indicators=['like', 'love', 'want', 'ready']
Return type: <string> spoken_text (now stripped down to only the search query.)

Installation

pip install search_query_finder

Example usage

from search_query_finder import find_query
# You can call the function, passing only the sentence.
query1 = find_query.find_query("do a google search on Python programming.")
# expected result = 'Python programming.'

# You can also call the function, passing the sentence along with the search_terms you would like the function to search for. By default, the search terms are set to be = ['to', 'on', 'for', 'search']
query2 = find_query.find_query("send an email to Alex", search_terms=["to"])
# expected result = 'Alex'

# You can also call the function, passing the sentence along with the false_search_term_indicators you want. By default, these are set to be = ['like', 'love', 'want', 'ready']
query3 = find_query.find_query("I would like to do a google search for the python programming language", false_search_term_indicators=["like"])
# expected result = 'the python programming language'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

search_query_finder-0.0.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

search_query_finder-0.0.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file search_query_finder-0.0.1.tar.gz.

File metadata

  • Download URL: search_query_finder-0.0.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.1

File hashes

Hashes for search_query_finder-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f8b20f22444ad5587b7e760a47e82979860507720e563aab4aac2fb6c5434734
MD5 c1469a86630b57937536bfcb742eb5ca
BLAKE2b-256 4b9b8e0509835169b9e377db18d1497a011256e9ac1a06411282ac6860532b94

See more details on using hashes here.

File details

Details for the file search_query_finder-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: search_query_finder-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.1

File hashes

Hashes for search_query_finder-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8ddc6916d8e489dfa15ea87884b7f23771cf78a7ba6dec345a66877f50bbdbec
MD5 146f649809973771cb5ce12341bffb49
BLAKE2b-256 a2a98c2c2689cb530caf8deff3005046cb289ec52f13fa62bd2410517486f9e4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page