Finding nouns in strings

Does anyone know / can anyone think of a way to find and extract nouns from a string by any chance?.. I know it’s an odd one!

Definitely doable as a Pack. The Pack could send each word out to a 3rd party API like this, which would return the part of speech.

Have you thought about venturing into Pack-land, if you haven’t yet? This would make a great first Pack.

2 Likes

Hey Nick,

I’ve only done the ‘Hello World’ for packs so far but it’s great to know this would work. Looks like the API referenced will only handle single words though - if you know any which will classify the words in a sentence off the top of your head, that’d be ace. I’ll go and do some reading. Thanks again :slight_smile:

You could still this API for that.

The code steps:

  • take in the sentence as a string
  • split the sentence on spaces so you have an array of words
  • send each one to the API. If it’s a noun, keep it, otherwise throw it away
  • return an array of the nouns you kept

Alternatively, you could do all this splitting logic in coda, and keep the pack simple (pack still handles single words, and returns what part of speech it is; in your coda formula, you check if each word is a noun or not and keep the ones that are)

1 Like

Of course! That makes complete sense. Sorry, I totally hadn’t engaged my brain there. Cool, I shall go and have a look at putting a pack together. Cheers!

1 Like

Hey man. Wrong tool for the job. The right tool you need is Python.

Step 1: Go to https://replit.com/ and create a Python program. This will allow you to run python without any configuration whatsoever, else you have to set it up locally on your PC
Step 2: Copy paste the solution: python - Extracting all Nouns from a text file using nltk - Stack Overflow
Step 3: Load your “txt” variable with your text
Step 4: Run your program and enjoy

1 Like

Why is @Nick_HE suggestion the wrong tool @Jake_Nguyen ? Would love to hear your thoughts

The pack that Nick suggested:

  • could be built in 15 min
  • would not have to be set up locally on ones own computer as one can use the pack building web based experience
  • could be used directly in the UI of Coda alongside ones tables, or anywhere else in any Coda doc at any time
  • could be used by anyone around the world who uses coda
  • wouldn’t have any clunky copy or pasting involved anywhere! Or downloading of txt files
2 Likes

It’s not wrong per say, but with Python, you could do a lot of custom things, especially if he has some NLP needs that are serviceable very well by those NLP Python libraries

The upper limit to what you can do in Python is much higher than what you can do in coda would be my summary. Just for reference, the NLTK :: Python Module Index is quite decked out. My personal philosophy is to not re-invent the wheel if it’s not necessary.

I do like the idea of having a get_nouns() formula though. We can do it thru a pack or Coda itself can implement it. It’s extremely niche though so maybe Coda can make it a hidden function

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.