evaluate-news-nlp

所属分类:自然语言处理
开发工具:JavaScript
文件大小:119KB
下载次数:0
上传日期:2023-01-24 02:29:26
上 传 者sh-1993
说明:  评估新闻nlp,,
(evaluate-news-nlp,,)

文件列表:
.babelrc (89, 2020-05-10)
.env (56, 2020-05-10)
REQUIREMENTS.md (685, 2020-05-10)
package-lock.json (417861, 2020-05-10)
package.json (1247, 2020-05-10)
src (0, 2020-05-10)
src\client (0, 2020-05-10)
src\client\index.js (342, 2020-05-10)
src\client\js (0, 2020-05-10)
src\client\js\formHandler.js (1368, 2020-05-10)
src\client\js\urlValidation.js (627, 2020-05-10)
src\client\styles (0, 2020-05-10)
src\client\styles\base.scss (160, 2020-05-10)
src\client\styles\footer.scss (92, 2020-05-10)
src\client\styles\form.scss (616, 2020-05-10)
src\client\styles\header.scss (126, 2020-05-10)
src\client\styles\resets.scss (1158, 2020-05-10)
src\client\views (0, 2020-05-10)
src\client\views\index.html (2080, 2020-05-10)
src\server (0, 2020-05-10)
src\server\app.js (652, 2020-05-10)
src\server\localServer.js (111, 2020-05-10)
src\server\mockAPI.js (119, 2020-05-10)
src\server\postHandler.js (601, 2020-05-10)
src\test (0, 2020-05-10)
src\test\app.test.js (312, 2020-05-10)
src\test\formHandler.test.js (158, 2020-05-10)
src\test\postHandler.test.js (981, 2020-05-10)
src\test\urlValidation.test.js (657, 2020-05-10)
webpack.dev.js (1728, 2020-05-10)
webpack.prod.js (1062, 2020-05-10)

# Project Instructions This repo is your starter code for the project. It is the same as the starter code we began with in lesson 2. Install and configure Webpack just as we did in the course. Feel free to refer to the course repo as you build this one, and remember to make frequent commits and to create and merge branches as necessary! The goal of this project is to give you practice with: - Setting up Webpack - Sass styles - Webpack Loaders and Plugins - Creating layouts and page design - Service workers - Using APIs and creating requests to external urls On top of that, I want to introduce you to the topic of Natural Language Processing. NLPs leverage machine learning and deep learning create a program that can interpret natural human speech. Systems like Alexa, Google Assistant, and many voice interaction programs are well known to us, but understanding human speech is an incredibly difficult task and requires a lot of resources to achieve. Full disclosure, this is the Wikipedia definition, but I found it to be a clear one: > Natural language processing (NLP) is a subfield of computer science, information engineering, and artificial intelligence concerned with the interactions between computers and human (natural) languages, in particular how to program computers to process and analyze large amounts of natural language data. You could spend years and get a masters degree focusing on the details of creating NLP systems and algorithms. Typically, NLP programs require far more resources than individuals have access to, but a fairly new API called Aylien has put a public facing API in front of their NLP system. We will use it in this project to determine various attributes of an article or blog post. ## Getting started It would probably be good to first get your basic project setup and functioning. Follow the steps from the course up to Lesson 4 but don't add Service Workers just yet. We won't need the service workers during development and having extra caches floating around just means there's more potential for confusion. So, fork this repo and begin your project setup. Remember that once you clone, you will still need to install everything: `cd` into your new folder and run: - `npm install` ## Setting up the API The Aylien API is perhaps different than what you've used before. It has you install a node module to run certain commands through, it will simplify the requests we need to make from our node/express backend. ### Step 1: Signup for an API key First, you will need to go [here](https://developer.aylien.com/signup). Signing up will get you an API key. Don't worry, at the time of this course, the API is free to use up to 1000 requests per day or 333 intensive requests. It is free to check how many requests you have remaining for the day. ### Step 2: Install the SDK Next you'll need to get the SDK. SDK stands for Software Development Kit, and SDKs are usually a program that brings together various tools to help you work with a specific technology. SDKs will be available for all the major languages and platforms, for instance the Aylien SDK brings together a bunch of tools and functions that will make it possible to interface with their API from our server and is available for Node, Python, PHP, Go, Ruby and many others. We are going to use the Node one, the page is available [here](https://docs.aylien.com/textapi/sdks/#sdks). You get 1000 free requests per day. ### Step 3: Require the SDK package Install the SDK in your project and then we'll be ready to set up your server/index.js file. Your server index.js file must have these things: - [ ] Require the Aylien npm package ``` var aylien = require("aylien_textapi"); ``` ### Step 4: Environment Variables Next we need to declare our API keys, which will look something like this: ``` // set aylien API credentias var textapi = new aylien({ application_id: "your-api-id", application_key: "your-key" }); ``` ...but there's a problem with this. We are about to put our personal API keys into a file, but when we push, this file is going to be available PUBLICLY on Github. Private keys, visible publicly are never a good thing. So, we have to figure out a way to make that not happen. The way we will do that is with environment variables. Environment variables are pretty much like normal variables in that they have a name and hold a value, but these variables only belong to your system and won't be visible when you push to a different environment like Github. - [ ] Use npm or yarn to install the dotenv package ```npm install dotenv```. This will allow us to use environment variables we set in a new file - [ ] Create a new ```.env``` file in the root of your project - [ ] Go to your .gitignore file and add ```.env``` - this will make sure that we don't push our environment variables to Github! If you forget this step, all of the work we did to protect our API keys was pointless. - [ ] Fill the .env file with your API keys like this: ``` API_ID=************************** API_KEY=************************** ``` - [ ] Add this code to the very top of your server/index.js file: ``` const dotenv = require('dotenv'); dotenv.config(); ``` - [ ] Reference variables you created in the .env file by putting ```process.env``` in front of it, an example might look like this: ``` console.log(`Your API key is ${process.env.API_KEY}`); ``` ...Not that you would want to do that. This means that our updated API credential settings will look like this: ```javascript // set aylien API credentials // NOTICE that textapi is the name I used, but it is arbitrary. // You could call it aylienapi, nlp, or anything else, // just make sure to make that change universally! var textapi = new aylien({ application_id: process.env.API_ID, application_key: process.env.API_KEY }); ``` ### Step 5: Using the API We're ready to go! The API has a lot of different endpoints you can take a look at [here](https://docs.aylien.com/textapi/endpoints/#api-endpoints). And you can see how using the SDK simplifies the requests we need to make. I won't provide further examples here, as it's up to you to create the various requests and make sure your server is set up appropriately. ## After the Aylien API Once you are hooked up to the Aylien API, you are most of the way there! Along with making sure you are following all the requirements in the project rubric in the classroom, here are a few other steps to make sure you take. - Parse the response body to dynamically fill content on the page. - Test that the server and form submission work, making sure to also handle error responses if the user input does not match API requirements. - Go back to the web pack config and add the setup for service workers. - Test that the site is now available even when you stop your local server ## Deploying A great step to take with your finished project would be to deploy it! Unfortunately its a bit out of scope for me to explain too much about how to do that here, but checkout [Netlify](https://www.netlify.com/) or [Heroku](https://www.heroku.com/) for some really intuitive free hosting options.

近期下载者

相关文件


收藏者