Naive bayesian classifier in java - can anyonetraslate this for me please??

Hi, ive written out how i want the classifier to work with regards to authorship attrbution, but im having trouble translating it into java since im new to this language and havent really done any programming before. This may not make sense as a classifier but its how i want my program to work. There's a training text file (a list of 300 words taken from the text of an author), and two author text files (two files with 50 words in each, these words r distinguishing words of the authors). Can you help??
PART 1
For each author distinguisher set, For total number of distinguisher words in each training text, For each author's distinguisher words, If word same as training text word, add to token set, otherwise ignore Return token out
For each token count Divide number of words in token count by number of words in author distinguisher set (store value!)
PART 2
For each author dstinguisher set, Divide the number of words that appear in training set by total number of words in distinguisher set (store value!)
PART 3
Divide number of words in training set that appear in author distinguisher set by the total number of words in the training set (store value!)
PART 4
(VALUE FROM PART 1 * VALUE FROM PART 2) / VALUE FROM PART 3
repeat all the above for Author 2
thanks to anyone that can help!

a pretty challenging assignment for someone that is new to the language. most new kids get "hello world".
"trouble translating it" - what do you want? no one will write this for you. give it a try and post specific questions when they come up. if you can't do that, go drop the course. it sounds like you don't have the prerequisites.
when i read the descriptions, they write themselves:
1. read in the training text file and store it in memory in a data structure. do this once.
2. read in each of the author training files. if a word doesn't appear in the data structure, add it.
3. you'll need a data structure that will let you keep a running total of word count by word.
4. division - have they taught you that yet?
so - can you read a file? do you know any data structures that might be suitable? (hint: think Map)
break the problem up into smaller parts. can you read a file? can you break it up into words? do you know how to store those words? do you know how to keep a running total? solve each one and your problem will be solved.
%

Similar Messages

  • Hey, I have an unopened iPad mini that I won at work and I'm wondering if there's an upgrade option where I can exchange this for an iPad mini with retina display? Thanks

    Hey, I have an unopened iPad mini that I won at work and I'm wondering if there's an upgrade option where I can exchange this for an iPad mini with retina display? Thanks

    Take it to an Apple store and ask. All they can do is say no. They may ask for a purchase receipt to make sure it's not stolen.
     Cheers, Tom

  • I want to watch 2d movies converted to 3d, is there any software which can do this for mac, i know there are many for windows.Or any player which can do this?

    I want to watch 2d movies converted to 3d, is there any software which can do this for mac, i know there are many for windows.Or any player which can do this?
    Or may be i can can watch normal 3d movies on my macbookpro with a glass?

    Xilisoft 3D Video Converter for Mac -  3D converter to convert 3D ...
    Mac 3D Video Converter - 3D Converter convert 2D video to 3D, 3D ...
    Convert DVD Movies to 3D Mac - Best 2D to 3D Converter
    4Media 2D to 3D Video Converter for Mac: Convert 2D video to 3D ...
    Convert 2D Video to 3D for Mac- Tutorial for You about Using 2D ...

  • I cannot control the sensor on my Mac, it moves by itself, and opens different pages. What can cause this problem? please help me.

    I cannot control the sensor on my Mac, it moves by itself, and opens different pages. What can cause this problem? please help me.

    There are several possible causes for this issue. Take each of the following steps until it's resolved.
    1. Follow the instructions in this support article.
    2. Reset the System Management Controller.
    3. If you're using a Bluetooth trackpad, investigate potential sources of interference, including USB 3 devices.
    4. A swollen battery in a MacBook Pro or Air can impinge on the trackpad from below and cause erratic behavior. If you have trouble clicking the trackpad, this is likely the reason. The battery must be replaced.
    5. There's a report that a (possibly defective) Thunderbolt Ethernet adapter can cause the built in trackpad of a MacBook to  behave erratically. If you're using such an adapter, disconnect it and test.
    6. There's also a report of erratic cursor movements caused by an external display that was connected but not turned on.
    7. If none of the above applies, or if you have good reason to think your computer is being controlled remotely, remove it from the network by turning off Wi-Fi, disconnecting from a Bluetooth network link, and unplugging the Ethernet cable or USB modem, whichever is applicable. If the cursor movements stop immediately, you should suspect an intrusion.

  • My wife just bought her first Iphone  a 4s a fwe months ago, its secondhand a few months ago but it came with ios7.  Now the phone has stopped working and is asking to be registered with a Developer Program portal  any ideas how I can fix this for her?

    my wife just boughtnher first apple an iphone4s she got it secondhand about last july , it came with ios7 which had not been released but today its stopped working and asking to be registered with a developers program,  how can I restore her phone and hopefullykeep her current data. Please keep your answer simple we are not it people thanks.

    Well, you have your answer perhaps as to why the phone was being sold in the first place - rather than being a registered developer, the previous owner probably downloaded and installed an illegal copy of iOS 7 beta on the phone and it has now bricked the phone.  Some people did this and of course they could not wait to get their hands on iOS 7, but now it has been released officially, everybody moans.
    The only thing you can do is try resetting the phone again.  Connect it to iTunes and install iOS 7.0.2 and restore it as new and see if that works.  This might help the phone but will not preserve data.
    If it still won't work, then I suggest that you confront the previous owner of the phone and return it for a full refund and start again, but this time buy the phone from a legitimate source.

  • My BB Playbook doesn't charge and turn on. Nothing can solve this problem. Please help!!!!

    Hi everybody!
    My BB playbook doesn't charge and turn on.  
    When I tried to charge it,  at first ,the red color appears for 10 seconds and after the green color starts blinking several times. And that's all. Every time when I am charging it the same thing is repeating. What should I do in this case???
    If someone knows how to solve this issue please HELP!

    Hey LM344,
    Welcome to the BlackBerry Support Community Forums.
    If you're receiving the flashing green LED light, it sounds like the BlackBerry PlayBook battery is completely drained.  I suggest plugged the BlackBerry PlayBook into the wall charger for several hours to get a charge again.
    Let me know if the issue still persists after charging it after several hours.
    Cheers.
    -ViciousFerret
    Come follow your BlackBerry Technical Team on Twitter! @BlackBerryHelp
    Be sure to click Like! for those who have helped you.
    Click  Accept as Solution for posts that have solved your issue(s)!

  • No one can answer this question. Please hel

    I'm looking at the T5400 and P5800. Both are 5. sound systems list price of 79.99. Both are 74 Watts. I'm trying to find out a breakdown of which may give the better sound or the differences in performance between the 2. I have the following questions :
    . What is the difference between channel dri'ven (T5400) and 2 channels dri'ven (P5800)
    2. The 5400's have tweeters (but are channel dri'ven) while the 5800 does not (but are 2 channels dri'ven), which will be giving out the better sound?

    hi, perhaps that your problem is the custom gui theme for firefox.
    Uninstall it and use just the default theme

  • Can you confirm for me please? - jdbc to pl/sql record types

    Hi, I was hoping somebody could confirm the following please? I've been researching this in the Oracle JDBC docs and the Internet, but would feel more comfortable if somebody would confirm my findings.
    I have a 10g database pl/sql procedure that takes a pl/sql record type as both IN and OUT parameter. I'm not allowed to modify this legacy procedure, though I may create new supporting code.
    My research shows there is no inherit support in JDBC for Oracle pl/sql record types as per the Oracle JDBC docs.
    As a solution, if the procedure only returned a record type, my understanding is I could create a ref cursor in pl/sql, as well as a wrapper procedure that calls my original procedure, and returns the record type through the ref cursor. This could then be used by my JDBC code as JDBC supports ref cursors as a return type.
    However in my case, as the record type is both an IN and OUT parameter of my procedure, my research so far says JDBC support for ref cursors does not allow the writing of value to the ref cursor to be submitted back to the database. Is this correct?
    If this limitation exists, as such the better (and only?) solution is to create a shadow pl/sql procedure that takes all the record elements as separate IN OUT parameters and then create a private record based on the record type and pass it to the original procedure.
    Is my research here correct? Any help appreciated.
    Thanks & regards,
    CM.

    Chris,
    As far as I know, PL/SQL record types are not supported in JDBC.
    I believe you may be able to use TopLink.
    I think Kuassi Mensah may have some examples in his book Oracle Database Programming.
    Alternatively, you could use an Oracle object instead of a PL/SQL record.
    This would be similar to what you are suggesting except that instead of a ref cursor, you would transfer the PL/SQL record to an Oracle object.
    Good Luck,
    Avi.

  • CRITICALLY EVALUATE THIS FOR ME PLEASE

    THE COLLECTION CLASSES OFFER A SOLUTION TO THE PROBLEM OF IMPLEMENTING GENERICITY IN JAVA

    Try searching the forums for "We will not do your homework" and see how many hits you get.

  • My cellcom line doesn't work with my iPhone here in Israel, why? Is there any way I can solve this issue?

    My cellcom line doesn't work with my iPhone here in Israel, why? Is there any way I can solve this issue?

    Please explain.
    What does "cellcom line doesn't work with my iPhone" mean?
    What are you trying?  What is happening?
    Where did you buy the iphone?
    Any info abnout your issue at all?

  • Crackling loudspeaker? Can someone test this for me?

    I've noticed something that might be abnormal about the speakers on my iPhone 4S.
    Could someone test this for me please? Go to ringtones, and play the 'bell tower' ringtone making sure your ringer volume is all the way up. Listen closly to the speaker, can you notice a slight crackling sound at parts?
    Thanks

    So when you play the bell tower tone at full volume it sounds perfectly cripst and doesn't 'crackle' or distort a little bit because mine does.
    Also when I've asked siri a question, the tone after that when it plays sounds like it distorts a bit to.
    Cheers

  • Cracking Loudspeaker? Can someone test this for me

    I've noticed something that might be abnormal about the speakers on my iPhone 4S.
    Could someone test this for me please? Go to ringtones, and play the 'bell tower' ringtone making sure your ringer volume is all the way up. Listen closly to the speaker, can you notice a slight crackling sound at parts?
    Thanks

    So when you play the bell tower tone at full volume it sounds perfectly cripst and doesn't 'crackle' or distort a little bit because mine does.
    Also when I've asked siri a question, the tone after that when it plays sounds like it distorts a bit to.
    Cheers

  • Technology P2P with JAVA (How can i do for implement this tech with JAVA B)

    Thanks for read this message,,, I will glad with you if you can help me...
    I would like desing, make, build, a point to point aplication with JAVA Builder, I have been reading about sockets but its not enought,,,,,,
    can you help me????
    Thanks

    Well , thanxs for take attention,,,
    I need some information about Point to Point tech because I would like to make an aplication with JAVA Builder...
    First step is to know how works the point to point...could you give me some links?
    Second step is to know how can I do for implement this tech?
    Third step is to know Is Java Builder the most indicate languaje for this aplication?
    Fourth step is - if Java Buider is the indicate tool, What have to know for make the aplication?
    Well,,I dont speak english very well but is the best that i can do?
    BYE

  • HT5367 Does anyone know if I can download this version of Java - for OS X 2012-005 - the new Java update is a total mess and it is preventing me from working... need to go back :-(

    Does anyone know if I can download this version of Java - for OS X 2012-005 - the new Java update is a total mess for me and is preventing me from working remotely...  :-( really need to go back to older Java, don't have the Time Machine set up ...  Thx

    I wonder if it's a variation of this, of which I've seen many different symptoms...
    http://km.support.apple.com/library/APPLE/APPLECARE_ALLGEOS/TS4135/TS4135_01-osx _1072-login_window-001-en.png
    Resolution
    Move the mouse or trackpad cursor over the center area of the login window so you can see the user icons. Click on the icon of the user that you would like to login as, type in the user's password, and press Return.
    If the login window is configured to show only the name and password fields, type in the user's name and password into the fields, and press Return (even if you cannot see the rest of the login window).
    Additional Information
    This issue will not occur if the display is not sleeping when the account is logged out. Use the steps below to confirm that the account is not configured to log out automatically while the display is sleeping:
    Open System Preferences > Security & Privacy > General.  Click the padlock to unlock the preference pane and enter your admin password. Click the Advanced button at the bottom, then see if the option "Log out after N minutes of inactivity" (where N is the number of minutes) is enabled.
    Open System Preferences > Energy Saver and configure Display Sleep to occur after the account is logged out, by dragging the slider to a number of minutes that is greater than N was set to in the previous step.
    Important: If automatic log out is not needed, disable "Log out after Nminutes of inactivity" in System Preferences > Security & Privacy > General. This will also prevent the issue.
    http://support.apple.com/kb/TS4135?viewlocale=en_US

  • Import net.java.stun4j.StunAddress; anybody knows how i can get this jar fi

    Can anybody tell me how i can get this
    import net.java.stun4j.StunAddress;
    i need these jar files.

    Previous link was on older version, it did not help me. Finally I've got latest version in source from CVS

Maybe you are looking for