Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't view sample code. #290

Closed
sbmaruf opened this issue Feb 3, 2019 · 3 comments · Fixed by #295
Closed

Can't view sample code. #290

sbmaruf opened this issue Feb 3, 2019 · 3 comments · Fixed by #295

Comments

@sbmaruf
Copy link

sbmaruf commented Feb 3, 2019

I'm following this page.
The colab notebook can't be accessed. Here is the link of the page. I am trying to access sample code link. https://github.com/google/sentencepiece/blob/master/tensorflow/README.md

@omarsar
Copy link

omarsar commented Feb 5, 2019

Same problem here as well! I also wasn't able to run the example code on the README file. I figured the interface changed. Or I may be wrong?

>>> import sentencepiece as spm
>>> s = spm.SentencePieceProcessor()
>>> s.Load('spm.model')
>>> for n in range(5):
...     s.SampleEncodeAsPiece('New York', -1, 0.1)
... 
['▁', 'N', 'e', 'w', '▁York']
['▁', 'New', '▁York']
['▁', 'New', '▁Y', 'o', 'r', 'k']
['▁', 'New', '▁York']
['▁', 'New', '▁York']

@ebuildy
Copy link
Contributor

ebuildy commented Feb 17, 2019

You can use dir(s) to list the available methods:

['DecodeIds', 'DecodeIdsAsSerializedProto', 'DecodePieces', 'DecodePiecesAsSerializedProto', 'EncodeAsIds', 'EncodeAsPieces', 'EncodeAsSerializedProto', 'GetPieceSize', 'GetScore', 'IdToPiece', 'IsControl', 'IsUnknown', 'IsUnused', 'Load', 'LoadFromSerializedProto', 'LoadOrDie', 'LoadVocabulary', 'NBestEncodeAsIds', 'NBestEncodeAsPieces', 'NBestEncodeAsSerializedProto', 'PieceToId', 'ResetVocabulary', 'SampleEncodeAsIds', 'SampleEncodeAsPieces', 'SampleEncodeAsSerializedProto', 'SetDecodeExtraOptions', 'SetEncodeExtraOptions', 'SetVocabulary', '__class__', '__del__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__len__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__swig_destroy__', '__swig_getmethods__', '__swig_setmethods__', '__weakref__', 'bos_id', 'decode_ids', 'decode_ids_as_serialized_proto', 'decode_pieces', 'decode_pieces_as_serialized_proto', 'encode_as_ids', 'encode_as_pieces', 'encode_as_serialized_proto', 'eos_id', 'get_piece_size', 'get_score', 'id_to_piece', 'is_control', 'is_unknown', 'is_unused', 'load', 'load_from_serialized_proto', 'load_vocabulary', 'nbest_encode_as_ids', 'nbest_encode_as_pieces', 'nbest_encode_as_serialized_proto', 'pad_id', 'piece_to_id', 'reset_vocabulary', 'sample_encode_as_ids', 'sample_encode_as_pieces', 'sample_encode_as_serialized_proto', 'set_decode_extra_options', 'set_encode_extra_options', 'set_vocabulary', 'this', 'unk_id']

Here, there is a typo: SampleEncodeAsPieces

@naveenkumarg651
Copy link

I am trying to run sentencepiece example give in readme but stuck with this following error

import sentencepiece as spm
s = spm.SentencePieceProcessor()
module 'sentencepiece' has no attribute 'SentencePieceProcessor'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants