Your cart is currently empty!
Published:
·
Last modified:
Are you looking to understand the structural elements of language in large volumes of text like web content, technical documents, or anchor text? Syntax analysis with Google’s Natural Language API is one way to better understand sentence structures.
This tutorial will help you master the Syntax Analysis module of Google’s Natural Language API, all without needing to write a single line of code! This tutorial is suitable for complete beginners, as we will implement this machine learning API in Google Sheets via Apps Script code. You don’t need prior coding knowledge, I’ll lead you through the entire process, enabling you to dissect the grammatical structure of your text data.
Syntax analysis, the second phase of natural language processing, involves examining the arrangement of words in a sentence to understand their grammatical structure. This process identifies how words function together to form coherent sentences, breaking down phrases into elements like nouns, verbs, adjectives, etc., and analyzing their relationships to one another.
Simply put, syntactic analysis breaks up a given text into a series of sentences and tokens (generally, words) and provides linguistic information about those tokens.
For example, in the sentence “The quick brown fox jumps over the lazy dog,” syntax analysis would identify “fox” as the subject, “jumps” as the verb, and “over the lazy dog” as the prepositional phrase indicating where the fox jumps. This analysis helps in understanding the sentence’s structure, which is crucial for further linguistic, semantic analysis, or computational processes, such as translating text or extracting information (like entities and sentiment).
The Natural Language API is a versatile API that draws from a vast library filled with knowledge about language structure, grammar structure, sentiment, and real world entities. It’s trained on massive amounts of text data, allowing it to:
The analyzeSyntax
module of Google’s Natural Language API is designed to parse the text you provide, breaking it down into its syntactic components to reveal the grammatical structure and relationships between different parts of the sentence.
The API will take text that you provide and return a response that provides the following information:
The language would be automatically detected from the text analysed, but you can also specify document language as well, as long as it’s within the list of supported languages.
Check out the additional resources by Google Cloud to practice working with this API, and the syntax analysis module specifically:
Having selected your Google Cloud project, navigate to the APIs and Services menu > Credentials.
Then, click on the Create Credentials button from the navigation next to the page title, then select API Key from the drop-down menu.
This is the easiest to use, but least secure method of authentication – you might consider alternatives for more complex projects.
Once you click on the Create API key button, there will be a pop-up menu that will indicate that the API key is being created, after which it will appear on the screen for you to copy.
You can always navigate back to this section of your project, and reveal the API key at a later stage, using the Show Key button. If you ever need to edit or delete the API key, you can do so from the drop-down menu.
The next step is to decide on and organise the content you want to analyse syntax for into Google Sheets.
For the purposes of the demo today, I’ve scraped content from a news website using Screaming Frog.
Once you have your content organised into a spreadsheet-suitable format, you can move on to the next step.
This Google Sheets template, integrated with an Apps Script, leverages the Google Cloud Natural Language API for syntax analysis. It allows users to analyze grammatical structure and extract parts of speech from text directly in Google Sheets, simplifying the process of linguistic data processing. This tool is particularly useful for analyzing syntax in textual data such as essays, articles, reports, and feedback. It’s designed to be user-friendly, making it accessible for beginners without any need for coding skills.
To prepare the data for analysis, we need to do two things – organize the content for analysis, and paste the API key in the script.
In Google Sheets, open the Extensions menu, and click on Apps Script.
Open the SyntaxAnalysis.gs script attached, and select the text that says enterAPIkey. Replace it with your Google Cloud API project key. Then click on the disk icon to Save, and return to the Google Sheet file.
Paste your content for analysis in the Working Sheet. Ensure that you keep the top-level navigation.
You need an ID for each item (like a URL, or customer identifier, depending on the content you are analysing), and content to analyse. Once you are done pasting your text, also clear the contents of column C: Syntax Structure (keep only the name of the column, as specified earlier).
To run the analysis, navigate to the Syntax Tools menu and click on the button, titled Mark Syntax Structure.
You might need to enable the permissions for the Apps Script to run before it runs (click on “Go to Syntax Analysis Google Natural language API (unsafe)“, then click “Allow”, and if that is the case, then navigate back to the menu above and click the same button again, once you’ve authorised the script.
An indication that the script has started executing is that there will be a pop-up in the bottom-right part of the screen notifying you that the syntax analysis has started, and for each of the individual texts, there will be a label of ‘complete’ in column C of the Working sheet.
Now, you can navigate to the Syntax Data sheet. Your data, organised per your identifier, will be split per sentence (indicated in column B), and the API response will be organised in the other columns.
While analyzing the syntax structure data in a spreadsheet can be informative, visualizing these details in Looker Studio can significantly enhance your understanding and presentation of the linguistic features of your text.
Set up a Syntax Analysis Dashboard in Looker Studio, so you can visualize the details of syntax parsing effectively:
By leveraging these visualization techniques, you can uncover deeper linguistic patterns and improve the effectiveness of your text-based projects or research.
Syntax analysis offers multiple advantages for improving SEO strategies by deeply understanding and optimizing the textual structure of web content. Using syntax analysis in Google Sheets can be a valuable addition to an SEO toolkit for several reasons, though it might not be necessary for every project:
While not every SEO project will require syntax analysis, it can provide deep insights into content structure when tackling specific challenges, such as enhancing readability or shifting the brand tone of voice.
Syntax analysis, while less commonly used than other SEO tools, offers opportunities to refine and enhance organic search strategies. This linguistic approach can dissect and interpret the structure of text in ways that can be beneficial for SEO and digital marketing. Here are some practical applications of syntax analysis that can help improve your organic search efforts:
By integrating syntax analysis into your SEO processes, you can gain deeper insights into how the structure of text affects user interaction and search engine performance.
As mentioned earlier, the Natural Language API has several additional capabilities that include text classification, entity analysis (which also includes entity sentiment analysis), and syntax analysis. Explore other step-by-step guides for this API by visiting the resources, linked below:
Meet the Author
Share this post on social media:
Leave a Reply