glample / fastBPE

Fast BPE
MIT License
656 stars 96 forks source link

[QUESTION] Python Wrapper #12

Closed loretoparisi closed 5 years ago

loretoparisi commented 5 years ago

I'm currently using subword-nmt to run BPE programmatically in Python. This implementation mostly match the fastBPE command line (applyBPE, etc.) like here

# fastBPE/fast applybpe ofn ifn bpe_codes bpe_vocab
bpe = BPE(bpe_codes, merges=-1, separator='@@', vocab=bpe_vocab, glossaries=None)
codes = bpe.process_line(line)

My question is if a swig wrapper of C++ headers to Python could make sense or not instead of using subword-nmt.

Thank you.

glample commented 5 years ago

Fixed in https://github.com/glample/fastBPE/commit/8af0dae779f11d9385d021915dffa0b7d4303e63

glample commented 5 years ago

See usage on the README :)

loretoparisi commented 5 years ago

@glample that's amazing!!!

johnfarina commented 5 years ago

I get the following compilation error when running python setup.py install. This is on macOS, using anaconda3's python 3.7.2

running install
running bdist_egg
running egg_info
creating fastBPE.egg-info
writing fastBPE.egg-info/PKG-INFO
writing dependency_links to fastBPE.egg-info/dependency_links.txt
writing requirements to fastBPE.egg-info/requires.txt
writing top-level names to fastBPE.egg-info/top_level.txt
writing manifest file 'fastBPE.egg-info/SOURCES.txt'
package init file 'fastBPE/__init__.py' not found (or not a regular file)
reading manifest file 'fastBPE.egg-info/SOURCES.txt'
writing manifest file 'fastBPE.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.7-x86_64/egg
running install_lib
running build_py
running build_ext
building 'fastBPE' extension
creating build
creating build/temp.macosx-10.7-x86_64-3.7
creating build/temp.macosx-10.7-x86_64-3.7/fastBPE
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/john/anaconda3/include -I/Users/john/anaconda3/include -arch x86_64 -IfastBPE -I/Users/john/anaconda3/include/python3.7m -c fastBPE/fastBPE.cpp -o build/temp.macosx-10.7-x86_64-3.7/fastBPE/fastBPE.o -std=c++11 -Ofast -pthread
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
fastBPE/fastBPE.cpp:649:10: fatal error: 'ios' file not found
#include "ios"
         ^~~~~
1 warning and 1 error generated.
error: command 'gcc' failed with exit status 1
willy20040711 commented 5 years ago

I get the following compilation error when running python setup.py install. This is on macOS, using anaconda3's python 3.7.2

running install
running bdist_egg
running egg_info
creating fastBPE.egg-info
writing fastBPE.egg-info/PKG-INFO
writing dependency_links to fastBPE.egg-info/dependency_links.txt
writing requirements to fastBPE.egg-info/requires.txt
writing top-level names to fastBPE.egg-info/top_level.txt
writing manifest file 'fastBPE.egg-info/SOURCES.txt'
package init file 'fastBPE/__init__.py' not found (or not a regular file)
reading manifest file 'fastBPE.egg-info/SOURCES.txt'
writing manifest file 'fastBPE.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.7-x86_64/egg
running install_lib
running build_py
running build_ext
building 'fastBPE' extension
creating build
creating build/temp.macosx-10.7-x86_64-3.7
creating build/temp.macosx-10.7-x86_64-3.7/fastBPE
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/john/anaconda3/include -I/Users/john/anaconda3/include -arch x86_64 -IfastBPE -I/Users/john/anaconda3/include/python3.7m -c fastBPE/fastBPE.cpp -o build/temp.macosx-10.7-x86_64-3.7/fastBPE/fastBPE.o -std=c++11 -Ofast -pthread
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
fastBPE/fastBPE.cpp:649:10: fatal error: 'ios' file not found
#include "ios"
         ^~~~~
1 warning and 1 error generated.
error: command 'gcc' failed with exit status 1

I have the same issue.
sys: anaconda3's python 3.7.3.

anjalibhavan commented 4 years ago

I have the above gcc issue as well.