Closed Bowid closed 4 years ago
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.
If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!
Hello Bowid. I am also working on python wrapper. Can you please write back with your contacts to pavanmirla @gmail. Thanks
Hello Bowid. I am also working on python wrapper. Can you please write back with your contacts to pavanmirla @gmail. Thanks
Replied. Also here is the sample, let it be here
import starwrap
model_path = '/path/to/trained/model'
args = starwrap.args()
model = starwrap.starSpace(args)
model.initFromSavedModel(model_path)
line = input("Enter text for classification: ")
parsed = model.parseDoc(line, ' ')
# Output is list of tuples in format (probability, token_id)
# Predict takes two arguments: parsed doc and maximum predictions count
tokens = model.predict(parsed, 10)
probabilities = [item[0] for item in tokens]
# Token_id is integer, thus it should be rendered to feature (string)
features = model.renderTokens(tokens)
for feature, probability in zip(features, probabilities):
print('Feature {f} probability {p}'.format(f=feature, p=probability))
I have some more thoughts to make things more pythonic, but it is nice to have feedback from FB guys and probably merge this PR to master.