Git Product home page Git Product logo

Comments (3)

boudinfl avatar boudinfl commented on June 9, 2024

Here is a corrected snippet of code for using MultipartiteRank. The API is the same as for the other models.

import os, sys
import pke

# create a MultipartiteRank extractor and set the input language to french (used for
# the stoplist in the candidate selection method)
extractor = pke.unsupervised.MultipartiteRank(input_file= sys.argv[1], language='french')

# load the content of the document, here in CoreNLP XML format
# the stemmer parameter allows to use stems computed using nltk
extractor.read_document(format='corenlp', use_lemmas=False, stemmer='french')

# select the keyphrase candidates, for TopicRank the longest sequences of 
# nouns and adjectives (UD French tagset)
extractor.candidate_selection(pos=['ADJ', 'NOUN', 'PROPN'])

# weight the candidates using a random walk with default parameters.
extractor.candidate_weighting()

# get the n-highest (60) scored candidates
tuples = extractor.get_n_best(n=60)
print(tuples)

Best,

Florian

from pke.

MGoulley avatar MGoulley commented on June 9, 2024

I get the same issue when i use your snippet :

Traceback (most recent call last):
File "xml_to_kw.py", line 10, in
extractor.candidate_weighting()
File "/home/matthias/.local/lib/python2.7/site-packages/pke/unsupervised/graph_based.py", line 481, in candidate_weighting
self.weight_adjustment(alpha)
File "/home/matthias/.local/lib/python2.7/site-packages/pke/unsupervised/graph_based.py", line 442, in weight_adjustment
for start, end in self.graph.edges_iter(first):
AttributeError: 'DiGraph' object has no attribute 'edges_iter'

(I use networkx-2.1 in Python2.7 )

Thanks for your response @boudinfl ;)
Matt

from pke.

boudinfl avatar boudinfl commented on June 9, 2024

This problem comes from networkx 2.0 in which edges_iter() was removed. This bug is fixed in the 1.7 release.

Let me know if you encounter any problem.

from pke.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.