Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7612697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:58:44+00:00 2026-05-31T01:58:44+00:00

i’m trying to extract from proper noun from a tagged file. But the problem

  • 0

i’m trying to extract from proper noun from a tagged file. But the problem is the the code that i’m trying with sometimes gives a error That is :

Traceback (most recent call last):
File "E:\pt\paragraph", line 35, in <module>
sen1= noun(mylist[s])
File "E:\pt\paragraph", line 5, in noun
word, tag = word.split('/')
ValueError: too many values to unpack

The code works fine for some texts but for some it gives the error.

The code:

def noun(words):
nouns = []
for word in words.split():
word, tag = word.split('/')
  if (tag.lower() == 'np'):
    nouns.append(word);
return nouns

def splitParagraph(paragraph):

import re
paragraphs = paragraph.split('\n\n')
return paragraphs

if __name__ == '__main__':
import nltk
rp = open("t3.txt", 'r')
text = rp.read()
mylist = []
para = splitParagraph(text)

for s in para:
mylist.append(s)
for s in range(len(mylist)-1):
sen1= noun(mylist[s])
sen2= noun(mylist[s+1])

The currently i’m trying with works if i remove the 1st paragraph other wise it gives the error.

Sample of the text:

A/at good/jj man/nn-hl departs/vbz-hl ./. Goodbye/uh-hl ,/,-hl Mr./np-hl Sam/np-hl./. Sam/np Rayburn/np was/bedz a/at good/jj man/nn ,/, a/at good/jj American/np ,/, and/cc ,/, third/od ,/, a/at good/jj Democrat/np ./. He/pps was/bedz all/abn of/in these/dts rolled/vbn into/in one/cd sturdy/jj figure/nn ;/. ;/. Mr./np Speaker/nn-tl ,/, Mr./np Sam/np ,/, and/cc Mr./np Democrat/np ,/, at/in one/cd and/cc the/at same/ap time/nn ./.

The/at House/nn-tl was/bedz his/pp$ habitat/nn and/cc there/rb he/pps flourished/vbd ,/, first/rb as/cs a/at young/jj representative/nn ,/, then/rb as/cs a/at forceful/jj committee/nn chairman/nn ,/, and/cc finally/rb in/in the/at post/nn for/in which/wdt he/pps seemed/vbd intended/vbn from/in birth/nn ,/, Speaker/nn-tl of/in-tl the/at-tl House/nn-tl ,/, and/cc second/od most/ql powerful/jj man/nn in/in Washington/np ./.

if i remove the 1st paragraph (A/at good/jj man/nn-hl departs…) the code works. How to solve this problem.

thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:58:46+00:00Added an answer on May 31, 2026 at 1:58 am

    your “word” contains more than one “/”.
    So unpacking it into (tag, word) will not work. You’ll have to figure out how you want to handle the case where your tag/word has more than one “/”.

    def noun(words):
        nouns = []
        for word in words.split():
            items = word.split('/')
            if len(items) == 2:
                tag, word = items
            else:
                # do something else to parse
    
        ....
    

    I just realized you can use the “maxsplit” option to the strings split method if you only want to split on the first “/”.

    >>> word = "a/b/c"
    >>>
    >>> word.split("/", 1)
    ['a', 'b/c']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.