async function fetchAndProcessData()

in src/js/MLSuggest_inference.js [57:95]


  async function fetchAndProcessData() {
    try {
      // Fetch the JSON data
      let queries;
      if (type === "YELP_KEYWORDS_DATA") {
        queries = await get_yelp_keywords();
      } else if (type === "YELP_VAL_DATA") {
        queries = await get_yelp_val_data();
      } else if (type === "NER_VAL_DATA") {
        queries = await get_ner_val_data();
      }
  
  
      // Ensure MLSuggest is initialized
      await MLSuggest.initialize();
  
      // Process each subject and collect results
      const results = [];
      for (const query of queries) {
        const suggestion = await MLSuggest.makeSuggestions(query);
        const res = {
          query,
          intent: suggestion.intent,
          city: suggestion.location.city,
          state: suggestion.location.state
        };
        results.push(res);
      }
  
      // Write results to a file
      await writeResultsToFile(results);
      console.log("Processing completed. Results saved to:", OUTPUT_FILE_PATH);
  
    } catch (error) {
      console.error("Error processing data:", error);
    } finally {
      await MLSuggest.shutdown();
    }
  }