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

Swig wrapper for apertium-tagger #52

Merged
merged 14 commits into from
Jul 14, 2019

Conversation

singh-lokendra
Copy link
Collaborator

The entire command is passed to the apertium_tagger constructor

  • Set optind=1 in the constructor to ensure multiple instances of apertium_tagger can be created.

@sushain97
Copy link
Member

Was the rename necessary? It's kind of annoying that Git isn't recognizing the rename. Any thoughts on that? Moreover it seems like we're going against the convention now since the apertium-foo.cc file by convention seems to contain main whereas the foo.cc file contains the actual implementation.

@singh-lokendra
Copy link
Collaborator Author

Was the rename necessary?

I though it would be better to have the tagger.cc declared in tagger.h instead of apertium_tagger.h

It's kind of annoying that Git isn't recognizing the rename. Any thoughts on that?

Its probably showing all the changes, and doesn't recognize renaming as a part of it, might be due to editing the header gaurds after renaming the file. It do recognize file rename 52a32a5.

Moreover it seems like we're going against the convention now since the apertium-foo.cc file by convention seems to contain main whereas the foo.cc file contains the actual implementation.

I've kept the main in apertium_tagger.cc and moved the class definition to tagger.cc. Can you elaborate your concern.

@sushain97
Copy link
Member

@singh-lokendra
Copy link
Collaborator Author

Why were the headers moved from the .cc to the .h file?

Since I've added these files in tagger.h, I didn't add them again in tagger.cc. Should I add them again in .cc file

Also, is it necessary that all these source files are included?

Yes, I had to lookup all the undefined objects in shared object and I included all the required files.

e.g. what is a.cc?

Its required for operator overloading. Also a.h is included in various files. Hence its .cc file needs to be linked as well.

@sushain97
Copy link
Member

Since I've added these files in tagger.h, I didn't add them again in tagger.cc. Should I add them again in .cc file

Standard convention is to add includes in the .cc file when possible and only in the header when types from them are necessary. Can they be moved back to their original location?

Yes, I had to lookup all the undefined objects in shared object and I included all the required files.

I see. This wasn't necessary before (for any of the other wrappers, that is)? Does it have something to do with you moving the includes?

Its required for operator overloading. Also a.h is included in various files. Hence its .cc file needs to be linked as well.

Ah. Odd name...

@singh-lokendra
Copy link
Collaborator Author

Standard convention is to add includes in the .cc file when possible and only in the header when types from them are necessary. Can they be moved back to their original location?

I'll check their dependencies on swig and move them back to the .cc file. Should I fix this as well https://github.com/apertium/apertium/blob/master/apertium/pretransfer.cc#L1

I see. This wasn't necessary before (for any of the other wrappers, that is)? Does it have something to do with you moving the includes?

These are dependencies for tagger.cc.

@sushain97
Copy link
Member

I'll check their dependencies on swig and move them back to the .cc file. Should I fix this as well https://github.com/apertium/apertium/blob/master/apertium/pretransfer.cc#L1

Ah, yes. That would be ideal. My bad for not noticing the issue earlier.

These are dependencies for tagger.cc.

Hmm, I see. Maybe we should separate the dependencies in the Python file with comments?

.h has headers required for prototyping
.cc has headers required for definition
Copy link
Member

@sushain97 sushain97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some notes. Mostly nits.

python/apertium_core.i Outdated Show resolved Hide resolved
python/apertium_core.i Outdated Show resolved Hide resolved
python/apertium_core.i Outdated Show resolved Hide resolved
python/apertium_core.i Outdated Show resolved Hide resolved
python/apertium_core.i Outdated Show resolved Hide resolved
python/apertium_core.i Outdated Show resolved Hide resolved
python/apertium_core.i Outdated Show resolved Hide resolved
python/apertium_core.i Outdated Show resolved Hide resolved
apertium/tagger.cc Outdated Show resolved Hide resolved
python/apertium_core.i Outdated Show resolved Hide resolved
python/apertium_core.i Outdated Show resolved Hide resolved
apertium/apertium_tagger.cc Outdated Show resolved Hide resolved
apertium/apertium_tagger.cc Show resolved Hide resolved
@sushain97
Copy link
Member

sushain97 commented Jul 11, 2019

@Vaydheesh can you bring changes from master into this branch? Also perhaps update the Travis build to actually build the Python bindings?

@singh-lokendra
Copy link
Collaborator Author

@Vaydheesh can you bring changes from master into this branch? Also perhaps update the Travis build to actually build the Python bindings?

Are these commands the required for updating my branch? Where upstream points to apertium-master and origin is my fork.

git pull upstream master
git push master origin
git checkout swig_wrapper_tagger
git rebase master
git push origin swig_wrapper_tagger --force

@sushain97
Copy link
Member

Are these commands the required for updating my branch? Where upstream points to apertium-master and origin is my fork.

It looks right. There should be lots of instructions on the web re. updating a fork's branch.

@singh-lokendra
Copy link
Collaborator Author

Also perhaps update the Travis build to actually build the Python bindings?

Should I also add test in makefile to support make test https://github.com/apertium/apertium/blob/master/.travis.yml#L13?

@sushain97
Copy link
Member

Should I also add test in makefile to support make test https://github.com/apertium/apertium/blob/master/.travis.yml#L13?

Huh? The test target already exists: https://github.com/apertium/apertium/blob/master/Makefile.am#L25 ?

@singh-lokendra
Copy link
Collaborator Author

I don't think that it would check for importing the wrapper. python -m apertium_core would fail if all the required symbols aren't present in the shared object https://github.com/Vaydheesh/apertium/blob/swig_wrapper_tagger/python/setup.py.in#L22

@sushain97
Copy link
Member

Oh, are you suggesting adding more tests? If so, go ahead!

Removed: const qualifier from Apertium::basic_Tagger::Flags and derived classes
@sushain97
Copy link
Member

Oh wow. I didn't realize this many functions were const-qualified. I'm not super comfortable with this change without some other input. Another, albeit hacky, approach is adding a patch file that gets applied before building the SWIG wrapper. @unhammer / @TinoDidriksen any thoughts? The diff in question is 51e7c28 and the associated discussion is here: apertium/apertium-python#40 (comment).

@singh-lokendra
Copy link
Collaborator Author

singh-lokendra commented Jul 13, 2019

I have added the script in TESTS 1a177a2#diff-ad9a2d1628d58878eff1ecc2e77834d8R5 still it isn't executed https://travis-ci.com/apertium/apertium/jobs/215825709#L1739. How can I fix this?

@sushain97
Copy link
Member

Don't you need to execute make test in the subfolder as well? Not too familiar with autotools but I can look more into it if you're unable to figure it out. Regardless, I don't consider it a blocker. More concerned with the diff that removes const qualifiers.

@singh-lokendra
Copy link
Collaborator Author

I tried but can't use the python import, so I've reverted back to previous state

@sushain97
Copy link
Member

I tried but can't use the python import, so I've reverted back to previous state

You could probably tackle this by forcing the distro Python version: https://docs.travis-ci.com/user/languages/python/#travis-ci-uses-isolated-virtualenvs. Not too worried about it though.

@@ -26,7 +26,7 @@ namespace Apertium {
class Stream_5_3_3_TaggerTrainer : private basic_5_3_3_Tagger,
public basic_StreamTaggerTrainer {
public:
Stream_5_3_3_TaggerTrainer(const Flags &Flags_);
Stream_5_3_3_TaggerTrainer(Flags &Flags_);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and others don't seem necessary?

Copy link
Collaborator Author

@singh-lokendra singh-lokendra Jul 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started with basic_tagger.h, and made changes according to the errors reported
Error without the changes stream_5_3_3_tagger_trainer.cc:30:20: error: binding reference of type ‘Apertium::basic_Tagger::Flags&’ to ‘const Apertium::basic_Tagger::Flags’ discards qualifiers

@sushain97 sushain97 merged commit fedc754 into apertium:master Jul 14, 2019
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 this pull request may close these issues.

2 participants