Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add book language ID fields #305

Open
wants to merge 36 commits into
base: master
Choose a base branch
from

Conversation

baieric
Copy link

@baieric baieric commented May 21, 2018

These are backend changes for eventually supporting the use the Language Ontology API in Poly. Hopefully these changes can be merged immediately.

There are some TODO comments where the code could be cleaner. I'll add Github comments to these for visibility.

There are two user-facing changes in this PR:

  1. The search URL can now be /search?q=<query_string>&glottocode=<glottocode_string>. The glottocode parameter is optional and not used currently (unless the user manually puts it in the URL). This will match all results containing query_string OR with language ID equal to glottocode_string. Let me know how you feel about this.
  2. I got rid of the use of the are_close? function, meaning that search results will work differently. I noticed some annoying results where "English" was close to "Spanish", which seems very undesirable. I didn't play around with the desired_distance constant, but maybe lowering it could fix this, rather than completely getting rid of it.

# only returns an ID if the verbatim search returns exactly one result
def id_check(input_lang)
# TODO do not hard-code this URL, move to a config constant
url_string = 'http://localhost:6543/search?q=' + input_lang + '&whole=true';
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure how to properly set up a config constant. Ideally this constant can be used by both the Ruby code and the React code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made the production url an environment variable on Heroku and on my local .ENV, happy to show you

# TODO this function copied from books_controller. put in a helper class
# given an identifier string, get the language ID
# only returns an ID if the verbatim search returns exactly one result
def id_check(input_lang)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should be in a helper class, but I wasn't familiar with where this class would go or how to add a dependency to it.

@baieric baieric changed the title add book language ID fields to DB and controllers (WIP) add book language ID fields to DB and controllers May 21, 2018
@baieric baieric changed the title add book language ID fields to DB and controllers add book language ID fields May 21, 2018
@FredericoAndrade
Copy link
Contributor

Looks great! All i need in order to test this is to get a local instance of glottolog3 running. Any chance you could update the readme there with instructions on how to get it running? Got requirements installed but couldn't quite get setup.py or serve.py running.

@FredericoAndrade
Copy link
Contributor

FredericoAndrade commented May 29, 2018

@baieric I've gone ahead and updated the url to reference an environment variable which points to the Heroku deploy of the ontology, but have started to get this error: Failed to open TCP connection to :80 (Connection refused - connect(2) for nil port 80). Any thoughts? Might I need some form of API key or config beyond just the url?

@baieric
Copy link
Author

baieric commented May 30, 2018

@FredericoAndrade Do you have a typo somewhere? Sounds similar to this issue: jnunemaker/httparty#393

This PDF has setup instructions for glottolog3. You'll need to get a local DB running as well. The instructions are intended for Heroku, but if you do steps 1-4 and step 6, it should run locally.

Setting-Up-Wikitongues-Ontology-API-Service.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants